@@ -602,13 +602,19 @@ ENDIF()
602
602
603
603
SET (SRC_LIBGIT2 ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SSH} ${SRC_SHA1} )
604
604
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 ()
609
615
610
616
# Compile and link libgit2
611
- ADD_LIBRARY (git2 $< TARGET_OBJECTS:git2_src > ${WIN_RC} )
617
+ ADD_LIBRARY (git2 ${SRC_LIBGIT2} ${WIN_RC} )
612
618
TARGET_LINK_LIBRARIES (git2 ${SECURITY_DIRS} )
613
619
TARGET_LINK_LIBRARIES (git2 ${COREFOUNDATION_DIRS} )
614
620
TARGET_LINK_LIBRARIES (git2 ${SSL_LIBRARIES} )
@@ -685,7 +691,7 @@ IF (BUILD_CLAR)
685
691
${CLAR_PATH} /clar.c
686
692
PROPERTIES OBJECT_DEPENDS ${CLAR_PATH} /clar.suite )
687
693
688
- ADD_EXECUTABLE (git2_tests ${SRC_CLAR} ${SRC_TEST} $< TARGET_OBJECTS:git2_src > )
694
+ ADD_EXECUTABLE (git2_tests ${SRC_CLAR} ${SRC_TEST} ${SRC_LIBGIT2} )
689
695
690
696
TARGET_LINK_LIBRARIES (git2_tests ${COREFOUNDATION_DIRS} )
691
697
TARGET_LINK_LIBRARIES (git2_tests ${SECURITY_DIRS} )
0 commit comments