summaryrefslogtreecommitdiff
path: root/cmake/Modules/SelectGSSAPI.cmake
blob: 9b2bb1fc54f75eb07b6ff75cb3e88486a462d230 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Select the backend to use

# We try to find any packages our backends might use

INCLUDE(SanitizeBool)

FIND_PACKAGE(GSSAPI)
IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
	INCLUDE(FindGSSFramework)
ENDIF()

# Auto-select GSS backend
SanitizeBool(USE_GSSAPI)
IF (USE_GSSAPI STREQUAL ON)
	IF (GSSFRAMEWORK_FOUND)
		SET(GSS_BACKEND "GSS.framework")
	ELSEIF(GSSAPI_FOUND)
		SET(GSS_BACKEND "gssapi")
	ELSE()
		MESSAGE(FATAL_ERROR "Unable to autodetect a usable GSS backend."
			"Please pass the backend name explicitly (-DUSE_GSS=backend)")
	ENDIF()
ELSEIF(USE_GSSAPI)
	# Backend was explicitly set
	SET(GSS_BACKEND ${USE_GSSAPI})
ELSE()
	SET(GSS_BACKEND NO)
ENDIF()

IF(GSS_BACKEND)
	# Check that we can find what's required for the selected backend
	IF (GSS_BACKEND STREQUAL "GSS.framework")
		IF (NOT GSSFRAMEWORK_FOUND)
			MESSAGE(FATAL_ERROR "Asked for GSS.framework backend, but it wasn't found")
		ENDIF()

		LIST(APPEND LIBGIT2_LIBS ${GSSFRAMEWORK_LIBRARIES})

		SET(GIT_GSSFRAMEWORK 1)
		ADD_FEATURE_INFO(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${GSS_BACKEND})")
	ELSEIF (GSS_BACKEND STREQUAL "gssapi")
		IF (NOT GSSAPI_FOUND)
			MESSAGE(FATAL_ERROR "Asked for gssapi GSS backend, but it wasn't found")
		ENDIF()

		LIST(APPEND LIBGIT2_LIBS ${GSSAPI_LIBRARIES})

		SET(GIT_GSSAPI 1)
		ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${GSS_BACKEND})")
	ELSE()
		MESSAGE(FATAL_ERROR "Asked for backend ${GSS_BACKEND} but it wasn't found")
	ENDIF()
ELSE()
	SET(GIT_GSSAPI 0)
	ADD_FEATURE_INFO(SPNEGO NO "SPNEGO authentication support")
ENDIF()