2009-09-23 19:40:25 +00:00
|
|
|
#
|
Fix up handling of the Kerberos package.
On Ubuntu 16.04, and possibly other versions of Ubuntu, and on Debian
and other Debian derivatives, packages for MIT and Heimdal Kerberos can
both be installed at the same time - including developer packages.
Collisions between headers and libraries are handled by putting them in
subdirectories of the system include and library directory and having
their .pc files add -isystem flags to point to the appropriate include
directory and -L flags to point to the appropriate library directory.
CMake's pkg-config support, however, only looks for -I flags, not
-isystem flags, in pkg-config output (using --cflags-only-I), so it
doesn't get the directory in which to look for the headers, and just
uses the results of --libs-only-l to get a list of library names and
does nothing with the results of --libs-only-L, causing it not to look
for libraries in the directory in which to look for the libraries.
We fix this by:
If FindKERBEROS.cmake found Kerberos with pkg-config, have it set
KERBEROS_DEFINITIONS to the "other" compiler flags, which includes the
-isystem flag.
For all packages, adding the <PACKAGE>_DEFINITIONS values to
CMAKE_C_FLAGS and CMAKE_CXX_FLAGS so that they're used when compiling.
If FindKERBEROS.cmake found Kerberos with pkg-config, having it search
for each of the libraries in KERBEROS_LIBRARIES using find_library()
with KERBEROS_LIBDIR and KERBEROS_LIBRARY_DIRS as hints, and
re-assembling the resulting full paths into KERBEROS_LIBRARIES.
Change-Id: Ie18b56b76934f542bd12dc737631c0190026d18a
Reviewed-on: https://code.wireshark.org/review/27071
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-04-22 02:38:08 +00:00
|
|
|
# - Find Kerberos
|
|
|
|
# Find the native Kerberos includes and library
|
2009-09-10 07:04:54 +00:00
|
|
|
#
|
Fix up handling of the Kerberos package.
On Ubuntu 16.04, and possibly other versions of Ubuntu, and on Debian
and other Debian derivatives, packages for MIT and Heimdal Kerberos can
both be installed at the same time - including developer packages.
Collisions between headers and libraries are handled by putting them in
subdirectories of the system include and library directory and having
their .pc files add -isystem flags to point to the appropriate include
directory and -L flags to point to the appropriate library directory.
CMake's pkg-config support, however, only looks for -I flags, not
-isystem flags, in pkg-config output (using --cflags-only-I), so it
doesn't get the directory in which to look for the headers, and just
uses the results of --libs-only-l to get a list of library names and
does nothing with the results of --libs-only-L, causing it not to look
for libraries in the directory in which to look for the libraries.
We fix this by:
If FindKERBEROS.cmake found Kerberos with pkg-config, have it set
KERBEROS_DEFINITIONS to the "other" compiler flags, which includes the
-isystem flag.
For all packages, adding the <PACKAGE>_DEFINITIONS values to
CMAKE_C_FLAGS and CMAKE_CXX_FLAGS so that they're used when compiling.
If FindKERBEROS.cmake found Kerberos with pkg-config, having it search
for each of the libraries in KERBEROS_LIBRARIES using find_library()
with KERBEROS_LIBDIR and KERBEROS_LIBRARY_DIRS as hints, and
re-assembling the resulting full paths into KERBEROS_LIBRARIES.
Change-Id: Ie18b56b76934f542bd12dc737631c0190026d18a
Reviewed-on: https://code.wireshark.org/review/27071
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-04-22 02:38:08 +00:00
|
|
|
# KERBEROS_INCLUDE_DIRS - where to find krb5.h, etc.
|
|
|
|
# KERBEROS_DEFINITIONS - -D and other compiler flags to use with krb5.
|
|
|
|
# KERBEROS_LIBRARIES - List of libraries when using krb5.
|
|
|
|
# KERBEROS_LINK_FLAGS - other linker flags to use with krb5.
|
|
|
|
# KERBEROS_FOUND - True if krb5 found.
|
|
|
|
# KERBEROS_DLL_DIR - (Windows) Path to the Kerberos DLLs.
|
|
|
|
# KERBEROS_DLLS - (Windows) List of required Kerberos DLLs.
|
|
|
|
# HAVE_HEIMDAL_KERBEROS - set if the Kerberos vendor is Heimdal
|
|
|
|
# HAVE_MIT_KERBEROS - set if the Kerberos vendor is MIT
|
2009-09-10 07:04:54 +00:00
|
|
|
|
|
|
|
|
2015-10-09 14:26:24 +00:00
|
|
|
if(KERBEROS_INCLUDE_DIRS)
|
2009-09-10 07:04:54 +00:00
|
|
|
# Already in cache, be silent
|
2015-10-09 14:26:24 +00:00
|
|
|
set(KERBEROS_FIND_QUIETLY TRUE)
|
|
|
|
endif()
|
2009-09-10 07:04:54 +00:00
|
|
|
|
2015-10-09 14:26:24 +00:00
|
|
|
include(FindWSWinLibs)
|
2019-02-06 16:24:24 +00:00
|
|
|
FindWSWinLibs("krb5-.*" "KERBEROS_HINTS")
|
2009-09-10 07:04:54 +00:00
|
|
|
|
2023-04-10 13:24:34 +00:00
|
|
|
if(NOT USE_REPOSITORY)
|
2017-11-18 20:16:32 +00:00
|
|
|
find_package(PkgConfig)
|
|
|
|
pkg_search_module(KERBEROS krb5 mit-krb5 heimdal-krb5)
|
|
|
|
endif()
|
2014-09-25 10:09:23 +00:00
|
|
|
|
Fix up handling of the Kerberos package.
On Ubuntu 16.04, and possibly other versions of Ubuntu, and on Debian
and other Debian derivatives, packages for MIT and Heimdal Kerberos can
both be installed at the same time - including developer packages.
Collisions between headers and libraries are handled by putting them in
subdirectories of the system include and library directory and having
their .pc files add -isystem flags to point to the appropriate include
directory and -L flags to point to the appropriate library directory.
CMake's pkg-config support, however, only looks for -I flags, not
-isystem flags, in pkg-config output (using --cflags-only-I), so it
doesn't get the directory in which to look for the headers, and just
uses the results of --libs-only-l to get a list of library names and
does nothing with the results of --libs-only-L, causing it not to look
for libraries in the directory in which to look for the libraries.
We fix this by:
If FindKERBEROS.cmake found Kerberos with pkg-config, have it set
KERBEROS_DEFINITIONS to the "other" compiler flags, which includes the
-isystem flag.
For all packages, adding the <PACKAGE>_DEFINITIONS values to
CMAKE_C_FLAGS and CMAKE_CXX_FLAGS so that they're used when compiling.
If FindKERBEROS.cmake found Kerberos with pkg-config, having it search
for each of the libraries in KERBEROS_LIBRARIES using find_library()
with KERBEROS_LIBDIR and KERBEROS_LIBRARY_DIRS as hints, and
re-assembling the resulting full paths into KERBEROS_LIBRARIES.
Change-Id: Ie18b56b76934f542bd12dc737631c0190026d18a
Reviewed-on: https://code.wireshark.org/review/27071
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-04-22 02:38:08 +00:00
|
|
|
if(KERBEROS_FOUND)
|
|
|
|
#
|
|
|
|
# Turn KERBEROS_CFLAGS_OTHER into KERBEROS_DEFINITIONS;
|
|
|
|
# <XPREFIX>_DEFINITIONS really means "flags other than -I,
|
|
|
|
# including both -D and other flags".
|
|
|
|
#
|
|
|
|
set(KERBEROS_DEFINITIONS "${KERBEROS_CFLAGS_OTHER}")
|
|
|
|
|
|
|
|
#
|
|
|
|
# KERBEROS_LIBRARIES is a list of library names, not library
|
|
|
|
# paths, and KERBEROS_LIBRARY_DIRS is a list of -L flag
|
|
|
|
# arguments. Turn KERBEROS_LIBRARIES into a list of absolute
|
|
|
|
# paths for libraries, by searching for the libraries in
|
|
|
|
# directories including KERBEROS_LIBRARY_DIRS.
|
|
|
|
#
|
|
|
|
set(_kerberos_libraries "${KERBEROS_LIBRARIES}")
|
|
|
|
set(KERBEROS_LIBRARIES "")
|
|
|
|
foreach(_library ${_kerberos_libraries})
|
|
|
|
#
|
|
|
|
# Search for the library, using the library directories from
|
|
|
|
# pkg_search_module as hints.
|
|
|
|
#
|
|
|
|
find_library(_abspath_${_library} NAMES ${_library}
|
|
|
|
HINTS ${KERBEROS_LIBDIR} ${KERBEROS_LIBRARY_DIRS})
|
|
|
|
list(APPEND KERBEROS_LIBRARIES ${_abspath_${_library}})
|
|
|
|
endforeach()
|
|
|
|
else()
|
2015-10-09 14:26:24 +00:00
|
|
|
# Fallback detection if pkg-config files are not installed.
|
|
|
|
# Note, this fallback will not add k5crypto and com_err libraries on Linux,
|
|
|
|
# ensure that pkg-config files are installed for full support.
|
|
|
|
find_path(KERBEROS_INCLUDE_DIR krb5.h
|
|
|
|
HINTS
|
|
|
|
"${KERBEROS_HINTS}/include"
|
|
|
|
)
|
2013-09-23 21:45:55 +00:00
|
|
|
|
2015-10-09 14:26:24 +00:00
|
|
|
set(KERBEROS_NAMES krb5 krb5_32 krb5_64)
|
|
|
|
find_library(KERBEROS_LIBRARY NAMES ${KERBEROS_NAMES}
|
|
|
|
HINTS
|
|
|
|
"${KERBEROS_HINTS}/lib"
|
|
|
|
)
|
2009-09-10 07:04:54 +00:00
|
|
|
|
2015-10-09 14:26:24 +00:00
|
|
|
# handle the QUIETLY and REQUIRED arguments and set KERBEROS_FOUND to TRUE if
|
|
|
|
# all listed variables are TRUE
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(KERBEROS DEFAULT_MSG KERBEROS_LIBRARY KERBEROS_INCLUDE_DIR)
|
2009-09-10 07:04:54 +00:00
|
|
|
|
2015-10-09 14:26:24 +00:00
|
|
|
if(KERBEROS_FOUND)
|
|
|
|
set(KERBEROS_LIBRARIES ${KERBEROS_LIBRARY})
|
|
|
|
set(KERBEROS_INCLUDE_DIRS ${KERBEROS_INCLUDE_DIR})
|
|
|
|
else()
|
|
|
|
set(KERBEROS_LIBRARIES)
|
|
|
|
set(KERBEROS_INCLUDE_DIRS)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Try to detect the installed Kerberos vendor, assume MIT if it was not Heimdal.
|
|
|
|
if(KERBEROS_FOUND)
|
|
|
|
include(CheckSymbolExists)
|
2021-08-10 15:46:40 +00:00
|
|
|
include(CheckFunctionExists)
|
2015-10-09 14:26:24 +00:00
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${KERBEROS_INCLUDE_DIRS})
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${KERBEROS_LIBRARIES})
|
2015-02-19 04:40:29 +00:00
|
|
|
#see also HAVE_HEIMDAL_KERBEROS in cmakeconfig.h.in
|
2015-10-09 14:26:24 +00:00
|
|
|
check_symbol_exists("heimdal_version" "krb5.h" HAVE_HEIMDAL_KERBEROS)
|
2015-02-19 04:40:29 +00:00
|
|
|
# see also HAVE_KRB5_PAC_VERIFY cmakeconfig.h.in
|
2020-01-09 12:34:06 +00:00
|
|
|
check_symbol_exists("krb5_pac_verify" "krb5.h" HAVE_KRB5_PAC_VERIFY)
|
2015-02-19 04:40:29 +00:00
|
|
|
# see also HAVE_KRB5_C_FX_CF2_SIMPLE in cmakeconfig.h.in
|
|
|
|
check_symbol_exists("krb5_c_fx_cf2_simple" "krb5.h" HAVE_KRB5_C_FX_CF2_SIMPLE)
|
2021-07-05 08:57:12 +00:00
|
|
|
check_function_exists(decode_krb5_enc_tkt_part HAVE_DECODE_KRB5_ENC_TKT_PART)
|
|
|
|
check_function_exists(encode_krb5_enc_tkt_part HAVE_ENCODE_KRB5_ENC_TKT_PART)
|
2015-10-09 14:26:24 +00:00
|
|
|
set(CMAKE_REQUIRED_INCLUDES)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
if(NOT HAVE_HEIMDAL_KERBEROS)
|
|
|
|
set(HAVE_MIT_KERBEROS 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
2009-09-10 07:04:54 +00:00
|
|
|
|
2015-10-09 14:26:24 +00:00
|
|
|
if(WIN32)
|
|
|
|
if(KERBEROS_FOUND)
|
|
|
|
set(KERBEROS_DLL_DIR "${KERBEROS_HINTS}/bin"
|
2015-01-12 22:44:42 +00:00
|
|
|
CACHE PATH "Path to the Kerberos DLLs"
|
|
|
|
)
|
2015-10-09 14:26:24 +00:00
|
|
|
file(GLOB _kerberos_dlls RELATIVE "${KERBEROS_DLL_DIR}"
|
2015-01-12 22:44:42 +00:00
|
|
|
"${KERBEROS_DLL_DIR}/comerr??.dll"
|
|
|
|
"${KERBEROS_DLL_DIR}/krb5_??.dll"
|
|
|
|
"${KERBEROS_DLL_DIR}/k5sprt??.dll"
|
|
|
|
)
|
2015-10-09 14:26:24 +00:00
|
|
|
set(KERBEROS_DLLS ${_kerberos_dlls}
|
2015-01-12 22:44:42 +00:00
|
|
|
# We're storing filenames only. Should we use STRING instead?
|
|
|
|
CACHE FILEPATH "Kerberos DLL list"
|
|
|
|
)
|
2015-10-09 14:26:24 +00:00
|
|
|
mark_as_advanced(KERBEROS_DLL_DIR KERBEROS_DLLS)
|
|
|
|
else()
|
|
|
|
set(KERBEROS_DLL_DIR)
|
|
|
|
set(KERBEROS_DLLS)
|
2015-01-12 22:44:42 +00:00
|
|
|
endif()
|
2015-10-09 14:26:24 +00:00
|
|
|
endif()
|
2009-09-10 07:04:54 +00:00
|
|
|
|
Fix up handling of the Kerberos package.
On Ubuntu 16.04, and possibly other versions of Ubuntu, and on Debian
and other Debian derivatives, packages for MIT and Heimdal Kerberos can
both be installed at the same time - including developer packages.
Collisions between headers and libraries are handled by putting them in
subdirectories of the system include and library directory and having
their .pc files add -isystem flags to point to the appropriate include
directory and -L flags to point to the appropriate library directory.
CMake's pkg-config support, however, only looks for -I flags, not
-isystem flags, in pkg-config output (using --cflags-only-I), so it
doesn't get the directory in which to look for the headers, and just
uses the results of --libs-only-l to get a list of library names and
does nothing with the results of --libs-only-L, causing it not to look
for libraries in the directory in which to look for the libraries.
We fix this by:
If FindKERBEROS.cmake found Kerberos with pkg-config, have it set
KERBEROS_DEFINITIONS to the "other" compiler flags, which includes the
-isystem flag.
For all packages, adding the <PACKAGE>_DEFINITIONS values to
CMAKE_C_FLAGS and CMAKE_CXX_FLAGS so that they're used when compiling.
If FindKERBEROS.cmake found Kerberos with pkg-config, having it search
for each of the libraries in KERBEROS_LIBRARIES using find_library()
with KERBEROS_LIBDIR and KERBEROS_LIBRARY_DIRS as hints, and
re-assembling the resulting full paths into KERBEROS_LIBRARIES.
Change-Id: Ie18b56b76934f542bd12dc737631c0190026d18a
Reviewed-on: https://code.wireshark.org/review/27071
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-04-22 02:38:08 +00:00
|
|
|
mark_as_advanced(KERBEROS_LIBRARIES KERBEROS_INCLUDE_DIRS KERBEROS_DEFINITIONS)
|