Skip to content

Commit 1d9dd88

Browse files
committed
cmake: distinguish libgit2 objects and sources
Distinguish variables keeping track of our internal libgit2 sources and the final objects which shall be linked into the library. This will ease the transition to use object libraries for our bundled dependencies instead of linking them in.
1 parent c17c3f8 commit 1d9dd88

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/CMakeLists.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ IF(DEBUG_POOL)
22
SET(GIT_DEBUG_POOL 1)
33
ENDIF()
44

5+
SET(LIBGIT2_OBJECTS "")
6+
57
# This variable will contain the libraries we need to put into
68
# libgit2.pc's Requires.private. That is, what we're linking to or
79
# what someone who's statically linking us needs to link to.
@@ -330,12 +332,12 @@ ENDIF()
330332

331333
CONFIGURE_FILE(features.h.in git2/sys/features.h)
332334

333-
SET(GIT2INTERNAL_OBJECTS ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_SSH} ${SRC_SHA1})
335+
SET(LIBGIT2_SOURCES ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_SSH} ${SRC_SHA1})
334336

335337
IF (CMAKE_VERSION VERSION_GREATER 2.8.7)
336-
ADD_LIBRARY(git2internal OBJECT ${GIT2INTERNAL_OBJECTS})
338+
ADD_LIBRARY(git2internal OBJECT ${LIBGIT2_SOURCES})
337339
IDE_SPLIT_SOURCES(git2internal)
338-
SET(GIT2INTERNAL_OBJECTS $<TARGET_OBJECTS:git2internal>)
340+
LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>)
339341

340342
IF (${CMAKE_VERSION} VERSION_LESS 2.8.12)
341343
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
@@ -346,16 +348,17 @@ IF (CMAKE_VERSION VERSION_GREATER 2.8.7)
346348
ENDIF()
347349
ELSE()
348350
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
351+
LIST(APPEND LIBGIT2_OBJECTS ${LIBGIT2_SOURCES})
349352
ENDIF()
350353

351-
SET(GIT2INTERNAL_OBJECTS ${GIT2INTERNAL_OBJECTS} PARENT_SCOPE)
354+
SET(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
352355
SET(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
353356
SET(LIBGIT2_LIBS ${LIBGIT2_LIBS} PARENT_SCOPE)
354357
SET(LIBGIT2_LIBDIRS ${LIBGIT2_LIBDIRS} PARENT_SCOPE)
355358

356359
# Compile and link libgit2
357360
LINK_DIRECTORIES(${LIBGIT2_LIBDIRS})
358-
ADD_LIBRARY(git2 ${WIN_RC} ${GIT2INTERNAL_OBJECTS})
361+
ADD_LIBRARY(git2 ${WIN_RC} ${LIBGIT2_OBJECTS})
359362
TARGET_LINK_LIBRARIES(git2 ${LIBGIT2_LIBS})
360363

361364
SET_TARGET_PROPERTIES(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ SET_SOURCE_FILES_PROPERTIES(
3333
LINK_DIRECTORIES(${LIBGIT2_LIBDIRS})
3434
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
3535

36-
ADD_EXECUTABLE(libgit2_clar ${SRC_CLAR} ${SRC_TEST} ${GIT2INTERNAL_OBJECTS})
36+
ADD_EXECUTABLE(libgit2_clar ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS})
3737

3838
SET_TARGET_PROPERTIES(libgit2_clar PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
3939

0 commit comments

Comments
 (0)