| 1 |
#CMake configuration for freeDiameter include directory |
| 2 |
|
| 3 |
Project("freeDiameter includes directory" C) |
| 4 |
|
| 5 |
######################## |
| 6 |
# Configurable parameters |
| 7 |
|
| 8 |
# Disable SCTP support completely ? |
| 9 |
OPTION(DISABLE_SCTP "Disable SCTP support?" OFF) |
| 10 |
IF (NOT DISABLE_SCTP) |
| 11 |
OPTION(DEBUG_SCTP "Verbose SCTP (for debug)?" OFF) |
| 12 |
OPTION(SCTP_USE_MAPPED_ADDRESSES "Use v6-mapped v4 addresses in SCTP (workaround some SCTP limitations)?" OFF) |
| 13 |
ENDIF (NOT DISABLE_SCTP) |
| 14 |
|
| 15 |
# Find TODO items in the code easily ? |
| 16 |
OPTION(ERRORS_ON_TODO "(development) Generate compilation errors on TODO items ?" OFF) |
| 17 |
|
| 18 |
# In DEBUG mode, each log can contain pid, calling function and file for easy debug. Set to ON to display this information. |
| 19 |
OPTION(DEBUG_WITH_META "Show calling location in logs?" OFF) |
| 20 |
|
| 21 |
# Create the absolute path for searching extensions |
| 22 |
SET(DEFAULT_EXTENSIONS_PATH ${CMAKE_INSTALL_PREFIX}/${INSTALL_EXTENSIONS_SUFFIX}) |
| 23 |
|
| 24 |
# IDNA considerations |
| 25 |
OPTION(DIAMID_IDNA_IGNORE "Ignore completely invalid characters in Diameter Identities (process blindly)?" OFF) |
| 26 |
IF (NOT DIAMID_IDNA_IGNORE) |
| 27 |
OPTION (DIAMID_IDNA_REJECT "Reject internationalized Diameter Identities, do not attempt to convert it (stringprep) ?" OFF) |
| 28 |
ENDIF (NOT DIAMID_IDNA_IGNORE) |
| 29 |
|
| 30 |
# Disable expiration of connections with dynamically connected peers as per RFC 3539 ? (default is enabled) |
| 31 |
# Note: if someone needs, we could also make the delay configurable here... |
| 32 |
OPTION(DISABLE_PEER_EXPIRY "Disable RFC3539 Peers Connections Expiration after inactivity?" OFF) |
| 33 |
|
| 34 |
# The following workaround increases compatibility with some implementations without breaking anything in freeDiameter, |
| 35 |
# so it can be enabled without risk. We keep it disabled by default anyway for those people who use freeDiameter to check the |
| 36 |
# compliancy of their implementation with the Diameter RFC... |
| 37 |
OPTION(WORKAROUND_ACCEPT_INVALID_VSAI "Do not reject a CER/CEA with a Vendor-Specific-Application-Id AVP containing both Auth- and Acct- application AVPs?" OFF) |
| 38 |
|
| 39 |
MARK_AS_ADVANCED(DISABLE_SCTP DEBUG_SCTP SCTP_USE_MAPPED_ADDRESSES ERRORS_ON_TODO DEBUG_WITH_META DIAMID_IDNA_IGNORE DIAMID_IDNA_REJECT DISABLE_PEER_EXPIRY WORKAROUND_ACCEPT_INVALID_VSAI) |
| 40 |
|
| 41 |
######################## |
| 42 |
### System checks part |
| 43 |
|
| 44 |
INCLUDE (CheckLibraryExists) |
| 45 |
INCLUDE (CheckFunctionExists) |
| 46 |
INCLUDE (CheckIncludeFiles) |
| 47 |
INCLUDE (CheckSymbolExists) |
| 48 |
INCLUDE (CheckCSourceCompiles) |
| 49 |
INCLUDE (TestBigEndian) |
| 50 |
|
| 51 |
|
| 52 |
### System checks -- mandatory support |
| 53 |
|
| 54 |
# We need the getopt_long function |
| 55 |
CHECK_FUNCTION_EXISTS (getopt_long HAVE_LONG_OPTIONS) |
| 56 |
IF (NOT HAVE_LONG_OPTIONS) |
| 57 |
MESSAGE(SEND_ERROR "The getopt_long function is not found, please add needed library in build system") |
| 58 |
ENDIF (NOT HAVE_LONG_OPTIONS) |
| 59 |
|
| 60 |
# getifaddrs ? |
| 61 |
CHECK_FUNCTION_EXISTS (getifaddrs HAVE_GETIFADDRS) |
| 62 |
IF (NOT HAVE_GETIFADDRS) |
| 63 |
MESSAGE(SEND_ERROR "The getifaddrs function is currently required by freeDiameter.") |
| 64 |
ENDIF (NOT HAVE_GETIFADDRS) |
| 65 |
|
| 66 |
|
| 67 |
### System checks -- for freeDiameter-host.h |
| 68 |
|
| 69 |
# Check byte ordering |
| 70 |
TEST_BIG_ENDIAN(HOST_BIG_ENDIAN) |
| 71 |
|
| 72 |
# Check if ntohll is provided on the system |
| 73 |
CHECK_SYMBOL_EXISTS(ntohll netinet/in.h HAVE_NTOHLL) |
| 74 |
|
| 75 |
# malloc.h ? |
| 76 |
CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H) |
| 77 |
|
| 78 |
# strndup ? Missing on OS X |
| 79 |
CHECK_FUNCTION_EXISTS (strndup HAVE_STRNDUP) |
| 80 |
|
| 81 |
|
| 82 |
### System checks -- for includes / link |
| 83 |
|
| 84 |
# pthreads |
| 85 |
INCLUDE(FindThreads) |
| 86 |
SET(CMAKE_THREAD_LIBS_INIT ${CMAKE_THREAD_LIBS_INIT} PARENT_SCOPE) |
| 87 |
|
| 88 |
# clock_gettime |
| 89 |
SET(HAVE_CLOCK_GETTIME "") |
| 90 |
CHECK_FUNCTION_EXISTS (clock_gettime HAVE_NATIVE_CLOCK_GETTIME) |
| 91 |
IF (HAVE_NATIVE_CLOCK_GETTIME) |
| 92 |
SET(CLOCK_GETTIME_LIBS "") |
| 93 |
SET(HAVE_CLOCK_GETTIME 1) |
| 94 |
ELSE (HAVE_NATIVE_CLOCK_GETTIME) |
| 95 |
CHECK_LIBRARY_EXISTS (rt clock_gettime "" HAVE_LIBRT) |
| 96 |
IF (HAVE_LIBRT) |
| 97 |
SET(CLOCK_GETTIME_LIBS "-lrt") |
| 98 |
SET(HAVE_CLOCK_GETTIME 1) |
| 99 |
ELSE (HAVE_LIBRT) |
| 100 |
CHECK_LIBRARY_EXISTS (posix4 clock_gettime "" HAVE_LIBPOSIX4) |
| 101 |
IF (HAVE_LIBPOSIX4) |
| 102 |
SET(CLOCK_GETTIME_LIBS "-lposix4") |
| 103 |
SET(HAVE_CLOCK_GETTIME 1) |
| 104 |
ENDIF (HAVE_LIBPOSIX4) |
| 105 |
ENDIF (HAVE_LIBRT) |
| 106 |
ENDIF (HAVE_NATIVE_CLOCK_GETTIME) |
| 107 |
SET(CLOCK_GETTIME_LIBS ${CLOCK_GETTIME_LIBS} PARENT_SCOPE) |
| 108 |
|
| 109 |
# dlopen and dlclose: CMAKE_DL_LIBS |
| 110 |
|
| 111 |
# We need the sctp_connectx function among others |
| 112 |
# We need the IPPROTO_SCTP symbol from sys/socket.h, netinet/in.h or netinet/sctp.h |
| 113 |
IF(NOT DISABLE_SCTP) |
| 114 |
CHECK_FUNCTION_EXISTS(sctp_connectx HAVE_NATIVE_SCTP) |
| 115 |
IF(NOT HAVE_NATIVE_SCTP) |
| 116 |
FIND_PACKAGE(SCTP REQUIRED) |
| 117 |
ENDIF(NOT HAVE_NATIVE_SCTP) |
| 118 |
# Now check the number of args of this function, since it changed between Ubuntu 9.04 and 9.10 |
| 119 |
SET(CHECK_SCTP_CONNECTX_4_ARGS_SOURCE_CODE " |
| 120 |
#include <unistd.h> |
| 121 |
#include <netinet/sctp.h> |
| 122 |
int main() { |
| 123 |
return sctp_connectx(0, NULL, 0, NULL); |
| 124 |
} |
| 125 |
") |
| 126 |
SET(CMAKE_REQUIRED_INCLUDES ${SCTP_INCLUDE_DIR}) |
| 127 |
SET(CMAKE_REQUIRED_LIBRARIES ${SCTP_LIBRARIES}) |
| 128 |
CHECK_C_SOURCE_COMPILES("${CHECK_SCTP_CONNECTX_4_ARGS_SOURCE_CODE}" SCTP_CONNECTX_4_ARGS) |
| 129 |
ELSE (NOT DISABLE_SCTP) |
| 130 |
MESSAGE(STATUS "Disabled SCTP support.") |
| 131 |
ENDIF(NOT DISABLE_SCTP) |
| 132 |
SET(SCTP_INCLUDE_DIR ${SCTP_INCLUDE_DIR} PARENT_SCOPE) |
| 133 |
SET(SCTP_LIBRARIES ${SCTP_LIBRARIES} PARENT_SCOPE) |
| 134 |
|
| 135 |
# IDNA process: we use libidn from GNU (unless the function & header files are included in libc) |
| 136 |
IF(NOT DIAMID_IDNA_IGNORE AND NOT DIAMID_IDNA_REJECT) |
| 137 |
FIND_PACKAGE(IDNA) |
| 138 |
SET(CHECK_IDNA_SOURCE_CODE " |
| 139 |
#include <idna.h> |
| 140 |
int main() { |
| 141 |
return idna_to_ascii_8z(NULL, NULL, 0); |
| 142 |
} |
| 143 |
") |
| 144 |
SET(CMAKE_REQUIRED_INCLUDES ${IDNA_INCLUDE_DIR}) |
| 145 |
SET(CMAKE_REQUIRED_LIBRARIES ${IDNA_LIBRARIES}) |
| 146 |
CHECK_C_SOURCE_COMPILES("${CHECK_IDNA_SOURCE_CODE}" HAS_IDNA_SUPPORT) |
| 147 |
IF(NOT HAS_IDNA_SUPPORT) |
| 148 |
MESSAGE(SEND_ERROR "Unable to find idna.h header or idna_to_ascii_8z function, please install libidn-dev or equivalent, or set DIAMID_IDNA_IGNORE or DIAMID_IDNA_REJECT") |
| 149 |
ENDIF(NOT HAS_IDNA_SUPPORT) |
| 150 |
ELSE (NOT DIAMID_IDNA_IGNORE AND NOT DIAMID_IDNA_REJECT) |
| 151 |
MESSAGE(STATUS "Non-default Internationalized Domain Names (IDN) behavior selected (no stringprep).") |
| 152 |
ENDIF(NOT DIAMID_IDNA_IGNORE AND NOT DIAMID_IDNA_REJECT) |
| 153 |
SET(IDNA_INCLUDE_DIR ${IDNA_INCLUDE_DIR} PARENT_SCOPE) |
| 154 |
SET(IDNA_LIBRARIES ${IDNA_LIBRARIES} PARENT_SCOPE) |
| 155 |
|
| 156 |
|
| 157 |
# Require GNU TLS for building the library |
| 158 |
FIND_PACKAGE(GnuTLS REQUIRED) |
| 159 |
SET(GNUTLS_INCLUDE_DIR ${GNUTLS_INCLUDE_DIR} PARENT_SCOPE) |
| 160 |
SET(GNUTLS_LIBRARIES ${GNUTLS_LIBRARIES} PARENT_SCOPE) |
| 161 |
|
| 162 |
find_path(GCRYPT_INCLUDE_DIR NAMES gcrypt.h) |
| 163 |
If ( NOT GCRYPT_INCLUDE_DIR ) |
| 164 |
MESSAGE(SEND_ERROR "Unable to find gcrypt.h, please install libgcrypt-dev or equivalent") |
| 165 |
Endif ( NOT GCRYPT_INCLUDE_DIR ) |
| 166 |
MARK_AS_ADVANCED(GCRYPT_INCLUDE_DIR) |
| 167 |
SET(GCRYPT_INCLUDE_DIR ${GCRYPT_INCLUDE_DIR} PARENT_SCOPE) |
| 168 |
|
| 169 |
# Also we need libgcrypt to... display its version :( |
| 170 |
find_library(GCRYPT_LIBRARY |
| 171 |
NAMES gcrypt |
| 172 |
) |
| 173 |
If ( NOT GCRYPT_LIBRARY ) |
| 174 |
MESSAGE(SEND_ERROR "Unable to find libgcrypt, please install libgcrypt or equivalent") |
| 175 |
Endif ( NOT GCRYPT_LIBRARY ) |
| 176 |
SET(GCRYPT_LIBRARY ${GCRYPT_LIBRARY} PARENT_SCOPE) |
| 177 |
|
| 178 |
|
| 179 |
# Check if AI_ADDRCONFIG is available on the system |
| 180 |
CHECK_SYMBOL_EXISTS(AI_ADDRCONFIG "netdb.h" HAVE_AI_ADDRCONFIG) |
| 181 |
|
| 182 |
|
| 183 |
# Check if barriers are available (for test_fifo) |
| 184 |
SET(CMAKE_REQUIRED_INCLUDES "pthread.h") |
| 185 |
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) |
| 186 |
CHECK_FUNCTION_EXISTS (pthread_barrier_wait HAVE_PTHREAD_BAR) |
| 187 |
SET(HAVE_PTHREAD_BAR ${HAVE_PTHREAD_BAR} PARENT_SCOPE) |
| 188 |
|
| 189 |
|
| 190 |
########################## |
| 191 |
|
| 192 |
# Additional hg version when relevant, stored in version.h |
| 193 |
if (EXISTS "${CMAKE_SOURCE_DIR}/.hg") |
| 194 |
# Search for hg binary to use |
| 195 |
FIND_PROGRAM(HGCOMMAND hg) |
| 196 |
if (HGCOMMAND) |
| 197 |
# Ok, add the custom target so that hg is executed at every build |
| 198 |
ADD_CUSTOM_TARGET(version_information |
| 199 |
COMMAND ${CMAKE_COMMAND} -D HGCOMMAND="${HGCOMMAND}" -D SRC="${CMAKE_CURRENT_SOURCE_DIR}/version.h.in" -D DST="${CMAKE_CURRENT_BINARY_DIR}/version.h" -P "${CMAKE_SOURCE_DIR}/cmake/Modules/GetVersionWithHg.cmake" |
| 200 |
DEPENDS "${CMAKE_SOURCE_DIR}/.hg/dirstate" |
| 201 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
| 202 |
COMMENT "Retrieving version of the hg repository" |
| 203 |
) |
| 204 |
else (HGCOMMAND) |
| 205 |
# Display at least "unknown" rev in this case |
| 206 |
SET(FD_PROJECT_VERSION_HG "unknown") |
| 207 |
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) |
| 208 |
ADD_CUSTOM_TARGET(version_information DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h) |
| 209 |
endif(HGCOMMAND) |
| 210 |
else (EXISTS "${CMAKE_SOURCE_DIR}/.hg") |
| 211 |
# We use the pure version number without extension |
| 212 |
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) |
| 213 |
ADD_CUSTOM_TARGET(version_information DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h) |
| 214 |
endif (EXISTS "${CMAKE_SOURCE_DIR}/.hg") |
| 215 |
|
| 216 |
|
| 217 |
########################## |
| 218 |
|
| 219 |
# LFDPROTO_LIBS = libraries required by the libfdproto. |
| 220 |
SET(LFDPROTO_LIBS ${CLOCK_GETTIME_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${IDNA_LIBRARIES} PARENT_SCOPE) |
| 221 |
# And includes paths |
| 222 |
SET(LFDPROTO_INCLUDES ${IDNA_INCLUDE_DIR} PARENT_SCOPE) |
| 223 |
# Dependencies: the libraries required by any code linking to libfdproto. |
| 224 |
SET(LFDPROTO_LINK_INTERFACES ${CMAKE_THREAD_LIBS_INIT} PARENT_SCOPE) |
| 225 |
|
| 226 |
# LFDCORE_LIBS = libraries required by the libfdcore (in addition to libfdproto and its dependencies) |
| 227 |
SET(LFDCORE_LIBS ${CLOCK_GETTIME_LIBS} ${CMAKE_DL_LIBS} ${SCTP_LIBRARIES} ${GCRYPT_LIBRARY} ${GNUTLS_LIBRARIES} PARENT_SCOPE) |
| 228 |
# And includes paths |
| 229 |
SET(LFDCORE_INCLUDES ${SCTP_INCLUDE_DIR} ${GNUTLS_INCLUDE_DIR} ${GCRYPT_INCLUDE_DIR} PARENT_SCOPE) |
| 230 |
# And dependencies |
| 231 |
SET(LFDCORE_LINK_INTERFACES "" PARENT_SCOPE) |
| 232 |
# We don't force other libraries, the programs will link with what it needs |
| 233 |
# (such as libgnutls if it uses GNUTLS_DEBUG() macro |
| 234 |
# or libfdproto if it uses some of its interfaces directly) |
| 235 |
# See freeDiameterd/CMakeLists.txt for an example. |
| 236 |
|
| 237 |
########################## |
| 238 |
|
| 239 |
# Generate the host.h file |
| 240 |
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/freeDiameter-host.h.in ${CMAKE_CURRENT_BINARY_DIR}/freeDiameter-host.h) |
| 241 |
|
| 242 |
#### |
| 243 |
## INSTALL section ## |
| 244 |
|
| 245 |
# The headers from this directory are required to develop new extensions for freeDiameter. |
| 246 |
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/freeDiameter-host.h libfdproto.h libfdcore.h extension.h |
| 247 |
DESTINATION ${INSTALL_HEADERS_SUFFIX} |
| 248 |
COMPONENT freeDiameter-dev) |
| 249 |
|