[evolution-data-server/wip/cmake] Fix/enhance FindKRB5.cmake
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/wip/cmake] Fix/enhance FindKRB5.cmake
- Date: Mon, 19 Sep 2016 07:42:36 +0000 (UTC)
commit 654f86760214108b5b89672475ac2a3f4bbc539b
Author: Milan Crha <mcrha redhat com>
Date: Mon Sep 19 09:42:16 2016 +0200
Fix/enhance FindKRB5.cmake
CMakeLists.txt | 2 +-
cmake/modules/FindKRB5.cmake | 26 ++++++++++++++++++++++----
cmake/modules/PrintableOptions.cmake | 26 +++++++++++++-------------
3 files changed, 36 insertions(+), 18 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 06cfc82..4fcb172 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -119,7 +119,7 @@ include(CheckIncludeFile)
include(PrintableOptions)
add_printable_variable(LIB_SUFFIX "Library directory suffix, usually defined to '64' for x86_64 systems" "")
-add_printable_variable_custom(CMAKE_INSTALL_PREFIX)
+add_printable_variable_bare(CMAKE_INSTALL_PREFIX)
add_printable_variable_path(INCLUDE_INSTALL_DIR "Install directory for header files, defaults to
CMAKE_INSTALL_PREFIX/include" ${CMAKE_INSTALL_PREFIX}/include)
add_printable_variable_path(LIB_INSTALL_DIR "Install directory for library files, defaults to
CMAKE_INSTALL_PREFIX/lib{LIB_SUFFIX}" ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
add_printable_variable_path(LIBEXEC_INSTALL_DIR "Install directory for library executable files, defaults to
CMAKE_INSTALL_PREFIX/libexec" ${CMAKE_INSTALL_PREFIX}/libexec)
diff --git a/cmake/modules/FindKRB5.cmake b/cmake/modules/FindKRB5.cmake
index 4f1072a..a586eb5 100644
--- a/cmake/modules/FindKRB5.cmake
+++ b/cmake/modules/FindKRB5.cmake
@@ -13,7 +13,7 @@ include(CheckCSourceCompiles)
include(PkgConfigEx)
include(PrintableOptions)
-add_printable_variable(WITH_KRB5 "Location of Kerberos 5 install dir, defaults to ON to search for it" "ON")
+add_printable_variable_path(WITH_KRB5 "Location of Kerberos 5 install dir, defaults to ON to search for it"
"ON")
add_printable_variable_path(WITH_KRB5_INCLUDES "Location of Kerberos 5 headers" "")
add_printable_variable_path(WITH_KRB5_LIBS "Location of Kerberos 5 libraries" "")
@@ -21,20 +21,32 @@ if(NOT WITH_KRB5)
return()
endif(NOT WITH_KRB5)
-#pkg_check_modules(KRB5 krb5 krb5-gssapi)
+pkg_check_modules(KRB5 krb5 krb5-gssapi)
if(KRB5_FOUND)
pkg_check_variable(KRB5_VENDOR krb5 vendor)
if(KRB5_VENDOR STREQUAL "MIT")
+ message(STATUS "Using MIT Kerberos 5 (found by pkg-config)")
+ set(WITH_KRB5 ON)
set(HAVE_MIT_KRB5 ON)
return()
endif(KRB5_VENDOR STREQUAL "MIT")
+
+ message(STATUS "Found Kerberos 5 with pkg-config, but unknown vendor '${KRB5_VENDOR}', continue with
autodetection")
endif()
-if("${WITH_KRB5}" STREQUAL "ON")
+string(LENGTH "${CMAKE_BINARY_DIR}" bindirlen)
+string(SUBSTRING "${WITH_KRB5}" 0 ${bindirlen} substr)
+string(TOUPPER "${WITH_KRB5}" optupper)
+
+if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
set(WITH_KRB5 "/usr")
-endif("${WITH_KRB5}" STREQUAL "ON")
+endif(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+
+unset(bindirlen)
+unset(substr)
+unset(optupper)
set(mit_includes "${WITH_KRB5}/include")
set(mit_libs "-lkrb5 -lk5crypto -lcom_err -lgssapi_krb5")
@@ -62,6 +74,7 @@ CHECK_C_SOURCE_COMPILES("#include <krb5/krb5.h>
if(HAVE_KRB5)
set(HAVE_MIT_KRB5 ON)
+ message(STATUS "Found MIT Kerberos 5")
else(HAVE_KRB5)
set(CMAKE_REQUIRED_INCLUDES "-I${heimdal_includes}")
set(CMAKE_REQUIRED_LIBRARIES "-L${krb_libs} ${heimdal_libs}")
@@ -70,6 +83,7 @@ else(HAVE_KRB5)
if(HAVE_KRB5)
set(HAVE_HEIMDAL_KRB5 ON)
+ message(STATUS "Found Heimdal Kerberos 5")
endif(HAVE_KRB5)
endif(HAVE_KRB5)
@@ -78,6 +92,10 @@ if(NOT HAVE_KRB5)
set(CMAKE_REQUIRED_LIBRARIES "-L${krb_libs} ${sun_libs}")
CHECK_C_SOURCE_COMPILES("#include <krb5/krb5.h>
int main(void) { krb5_init_context (NULL); return 0; }" HAVE_KRB5)
+ if(HAVE_KRB5)
+ set(HAVE_SUN_KRB5 ON)
+ message(STATUS "Found Sun Kerberos 5")
+ endif(HAVE_KRB5)
endif(NOT HAVE_KRB5)
if(HAVE_KRB5)
diff --git a/cmake/modules/PrintableOptions.cmake b/cmake/modules/PrintableOptions.cmake
index 72a1eb8..23ce356 100644
--- a/cmake/modules/PrintableOptions.cmake
+++ b/cmake/modules/PrintableOptions.cmake
@@ -3,6 +3,9 @@
# Provides functions to manage printable otpions,
# which can be printed at the end of the configuration
#
+# add_printable_variable_bare(_name)
+# adds variable named _name to the list of prinable options
+#
# add_printable_option(_name _description _default_value)
# the same as option() commnd, only also notes this option for later printing
#
@@ -12,18 +15,22 @@
# add_printable_variable_path(_name _description _default_value)
# sets a new cached PATH variable and adds it to the list of printable options
#
-# add_printable_variable_custom(_name)
-# adds variable named _name to the list of prinable options
-#
# print_build_options()
# prints all the build options previously added with the above functions
+macro(add_printable_variable_bare _name)
+ if(_name STREQUAL "")
+ message(FATAL_ERROR "variable name cannot be empty")
+ endif(_name STREQUAL "")
+ list(APPEND _printable_options ${_name})
+endmacro()
+
macro(add_printable_option _name _description _default_value)
if(_name STREQUAL "")
message(FATAL_ERROR "option name cannot be empty")
endif(_name STREQUAL "")
option(${_name} ${_description} ${_default_value})
- list(APPEND _printable_options ${_name})
+ add_printable_variable_bare(${_name})
endmacro()
macro(add_printable_variable _name _description _default_value)
@@ -31,7 +38,7 @@ macro(add_printable_variable _name _description _default_value)
message(FATAL_ERROR "variable name cannot be empty")
endif(_name STREQUAL "")
set(${_name} ${_default_value} CACHE STRING ${_description})
- list(APPEND _printable_options ${_name})
+ add_printable_variable_bare(${_name})
endmacro()
macro(add_printable_variable_path _name _description _default_value)
@@ -39,14 +46,7 @@ macro(add_printable_variable_path _name _description _default_value)
message(FATAL_ERROR "path variable name cannot be empty")
endif(_name STREQUAL "")
set(${_name} ${_default_value} CACHE PATH ${_description})
- list(APPEND _printable_options ${_name})
-endmacro()
-
-macro(add_printable_variable_custom _name)
- if(_name STREQUAL "")
- message(FATAL_ERROR "variable name cannot be empty")
- endif(_name STREQUAL "")
- list(APPEND _printable_options ${_name})
+ add_printable_variable_bare(${_name})
endmacro()
function(print_build_options)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]