summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-11-17 16:48:17 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-16 07:58:56 -0800
commit24f3743fc11c7f0879b1180ca6e2e179d04da91f (patch)
treebbd8128a17fe4c8d20054f2079edc6b4c7775c41 /cmake
parent86765774dc8193ed910041b13be25c6d3145ce72 (diff)
downloadsubsurface-24f3743fc11c7f0879b1180ca6e2e179d04da91f.tar.gz
Start to clean the Main CMakeLists.txt filel
CMake is a strange and complex language for buildsystems, and as such we need to let the main CMakeLists.txt be as clear as possible. Moving a bunch of code that deals with finding git via default CMake way or pkg_cofig to a file named 'HandleFindGit' on our cmake/Modules folder. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/HandleFindGit2.cmake39
1 files changed, 39 insertions, 0 deletions
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()