aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt34
-rw-r--r--cmake/Modules/HandleFindGit2.cmake39
2 files changed, 42 insertions, 31 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2bccbecd7..cb174b1fc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,6 +12,7 @@ option(LIBGIT2_FROM_PKGCONFIG "use pkg-config to retrieve libgit2" OFF)
option(LIBDC_FROM_PKGCONFIG "use pkg-config to retrieve libdivecomputer" OFF)
option(LIBGRANTLEE_FROM_PKGCONFIG "use pkg-config to retrieve grantlee" OFF)
option(LIBMARBLE_FROM_PKGCONFIG "use pkg-config to retrieve marble" OFF)
+
option(MAKE_TESTS "Make the tests" ON)
option(NO_MARBLE "disable the marble widget" OFF)
option(NO_DOCS "disable the docs" OFF)
@@ -72,6 +73,7 @@ endif()
# pkgconfig for required libraries
find_package(PkgConfig)
include(cmake/Modules/pkgconfig_helper.cmake)
+include(cmake/Modules/HandleFindGit2.cmake)
pkg_config_library(LIBXML libxml-2.0 REQUIRED)
pkg_config_library(LIBSQLITE3 sqlite3 REQUIRED)
@@ -79,42 +81,12 @@ pkg_config_library(LIBXSLT libxslt REQUIRED)
pkg_config_library(LIBZIP libzip REQUIRED)
pkg_config_library(LIBUSB libusb-1.0 QUIET)
+
if(SMARTTRAK_IMPORT)
pkg_config_library(GLIB2 glib-2.0 REQUIRED)
pkg_config_library(LIBMDB libmdb REQUIRED)
endif()
-# more libraries with special handling in case we build them ourselves
-if(LIBGIT2_FROM_PKGCONFIG)
- pkg_config_library(LIBGIT2 libgit2 REQUIRED)
- set(LIBGIT2_LIBRARIES "")
- if(ANDROID)
- # for Android we need to force a static link against ssl and crypto
- # this is a bit hacky, but it seems to work
- set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} ${LIBGIT2_LIBRARY_DIRS}/libssl.a ${LIBGIT2_LIBRARY_DIRS}/libcrypto.a)
- endif()
- if(FORCE_LIBSSH)
- pkg_config_library(LIBSSH2 libssh2 REQUIRED)
- set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} ${LIBSSH2_LIBRARIES})
- endif()
-else()
- find_package(LIBGIT2 REQUIRED)
- include_directories(${LIBGIT2_INCLUDE_DIR})
- if(FORCE_LIBSSH)
- find_package(Libssh2 QUIET CONFIG)
- if ("${LIBSSH2_VERSION}" STRGREATER "1.6.1")
- set(LIBSSH2_LIBRARIES Libssh2::libssh2)
- endif()
- if(!Libssh2_FOUND AND !LIBSSH2_FOUND)
- pkg_config_library(LIBSSH2 libssh2 REQUIRED)
- endif()
- endif()
- find_package(libcurl QUIET)
- if(!LIBCURL_FOUND OR "${LIBCURL_FOUND}" STREQUAL "")
- pkg_config_library(LIBCURL libcurl REQUIRED)
- endif()
- set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} -L${LIBSSH2_LIBRARY_DIRS} ${LIBSSH2_LIBRARIES} ${LIBCURL_LIBRARIES})
-endif()
if(LIBDC_FROM_PKGCONFIG)
pkg_config_library(LIBDC libdivecomputer REQUIRED)
diff --git a/cmake/Modules/HandleFindGit2.cmake b/cmake/Modules/HandleFindGit2.cmake
new file mode 100644
index 000000000..e0bb9979f
--- /dev/null
+++ b/cmake/Modules/HandleFindGit2.cmake
@@ -0,0 +1,39 @@
+# more libraries with special handling in case we build them ourselves
+if(LIBGIT2_FROM_PKGCONFIG)
+ pkg_config_library(LIBGIT2 libgit2 REQUIRED)
+ set(LIBGIT2_LIBRARIES "")
+ if(USE_LIBGIT23_API)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_LIBGIT23_API")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LIBGIT23_API")
+ if(ANDROID)
+ # for Android we need to force a static link against ssl and crypto
+ # this is a bit hacky, but it seems to work
+ set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} ${LIBGIT2_LIBRARY_DIRS}/libssl.a ${LIBGIT2_LIBRARY_DIRS}/libcrypto.a)
+ endif()
+ if(FORCE_LIBSSH)
+ pkg_config_library(LIBSSH2 libssh2 REQUIRED)
+ set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} ${LIBSSH2_LIBRARIES})
+ endif()
+ endif()
+else()
+ find_package(LIBGIT2 REQUIRED)
+ include_directories(${LIBGIT2_INCLUDE_DIR})
+ if(USE_LIBGIT23_API)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_LIBGIT23_API")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LIBGIT23_API")
+ if(FORCE_LIBSSH)
+ find_package(Libssh2 QUIET CONFIG)
+ if ("${LIBSSH2_VERSION}" STRGREATER "1.6.1")
+ set(LIBSSH2_LIBRARIES Libssh2::libssh2)
+ endif()
+ if(!LIBSSH2_FOUND OR "${LIBSSH2_FOUND}" STREQUAL "")
+ pkg_config_library(LIBSSH2 libssh2 REQUIRED)
+ endif()
+ endif()
+ find_package(libcurl QUIET)
+ if(!LIBCURL_FOUND OR "${LIBCURL_FOUND}" STREQUAL "")
+ pkg_config_library(LIBCURL libcurl REQUIRED)
+ endif()
+ set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} -L${LIBSSH2_LIBRARY_DIRS} ${LIBSSH2_LIBRARIES} ${LIBCURL_LIBRARIES})
+ endif()
+endif()