aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-04-21 19:38:08 -0700
committerGuy Harris <guy@alum.mit.edu>2018-04-22 03:04:19 +0000
commit6eecb310305264a99e2a13aa49cb7f7fb6cab296 (patch)
treefef1453cfb768b13bd48b2be4ae9bd47096b0797 /cmake
parent7853d0e354a92e4c4a25bc0031151c7179597b06 (diff)
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>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindKERBEROS.cmake50
1 files changed, 39 insertions, 11 deletions
diff --git a/cmake/modules/FindKERBEROS.cmake b/cmake/modules/FindKERBEROS.cmake
index 3e4444f99b..65bd3a9904 100644
--- a/cmake/modules/FindKERBEROS.cmake
+++ b/cmake/modules/FindKERBEROS.cmake
@@ -1,14 +1,16 @@
#
-# - Find kerberos
-# Find the native KERBEROS includes and library
+# - Find Kerberos
+# Find the native Kerberos includes and library
#
-# KERBEROS_INCLUDE_DIRS - where to find krb5.h, etc.
-# KERBEROS_LIBRARIES - List of libraries when using 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
+# 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
if(KERBEROS_INCLUDE_DIRS)
@@ -24,7 +26,33 @@ if(NOT WIN32)
pkg_search_module(KERBEROS krb5 mit-krb5 heimdal-krb5)
endif()
-if(NOT KERBEROS_FOUND)
+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()
# 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.
@@ -87,4 +115,4 @@ if(WIN32)
endif()
endif()
-mark_as_advanced(KERBEROS_LIBRARIES KERBEROS_INCLUDE_DIRS)
+mark_as_advanced(KERBEROS_LIBRARIES KERBEROS_INCLUDE_DIRS KERBEROS_DEFINITIONS)