diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index df3936496..a14abae0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,9 +27,14 @@ OPTION( BUILD_EXAMPLES "Build library usage example apps" OFF ) OPTION( TAGS "Generate tags" OFF ) OPTION( PROFILE "Generate profiling information" OFF ) OPTION( ENABLE_TRACE "Enables tracing support" OFF ) -OPTION( LIBGIT2_FILENAME "Name of the produced binary" OFF ) +OPTION( LIBGIT2_FILENAME "Name of the produced binary" OFF ) -OPTION( ANDROID "Build for android NDK" OFF ) +OPTION( ANDROID "Build for android NDK" OFF ) + +OPTION( USE_ICONV "Link with and use iconv library" OFF ) +IF(APPLE) + SET( USE_ICONV ON ) +ENDIF() IF(MSVC) # This option is only available when building with MSVC. By default, libgit2 @@ -43,8 +48,21 @@ IF(MSVC) # This option must match the settings used in your program, in particular if you # are linking statically OPTION( STATIC_CRT "Link the static CRT libraries" ON ) + + # By default, libgit2 is built with WinHTTP. To use the built-in + # HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument. + OPTION( WINHTTP "Use Win32 WinHTTP routines" ON ) ENDIF() +# This variable will contain the libraries we need to put into +# libgit2.pc's Requires.private. That is, what we're linking to or +# what someone who's statically linking us needs to link to. +SET(LIBGIT2_PC_REQUIRES "") +# This will be set later if we use the system's http-parser library or +# use iconv (OSX) and will be written to the Libs.private field in the +# pc file. +SET(LIBGIT2_PC_LIBS "") + # Installation paths # SET(BIN_INSTALL_DIR bin CACHE PATH "Where to install binaries to.") @@ -56,9 +74,18 @@ FUNCTION(TARGET_OS_LIBRARIES target) TARGET_LINK_LIBRARIES(${target} ws2_32) ELSEIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") TARGET_LINK_LIBRARIES(${target} socket nsl) + SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lsocket -lnsl" PARENT_SCOPE) ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Linux") TARGET_LINK_LIBRARIES(${target} rt) - ENDIF () + SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lrt" PARENT_SCOPE) + ENDIF() + + IF(USE_ICONV) + TARGET_LINK_LIBRARIES(${target} iconv) + ADD_DEFINITIONS(-DGIT_USE_ICONV) + SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -liconv" PARENT_SCOPE) + ENDIF() + IF(THREADSAFE) TARGET_LINK_LIBRARIES(${target} ${CMAKE_THREAD_LIBS_INIT}) ENDIF() @@ -97,7 +124,7 @@ SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${ # Find required dependencies INCLUDE_DIRECTORIES(src include) -IF (WIN32 AND NOT MINGW) +IF (WIN32 AND WINHTTP AND NOT MINGW) ADD_DEFINITIONS(-DGIT_WINHTTP) ELSE () IF (NOT AMIGA) @@ -108,6 +135,7 @@ ELSE () IF (HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2) INCLUDE_DIRECTORIES(${HTTP_PARSER_INCLUDE_DIRS}) LINK_LIBRARIES(${HTTP_PARSER_LIBRARIES}) + SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lhttp_parser") ELSE() MESSAGE("http-parser was not found or is too old; using bundled 3rd-party sources.") INCLUDE_DIRECTORIES(deps/http-parser) @@ -121,6 +149,7 @@ IF (WIN32 AND NOT MINGW AND NOT SHA1_TYPE STREQUAL "builtin") FILE(GLOB SRC_SHA1 src/hash/hash_win32.c) ELSEIF (OPENSSL_FOUND AND NOT SHA1_TYPE STREQUAL "builtin") ADD_DEFINITIONS(-DOPENSSL_SHA1) + SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} openssl") ELSE() FILE(GLOB SRC_SHA1 src/hash/hash_generic.c) ENDIF() @@ -143,6 +172,11 @@ FIND_PACKAGE(ZLIB QUIET) IF (ZLIB_FOUND) INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS}) LINK_LIBRARIES(${ZLIB_LIBRARIES}) + IF(APPLE) + SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lz") + ELSE() + SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} zlib") + ENDIF() # Fake the message CMake would have shown MESSAGE("-- Found zlib: ${ZLIB_LIBRARY}") ELSE() @@ -158,6 +192,7 @@ ENDIF() IF (LIBSSH2_FOUND) ADD_DEFINITIONS(-DGIT_SSH) INCLUDE_DIRECTORIES(${LIBSSH2_INCLUDE_DIR}) + SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} libssh2") SET(SSH_LIBRARIES ${LIBSSH2_LIBRARIES}) ENDIF() |