@@ -155,32 +155,6 @@ ELSE(IS_ABSOLUTE ${INCLUDE_INSTALL_DIR})
155155 SET (PKGCONFIG_INCLUDEDIR "\$ {prefix}/${INCLUDE_INSTALL_DIR} " )
156156ENDIF (IS_ABSOLUTE ${INCLUDE_INSTALL_DIR} )
157157
158- FUNCTION (TARGET_OS_LIBRARIES target )
159- IF (WIN32 )
160- TARGET_LINK_LIBRARIES (${target} ws2_32)
161- ELSEIF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)" )
162- TARGET_LINK_LIBRARIES (${target} socket nsl)
163- LIST (APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl" )
164- SET (LIBGIT2_PC_LIBS ${LIBGIT2_PC_LIBS} PARENT_SCOPE)
165- ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Haiku" )
166- TARGET_LINK_LIBRARIES (${target} network)
167- LIST (APPEND LIBGIT2_PC_LIBS "-lnetwork" )
168- SET (LIBGIT2_PC_LIBS ${LIBGIT2_PC_LIBS} PARENT_SCOPE)
169- ENDIF ()
170- CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" NEED_LIBRT)
171- IF (NEED_LIBRT)
172- TARGET_LINK_LIBRARIES (${target} rt)
173- LIST (APPEND LIBGIT2_PC_LIBS "-lrt" )
174- SET (LIBGIT2_PC_LIBS ${LIBGIT2_PC_LIBS} PARENT_SCOPE)
175- ENDIF ()
176-
177- IF (THREADSAFE)
178- TARGET_LINK_LIBRARIES (${target} ${CMAKE_THREAD_LIBS_INIT} )
179- LIST (APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT} )
180- SET (LIBGIT2_PC_LIBS ${LIBGIT2_PC_LIBS} PARENT_SCOPE)
181- ENDIF ()
182- ENDFUNCTION ()
183-
184158# This function splits the sources files up into their appropriate
185159# subdirectories. This is especially useful for IDEs like Xcode and
186160# Visual Studio, so that you can navigate into the libgit2_clar project,
@@ -216,6 +190,27 @@ STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "$
216190
217191# Find required dependencies
218192
193+ IF (WIN32 )
194+ LIST (APPEND LIBGIT2_LIBS ws2_32)
195+ ELSEIF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)" )
196+ LIST (APPEND LIBGIT2_LIBS socket nsl)
197+ LIST (APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl" )
198+ ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Haiku" )
199+ LIST (APPEND LIBGIT2_LIBS network)
200+ LIST (APPEND LIBGIT2_PC_LIBS "-lnetwork" )
201+ ENDIF ()
202+
203+ CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" NEED_LIBRT)
204+ IF (NEED_LIBRT)
205+ LIST (APPEND LIBGIT2_LIBS rt)
206+ LIST (APPEND LIBGIT2_PC_LIBS "-lrt" )
207+ ENDIF ()
208+
209+ IF (THREADSAFE)
210+ LIST (APPEND LIBGIT2_LIBS ${CMAKE_THREAD_LIBS_INIT} )
211+ LIST (APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT} )
212+ ENDIF ()
213+
219214IF (SECURITY_FOUND)
220215 # OS X 10.7 and older do not have some functions we use, fall back to OpenSSL there
221216 CHECK_LIBRARY_EXISTS("${SECURITY_DIRS} " SSLCreateContext "Security/SecureTransport.h" HAVE_NEWER_SECURITY)
@@ -646,7 +641,6 @@ ENDIF()
646641LINK_DIRECTORIES (${LIBGIT2_LIBDIRS} )
647642ADD_LIBRARY (git2 ${WIN_RC} ${GIT2INTERNAL_OBJECTS} )
648643TARGET_LINK_LIBRARIES (git2 ${LIBGIT2_LIBS} )
649- TARGET_OS_LIBRARIES(git2)
650644
651645# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
652646# Win64+MSVC+static libs = linker error
0 commit comments