1 include(CheckIncludeFile)
2 include(CheckSymbolExists)
3 include(CheckFunctionExists)
4 include(CheckLibraryExists)
6 include(CheckStructHasMember)
7 include(CheckPrototypeDefinition)
10 set(PACKAGE ${APPLICATION_NAME})
11 set(VERSION ${APPLICATION_VERSION})
12 set(DATADIR ${DATA_INSTALL_DIR})
13 set(LIBDIR ${LIB_INSTALL_DIR})
14 set(PLUGINDIR "${PLUGIN_INSTALL_DIR}-${LIBRARY_SOVERSION}")
15 set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
17 set(BINARYDIR ${CMAKE_BINARY_DIR})
18 set(SOURCEDIR ${CMAKE_SOURCE_DIR})
20 function(COMPILER_DUMPVERSION _OUTPUT_VERSION)
21 # Remove whitespaces from the argument.
22 # This is needed for CC="ccache gcc" cmake ..
23 string(REPLACE " " "" _C_COMPILER_ARG "${CMAKE_C_COMPILER_ARG1}")
27 ${CMAKE_C_COMPILER} ${_C_COMPILER_ARG} -dumpversion
28 OUTPUT_VARIABLE _COMPILER_VERSION
31 string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
32 _COMPILER_VERSION "${_COMPILER_VERSION}")
34 set(${_OUTPUT_VERSION} ${_COMPILER_VERSION} PARENT_SCOPE)
38 check_include_file(sys/types.h HAVE_SYS_TYPES_H)
39 check_include_file(unistd.h HAVE_UNISTD_H)
40 check_include_file(security/pam_appl.h HAVE_SECURITY_PAM_APPL_H)
41 check_include_file(security/pam_modules.h HAVE_SECURITY_PAM_MODULES_H)
42 check_include_file(security/pam_ext.h HAVE_SECURITY_PAM_EXT_H)
45 check_function_exists(strncpy HAVE_STRNCPY)
46 check_function_exists(vsnprintf HAVE_VSNPRINTF)
47 check_function_exists(snprintf HAVE_SNPRINTF)
49 check_prototype_definition(pam_vprompt
50 "int pam_vprompt(const pam_handle_t *_pamh, int _style, char **_resp, const char *_fmt, va_list _ap)"
52 "stdio.h;sys/types.h;security/pam_appl.h;security/pam_modules.h"
53 HAVE_PAM_VPROMPT_CONST)
55 check_prototype_definition(pam_prompt
56 "int pam_prompt(const pam_handle_t *_pamh, int _style, char **_resp, const char *_fmt, ...)"
58 "stdio.h;sys/types.h;security/pam_appl.h;security/pam_modules.h"
59 HAVE_PAM_PROMPT_CONST)
61 check_prototype_definition(pam_strerror
62 "const char *pam_strerror(const pam_handle_t *_pamh, int _error_number)"
64 "stdio.h;sys/types.h;security/pam_appl.h;security/pam_modules.h"
65 HAVE_PAM_STRERROR_CONST)
68 find_library(PAM_LIBRARY NAMES libpam.so.0 pam)
69 set(PAM_LIBRARY ${PAM_LIBRARY})
70 find_library(PAM_MISC_LIBRARY NAMES pam_misc)
72 set(HAVE_PAM_MISC TRUE)
75 check_library_exists(${PAM_LIBRARY} openpam_set_option "" HAVE_OPENPAM)
78 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${PAM_LIBRARY})
79 check_function_exists(pam_syslog HAVE_PAM_SYSLOG)
80 check_function_exists(pam_vsyslog HAVE_PAM_VSYSLOG)
85 if (HAVE_SYS_SYSCALL_H)
86 list(APPEND CMAKE_REQUIRED_DEFINITIONS "-DHAVE_SYS_SYSCALL_H")
87 endif (HAVE_SYS_SYSCALL_H)
89 list(APPEND CMAKE_REQUIRED_DEFINITIONS "-DHAVE_SYSCALL_H")
90 endif (HAVE_SYSCALL_H)
92 set(CMAKE_REQUIRED_DEFINITIONS)
100 check_c_source_compiles("
105 __atomic_load(p_x, &x, __ATOMIC_RELAXED);
107 }" HAVE_GCC_ATOMIC_BUILTINS)
109 check_c_source_compiles("
114 }" HAVE_GCC_THREAD_LOCAL_STORAGE)
116 check_c_source_compiles("
117 void test_constructor_attribute(void) __attribute__ ((constructor));
119 void test_constructor_attribute(void)
126 }" HAVE_CONSTRUCTOR_ATTRIBUTE)
128 check_c_source_compiles("
129 void test_destructor_attribute(void) __attribute__ ((destructor));
131 void test_destructor_attribute(void)
138 }" HAVE_DESTRUCTOR_ATTRIBUTE)
140 check_c_source_compiles("
141 void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
145 }" HAVE_FUNCTION_ATTRIBUTE_FORMAT)
149 check_library_exists(dl dlopen "" HAVE_LIBDL)
151 find_library(DLFCN_LIBRARY dl)
152 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${DLFCN_LIBRARY})
161 test_big_endian(WORDS_BIGENDIAN)
164 set(UIDWRAP_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL "uidwrap required system libraries")