[evolution-data-server/wip/cmake] FindLDAP.cmake and some other tweaks on build flags
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/wip/cmake] FindLDAP.cmake and some other tweaks on build flags
- Date: Tue, 20 Sep 2016 15:07:30 +0000 (UTC)
commit d5a99be6a047022fcf8471aa6b6d1c7f1c649473
Author: Milan Crha <mcrha redhat com>
Date: Tue Sep 20 17:07:15 2016 +0200
FindLDAP.cmake and some other tweaks on build flags
CMakeLists.txt | 7 +--
cmake/modules/FindLDAP.cmake | 129 +++++++++++++++++++++++++++++++++++
cmake/modules/SetupBuildFlags.cmake | 17 +++--
config.h.in | 13 ++--
4 files changed, 146 insertions(+), 20 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8b1ac4f..e28dd48 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -133,6 +133,7 @@ include(SetupBuildFlags)
include(UninstallTarget)
include(FindKRB5)
+include(FindLDAP)
include(FindPhonenumber)
include(FindSMIME)
@@ -141,12 +142,6 @@ add_printable_option(ENABLE_MAINTAINER_MODE "Enable maintainer mode" OFF)
# Setup compiler/linker flags
setup_build_flags(${ENABLE_MAINTAINER_MODE})
-check_c_compiler_flag(-fno-strict-aliasing _flag_supported)
-if(_flag_supported)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing")
-endif(_flag_supported)
-unset(_flag_supported)
-
CHECK_INCLUDE_FILE(sys/wait.h HAVE_SYS_WAIT_H)
CHECK_INCLUDE_FILE(wspiapi.h HAVE_WSPIAPI_H)
CHECK_FUNCTION_EXISTS(fsync HAVE_FSYNC)
diff --git a/cmake/modules/FindLDAP.cmake b/cmake/modules/FindLDAP.cmake
new file mode 100644
index 0000000..450de68
--- /dev/null
+++ b/cmake/modules/FindLDAP.cmake
@@ -0,0 +1,129 @@
+# FindLDAP.cmake
+#
+# Searches for OpenLDAP/SunLDAP library
+#
+# Adds these options:
+# -DWITH_OPENLDAP=ON/OFF/PATH - enable/disable OpenLDAP, eventually set prefix to find it
+# -DWITH_SUNLDAP=OFF/ON/PATH - enable/disable SunLDAP, eventually set prefix to find it
+# -DWITH_STATIC_LDAP=OFF/ON - enable/disable static LDAP linking
+#
+# The OpenLDAP has precedence over SunLDAP, if both are specified. The default is to use OpenLDAP.
+#
+# The output is:
+# HAVE_LDAP - set to ON, if LDAP support is enabled and libraries found
+# SUNLDAP - set to ON, when using SunLDAP implementation
+# LDAP_CFLAGS - CFLAGS to use with target_compile_options() and similar commands
+# LDAP_LDFLAGS - LDFLAGS to use with target_link_libraries() and similar commands
+
+include(CheckCSourceCompiles)
+include(CheckLibraryExists)
+include(PrintableOptions)
+
+add_printable_variable_path(WITH_OPENLDAP "Enable LDAP support using OpenLDAP, default ON" "ON")
+add_printable_variable_path(WITH_SUNLDAP "Enable LDAP support using SunLDAP, default OFF" "OFF")
+add_printable_option(WITH_STATIC_LDAP "Link LDAP statically, default OFF" OFF)
+
+if((NOT WITH_OPENLDAP) AND (NOT WITH_SUNLDAP))
+ return()
+endif((NOT WITH_OPENLDAP) AND (NOT WITH_SUNLDAP))
+
+string(LENGTH "${CMAKE_BINARY_DIR}" bindirlen)
+string(SUBSTRING "${WITH_OPENLDAP}" 0 ${bindirlen} substr)
+string(TOUPPER "${WITH_OPENLDAP}" optupper)
+
+if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+ set(WITH_OPENLDAP "/usr")
+endif(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+
+string(SUBSTRING "${WITH_SUNLDAP}" 0 ${bindirlen} substr)
+string(TOUPPER "${WITH_SUNLDAP}" optupper)
+
+if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+ set(WITH_SUNLDAP "/usr")
+endif(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+
+unset(bindirlen)
+unset(substr)
+unset(optupper)
+
+set(HAVE_LDAP ON)
+set(SUNLDAP OFF)
+
+macro(add_ldap_lib_if_provides _lib _symbol)
+ CHECK_LIBRARY_EXISTS(${_lib} ${_symbol} "" lib${_lib}_provides_${_symbol})
+ if(lib${_lib}_provides_${_symbol})
+ set(LDAP_LIBS "${LDAP_LIBS} -l${_lib}")
+ endif(lib${_lib}_provides_${_symbol})
+endmacro(add_ldap_lib_if_provides)
+
+set(LDAP_PREFIX "")
+if(WITH_OPENLDAP)
+ set(LDAP_PREFIX "${WITH_OPENLDAP}")
+else(WITH_OPENLDAP)
+ set(LDAP_PREFIX "${WITH_SUNLDAP}")
+ set(SUNLDAP ON)
+endif(WITH_OPENLDAP)
+
+set(LDAP_CFLAGS "-I${LDAP_PREFIX}/include")
+set(LDAP_LIBS "-L${LDAP_PREFIX}/lib${LIB_SUFFIX}")
+
+set(CMAKE_REQUIRED_INCLUDES "-I${LDAP_CFLAGS}")
+set(CMAKE_REQUIRED_LIBRARIES "-L${LDAP_LIBS}")
+
+if(WITH_OPENLDAP)
+ CHECK_C_SOURCE_COMPILES("#include \"ldap.h\"
+ int main(void) {
+ #if !defined(LDAP_VENDOR_VERSION) || LDAP_VENDOR_VERSION < 20000
+ #error OpenLDAP version not at least 2.0
+ #endif
+ return 0; }" openldap_2_x)
+ if(NOT openldap_2_x)
+ message(FATAL_ERROR "At least 2.0 OpenLDAP version required")
+ endif(NOT openldap_2_x)
+else(WITH_OPENLDAP)
+ CHECK_C_SOURCE_COMPILES("#include \"ldap.h\"
+ int main(void) {
+ #if !defined(LDAP_VENDOR_VERSION) || LDAP_VENDOR_VERSION < 500
+ #error SunLDAP version not at least 2.0
+ #endif
+ return 0; }" sunldap_2_x)
+ if(NOT sunldap_2_x)
+ message(FATAL_ERROR "At least 2.0 SunLDAP version required")
+ endif(NOT sunldap_2_x)
+endif(WITH_OPENLDAP)
+
+add_ldap_lib_if_provides(resolv res_query)
+add_ldap_lib_if_provides(resolv __res_query)
+add_ldap_lib_if_provides(socket bind)
+CHECK_LIBRARY_EXISTS(lber ber_get_tag "" liblber_provides_ber_get_tag)
+if(liblber_provides_ber_get_tag)
+ if(WITH_STATIC_LDAP)
+ set(LDAP_LIBS "${LDAP_LIBS} ${LDAP_PREFIX}/lib${LIB_SUFFIX}/liblber.a")
+# # libldap might depend on OpenSSL... We need to pull
+# # in the dependency libs explicitly here since we're
+# # not using libtool for the configure test.
+# if test -f ${LDAP_PREFIX}/lib${LIB_SUFFIX}/libldap.la; then
+# LDAP_LIBS="`. ${LDAP_PREFIX}/libPLIB_SUFFIX}/libldap.la; echo $dependency_libs`
$LDAP_LIBS"
+# fi
+ else(WITH_STATIC_LDAP)
+ set(LDAP_LIBS "${LDAP_LIBS} -llber")
+ endif(WITH_STATIC_LDAP)
+endif(liblber_provides_ber_get_tag)
+
+CHECK_LIBRARY_EXISTS(ldap ldap_open "" libldap_provides_ldap_open)
+if(libldap_provides_ldap_open)
+ if(WITH_STATIC_LDAP)
+ set(LDAP_LIBS "${LDAP_LIBS} ${LDAP_PREFIX}/lib${LIB_SUFFIX}/libldap.a")
+ else(WITH_STATIC_LDAP)
+ set(LDAP_LIBS "${LDAP_LIBS} -lldap")
+ endif(WITH_STATIC_LDAP)
+else(libldap_provides_ldap_open)
+ if(WITH_OPENLDAP)
+ message(FATAL_ERROR "Could not find OpenLDAP libraries")
+ else(WITH_OPENLDAP)
+ message(FATAL_ERROR "Could not find SunLDAP libraries")
+ endif(WITH_OPENLDAP)
+endif(libldap_provides_ldap_open)
+
+unset(CMAKE_REQUIRED_INCLUDES)
+unset(CMAKE_REQUIRED_LIBRARIES)
diff --git a/cmake/modules/SetupBuildFlags.cmake b/cmake/modules/SetupBuildFlags.cmake
index ac88ff5..bff58ce 100644
--- a/cmake/modules/SetupBuildFlags.cmake
+++ b/cmake/modules/SetupBuildFlags.cmake
@@ -19,6 +19,7 @@ function(setup_build_flags _maintainer_mode)
-Wundef
-Wwrite-strings
-no-undefined
+ -fno-strict-aliasing
)
if(_maintainer_mode)
@@ -54,19 +55,19 @@ function(setup_build_flags _maintainer_mode)
)
foreach(flag IN LISTS proposed_c_flags)
- check_c_compiler_flag(${flag} _flag_supported)
- if(_flag_supported)
+ check_c_compiler_flag(${flag} c_flag_${flag}_supported)
+ if(c_flag_${flag}_supported)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
- endif(_flag_supported)
- unset(_flag_supported)
+ endif(c_flag_${flag}_supported)
+ unset(c_flag_${flag}_supported)
endforeach()
foreach(flag IN LISTS proposed_cxx_flags)
- check_cxx_compiler_flag(${flag} _flag_supported)
- if(_flag_supported)
+ check_cxx_compiler_flag(${flag} cxx_flag_${flag}_supported)
+ if(cxx_flag_${flag}_supported)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
- endif(_flag_supported)
- unset(_flag_supported)
+ endif(cxx_flag_${flag}_supported)
+ unset(cxx_flag_${flag}_supported)
endforeach()
if(("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "gcc"))
diff --git a/config.h.in b/config.h.in
index 8b6eee1..24b8c4e 100644
--- a/config.h.in
+++ b/config.h.in
@@ -147,6 +147,13 @@
/* Whether Parse() or ParseAndKeepRawInput() must be used to get the country-code source */
#cmakedefine PHONENUMBER_RAW_INPUT_NEEDED 1
+/* Define if you have LDAP support */
+#cmakedefine HAVE_LDAP 1
+
+/* Define if you use SunLDAP */
+#cmakedefine SUNLDAP */
+
+
/* *************************************************** */
@@ -202,9 +209,6 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
-/* Define if you have LDAP support */
-#define HAVE_LDAP 1
-
/* Define if compiled with libical 2.0 */
#define HAVE_LIBICAL_2_0 1
@@ -309,9 +313,6 @@
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
-/* Define if you use SunLDAP */
-/* #undef SUNLDAP */
-
/* Version number of package */
#define VERSION "3.22.0"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]