cmake: detect GNU GSS
Fix to set `HAVE_GSSGNU` when GNU GSS is detected. Also set the appropriate `pkg-config` dependency and do version detection for the GNU GSS flavour. Tested with `pkg-config` and partly tested without. The latter case picks up everything else but, in my env. This is likely not the last word to implement this detection correctly for all build-cases. GNU GSS doesn't seem to have a Homebrew formula and building it locally needs manual tweaks to make finish successfully. Also move a MIT-specific header detection into to MIT-specific `if` branch. Closes #15176
This commit is contained in:
parent
3db50bd01f
commit
9e19a577eb
@ -30,7 +30,7 @@
|
||||
# Result variables:
|
||||
#
|
||||
# GSS_FOUND System has the Heimdal library
|
||||
# GSS_FLAVOUR "MIT" or "Heimdal" if anything found
|
||||
# GSS_FLAVOUR "GNU", "MIT" or "Heimdal" if anything found
|
||||
# GSS_INCLUDE_DIRS The GSS include directories
|
||||
# GSS_LIBRARIES The GSS library names
|
||||
# GSS_LIBRARY_DIRS The GSS library directories
|
||||
@ -39,6 +39,7 @@
|
||||
# GSS_VERSION This is set to version advertised by pkg-config or read from manifest.
|
||||
# In case the library is found but no version info available it is set to "unknown"
|
||||
|
||||
set(_gnu_modname "gss")
|
||||
set(_mit_modname "mit-krb5-gssapi")
|
||||
set(_heimdal_modname "heimdal-gssapi")
|
||||
|
||||
@ -55,7 +56,7 @@ set(_gss_root_hints
|
||||
if(NOT GSS_ROOT_DIR AND NOT "$ENV{GSS_ROOT_DIR}")
|
||||
if(CURL_USE_PKGCONFIG)
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_search_module(_GSS ${_mit_modname} ${_heimdal_modname})
|
||||
pkg_search_module(_GSS ${_gnu_modname} ${_mit_modname} ${_heimdal_modname})
|
||||
list(APPEND _gss_root_hints "${_GSS_PREFIX}")
|
||||
endif()
|
||||
if(WIN32)
|
||||
@ -203,6 +204,17 @@ if(NOT _GSS_FOUND) # Not found by pkg-config. Let us take more traditional appr
|
||||
|
||||
if(_GSS_INCLUDE_DIRS)
|
||||
set(GSS_FLAVOUR "Heimdal")
|
||||
else()
|
||||
find_path(_GSS_INCLUDE_DIRS NAMES "gss.h"
|
||||
HINTS
|
||||
${_gss_root_hints}
|
||||
PATH_SUFFIXES
|
||||
"include"
|
||||
)
|
||||
|
||||
if(_GSS_INCLUDE_DIRS)
|
||||
set(GSS_FLAVOUR "GNU")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -216,14 +228,18 @@ if(NOT _GSS_FOUND) # Not found by pkg-config. Let us take more traditional appr
|
||||
if(WIN32)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
list(APPEND _gss_libdir_suffixes "lib/AMD64")
|
||||
if(GSS_FLAVOUR STREQUAL "MIT")
|
||||
if(GSS_FLAVOUR STREQUAL "GNU")
|
||||
set(_gss_libname "gss")
|
||||
elseif(GSS_FLAVOUR STREQUAL "MIT")
|
||||
set(_gss_libname "gssapi64")
|
||||
else()
|
||||
set(_gss_libname "libgssapi")
|
||||
endif()
|
||||
else()
|
||||
list(APPEND _gss_libdir_suffixes "lib/i386")
|
||||
if(GSS_FLAVOUR STREQUAL "MIT")
|
||||
if(GSS_FLAVOUR STREQUAL "GNU")
|
||||
set(_gss_libname "gss")
|
||||
elseif(GSS_FLAVOUR STREQUAL "MIT")
|
||||
set(_gss_libname "gssapi32")
|
||||
else()
|
||||
set(_gss_libname "libgssapi")
|
||||
@ -231,7 +247,9 @@ if(NOT _GSS_FOUND) # Not found by pkg-config. Let us take more traditional appr
|
||||
endif()
|
||||
else()
|
||||
list(APPEND _gss_libdir_suffixes "lib;lib64") # those suffixes are not checked for HINTS
|
||||
if(GSS_FLAVOUR STREQUAL "MIT")
|
||||
if(GSS_FLAVOUR STREQUAL "GNU")
|
||||
set(_gss_libname "gss")
|
||||
elseif(GSS_FLAVOUR STREQUAL "MIT")
|
||||
set(_gss_libname "gssapi_krb5")
|
||||
else()
|
||||
set(_gss_libname "gssapi")
|
||||
@ -247,7 +265,13 @@ if(NOT _GSS_FOUND) # Not found by pkg-config. Let us take more traditional appr
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
if(_GSS_MODULE_NAME STREQUAL _mit_modname OR _GSS_${_mit_modname}_VERSION) # _GSS_MODULE_NAME set since CMake 3.16
|
||||
# _GSS_MODULE_NAME set since CMake 3.16
|
||||
if(_GSS_MODULE_NAME STREQUAL _gnu_modname OR _GSS_${_gnu_modname}_VERSION)
|
||||
set(GSS_FLAVOUR "GNU")
|
||||
if(NOT _GSS_VERSION) # for old CMake versions?
|
||||
set(_GSS_VERSION ${_GSS_${_gnu_modname}_VERSION})
|
||||
endif()
|
||||
elseif(_GSS_MODULE_NAME STREQUAL _mit_modname OR _GSS_${_mit_modname}_VERSION)
|
||||
set(GSS_FLAVOUR "MIT")
|
||||
if(NOT _GSS_VERSION) # for old CMake versions?
|
||||
set(_GSS_VERSION ${_GSS_${_mit_modname}_VERSION})
|
||||
@ -294,6 +318,15 @@ if(GSS_FLAVOUR)
|
||||
else()
|
||||
set(GSS_VERSION "MIT Unknown")
|
||||
endif()
|
||||
elseif(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "GNU")
|
||||
if(GSS_INCLUDE_DIRS AND EXISTS "${GSS_INCLUDE_DIRS}/gss.h")
|
||||
set(_version_regex "#[\t ]*define[\t ]+GSS_VERSION[\t ]+\"([^\"]*)\"")
|
||||
file(STRINGS "${GSS_INCLUDE_DIRS}/gss.h" _version_str REGEX "${_version_regex}")
|
||||
string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}")
|
||||
set(GSS_VERSION "${_version_str}")
|
||||
unset(_version_regex)
|
||||
unset(_version_str)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@ -1178,30 +1178,32 @@ if(CURL_USE_GSSAPI)
|
||||
set(GSS_LDFLAGS "${GSS_LDFLAGS} -L\"${_dir}\"")
|
||||
endforeach()
|
||||
|
||||
check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H)
|
||||
check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H)
|
||||
check_include_file_concat("gssapi/gssapi_krb5.h" _have_gssapi_gssapi_krb5_h)
|
||||
if(NOT GSS_FLAVOUR STREQUAL "GNU")
|
||||
check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H)
|
||||
check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H)
|
||||
|
||||
if(GSS_FLAVOUR STREQUAL "MIT")
|
||||
set(_include_list "")
|
||||
if(HAVE_GSSAPI_GSSAPI_H)
|
||||
list(APPEND _include_list "gssapi/gssapi.h")
|
||||
endif()
|
||||
if(HAVE_GSSAPI_GSSAPI_GENERIC_H)
|
||||
list(APPEND _include_list "gssapi/gssapi_generic.h")
|
||||
endif()
|
||||
if(_have_gssapi_gssapi_krb5_h)
|
||||
list(APPEND _include_list "gssapi/gssapi_krb5.h")
|
||||
endif()
|
||||
if(GSS_FLAVOUR STREQUAL "MIT")
|
||||
check_include_file_concat("gssapi/gssapi_krb5.h" _have_gssapi_gssapi_krb5_h)
|
||||
set(_include_list "")
|
||||
if(HAVE_GSSAPI_GSSAPI_H)
|
||||
list(APPEND _include_list "gssapi/gssapi.h")
|
||||
endif()
|
||||
if(HAVE_GSSAPI_GSSAPI_GENERIC_H)
|
||||
list(APPEND _include_list "gssapi/gssapi_generic.h")
|
||||
endif()
|
||||
if(_have_gssapi_gssapi_krb5_h)
|
||||
list(APPEND _include_list "gssapi/gssapi_krb5.h")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED HAVE_GSS_C_NT_HOSTBASED_SERVICE)
|
||||
set(CMAKE_REQUIRED_FLAGS "${GSS_CFLAGS} ${GSS_LDFLAGS}")
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${GSS_LIBRARIES})
|
||||
check_symbol_exists("GSS_C_NT_HOSTBASED_SERVICE" ${_include_list} HAVE_GSS_C_NT_HOSTBASED_SERVICE)
|
||||
unset(CMAKE_REQUIRED_LIBRARIES)
|
||||
endif()
|
||||
if(NOT HAVE_GSS_C_NT_HOSTBASED_SERVICE)
|
||||
set(HAVE_OLD_GSSMIT ON)
|
||||
if(NOT DEFINED HAVE_GSS_C_NT_HOSTBASED_SERVICE)
|
||||
set(CMAKE_REQUIRED_FLAGS "${GSS_CFLAGS} ${GSS_LDFLAGS}")
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${GSS_LIBRARIES})
|
||||
check_symbol_exists("GSS_C_NT_HOSTBASED_SERVICE" ${_include_list} HAVE_GSS_C_NT_HOSTBASED_SERVICE)
|
||||
unset(CMAKE_REQUIRED_LIBRARIES)
|
||||
endif()
|
||||
if(NOT HAVE_GSS_C_NT_HOSTBASED_SERVICE)
|
||||
set(HAVE_OLD_GSSMIT ON)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -1211,7 +1213,10 @@ if(CURL_USE_GSSAPI)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GSS_LDFLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GSS_LDFLAGS}")
|
||||
list(APPEND CURL_LIBS ${GSS_LIBRARIES})
|
||||
if(GSS_FLAVOUR STREQUAL "MIT")
|
||||
if(GSS_FLAVOUR STREQUAL "GNU")
|
||||
set(HAVE_GSSGNU 1)
|
||||
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "gss")
|
||||
elseif(GSS_FLAVOUR STREQUAL "MIT")
|
||||
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "mit-krb5-gssapi")
|
||||
else() # Heimdal
|
||||
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "heimdal-gssapi")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user