summaryrefslogtreecommitdiffstats
path: root/cmake/Modules/HandleFindGit2.cmake
blob: ee1f1521b200bcdd4c14e1b5bc48d55d88d1b6b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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(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} -lcrypto)
	endif()
else()
	find_package(LIBGIT2 REQUIRED)
	include_directories(${LIBGIT2_INCLUDE_DIR})
	if(FORCE_LIBSSH)
		find_package(Libssh2 QUIET CONFIG)
		if (LIBSSH2_VERSION VERSION_LESS "1.7" AND LIBSSH2_VERSION VERSION_GREATER "1.6.1")
			set(LIBSSH2_LIBRARIES Libssh2::libssh2)
		endif()
		# at least on my Mac I get the mixed case variable instead...
		if(Libssh2_FOUND)
			set(LIBSSH2_FOUND ${Libssh2_FOUND})
		endif()
		if(NOT LIBSSH2_FOUND)
			pkg_config_library(LIBSSH2 libssh2 REQUIRED)
		endif()
	endif()
	find_package(libcurl QUIET)
	if(NOT LIBCURL_FOUND)
		pkg_config_library(LIBCURL libcurl REQUIRED)
	endif()
	if(NOT LIBSSH2_LIBRARY_DIRS)
		set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} ${LIBSSH2_LIBRARIES} ${LIBCURL_LIBRARIES} -lcrypto)
	else()
		set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} -L${LIBSSH2_LIBRARY_DIRS} ${LIBSSH2_LIBRARIES} ${LIBCURL_LIBRARIES} -lcrypto)
	endif()
endif()