@@ -602,20 +602,27 @@ 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} )
615
621
TARGET_LINK_LIBRARIES (git2 ${SSH_LIBRARIES} )
616
622
TARGET_LINK_LIBRARIES (git2 ${GSSAPI_LIBRARIES} )
617
623
TARGET_LINK_LIBRARIES (git2 ${ICONV_LIBRARIES} )
618
624
TARGET_OS_LIBRARIES(git2)
625
+ IDE_SPLIT_SOURCES(git2)
619
626
620
627
# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
621
628
# Win64+MSVC+static libs = linker error
@@ -685,7 +692,7 @@ IF (BUILD_CLAR)
685
692
${CLAR_PATH} /clar.c
686
693
PROPERTIES OBJECT_DEPENDS ${CLAR_PATH} /clar.suite)
687
694
688
- ADD_EXECUTABLE (git2_tests ${SRC_CLAR} ${SRC_TEST} $<TARGET_OBJECTS:git2_src> )
695
+ ADD_EXECUTABLE (git2_tests ${SRC_CLAR} ${SRC_TEST} ${SRC_LIBGIT2} )
689
696
690
697
TARGET_LINK_LIBRARIES (git2_tests ${COREFOUNDATION_DIRS} )
691
698
TARGET_LINK_LIBRARIES (git2_tests ${SECURITY_DIRS} )
0 commit comments