Skip to content

Commit 4969a67

Browse files
committed
cmake: create a dummy file for Xcode
Otherwise Xcode will happily not-link our git2 target, resulting in a "missing file" error when building eg. examples
1 parent 1bf173c commit 4969a67

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ IF(DEBUG_POOL)
33
ENDIF()
44
ADD_FEATURE_INFO(debugpool GIT_DEBUG_POOL "debug pool allocator")
55

6-
# Add the features.h file as a dummy. This is required for Xcode
7-
# to successfully build the libgit2 library when using only
8-
# object libraries.
9-
SET(LIBGIT2_OBJECTS "${CMAKE_CURRENT_BINARY_DIR}/git2/sys/features.h")
10-
116
# This variable will contain the libraries we need to put into
127
# libgit2.pc's Requires.private. That is, what we're linking to or
138
# what someone who's statically linking us needs to link to.
@@ -404,6 +399,13 @@ SET(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
404399
SET(LIBGIT2_LIBS ${LIBGIT2_LIBS} PARENT_SCOPE)
405400
SET(LIBGIT2_LIBDIRS ${LIBGIT2_LIBDIRS} PARENT_SCOPE)
406401

402+
IF(XCODE_VERSION)
403+
# This is required for Xcode to actually link the libgit2 library
404+
# when using only object libraries.
405+
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.c "")
406+
LIST(APPEND LIBGIT2_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/dummy.c)
407+
ENDIF()
408+
407409
# Compile and link libgit2
408410
LINK_DIRECTORIES(${LIBGIT2_LIBDIRS})
409411
ADD_LIBRARY(git2 ${WIN_RC} ${LIBGIT2_OBJECTS})

0 commit comments

Comments
 (0)