8000 cmake: only create target obj lib on new enough cmakes · libgit2/libgit2@f48190c · GitHub
[go: up one dir, main page]

Skip to content

Commit f48190c

Browse files
author
Edward Thomson
committed
cmake: only create target obj lib on new enough cmakes
1 parent 07f7b30 commit f48190c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

CMakeLists.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -602,13 +602,19 @@ ENDIF()
602602

603603
SET(SRC_LIBGIT2 ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SSH} ${SRC_SHA1})
604604

605-
# Compile the objects that make up our library; we will create an actual
606-
# shared/static library with them later.
607-
ADD_LIBRARY(git2_src OBJECT ${SRC_LIBGIT2})
608-
IDE_SPLIT_SOURCES(git2_src)
605+
# On a sufficiently new cmake, we can compile the objects that make up our
606+
# library as a separate target (without needing to link a library or an
607+
# executable). This will satisfy the dependency for our tests, and saves
608+
# us from having to recompile them.
609+
IF (${CMAKE_VERSION} VERSION_GREATER 2.8.7)
610+
ADD_LIBRARY(git2_src OBJECT ${SRC_LIBGIT2})
611+
IDE_SPLIT_SOURCES(git2_src)
612+
613+
SET(SRC_LIBGIT2 $<TARGET_OBJECTS:git2_src>)
614+
ENDIF()
609615

610616
# Compile and link libgit2
611-
ADD_LIBRARY(git2 $<TARGET_OBJECTS:git2_src> ${WIN_RC})
617+
ADD_LIBRARY(git2 ${SRC_LIBGIT2} ${WIN_RC})
612618
TARGET_LINK_LIBRARIES(git2 ${SECURITY_DIRS})
613619
TARGET_LINK_LIBRARIES(git2 ${COREFOUNDATION_DIRS})
614620
TARGET_LINK_LIBRARIES(git2 ${SSL_LIBRARIES})
@@ -685,7 +691,7 @@ IF (BUILD_CLAR)
685691
${CLAR_PATH}/clar.c
686692
PROPERTIES OBJECT_DEPENDS ${CLAR_PATH}/clar.suite)
687693

688-
ADD_EXECUTABLE(git2_tests ${SRC_CLAR} ${SRC_TEST} $<TARGET_OBJECTS:git2_src>)
694+
ADD_EXECUTABLE(git2_tests ${SRC_CLAR} ${SRC_TEST} ${SRC_LIBGIT2})
689695

690696
TARGET_LINK_LIBRARIES(git2_tests ${COREFOUNDATION_DIRS})
691697
TARGET_LINK_LIBRARIES(git2_tests ${SECURITY_DIRS})

0 commit comments

Comments
 (0)
0