Skip to content

Commit 0e70903

Browse files
committed
cmake: fix linking in Xcode with object libraries only
CMake is unable to generate a correct Xcode project when trying to link libraries with only object libraries as its input. As our new build infrastructure makes heavy use of object libraries now, this affects our libgit2 library target, as well, leading to linking errors. Fix the issue by adding a dummy file to the libgit2 objects. As we always have the "features.h" header ready which contains defines only, we can simply link it into the resulting library without any effect whatsoever. This fixes building with Xcode.
1 parent 38e769c commit 0e70903

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ IF(DEBUG_POOL)
22
SET(GIT_DEBUG_POOL 1)
33
ENDIF()
44

5-
SET(LIBGIT2_OBJECTS "")
5+
# Add the features.h file as a dummy. This is required for Xcode
6+
# to successfully build the libgit2 library when using only
7+
# object libraries.
8+
SET(LIBGIT2_OBJECTS "${CMAKE_CURRENT_BINARY_DIR}/git2/sys/features.h")
69

710
# This variable will contain the libraries we need to put into
811
# libgit2.pc's Requires.private. That is, what we're linking to or

0 commit comments

Comments
 (0)