0
|
1 #CMake configuration for freediameter include directory
|
|
2
|
|
3 Project("FreeDiameter include directory" C)
|
|
4
|
|
5 ########################
|
|
6 # Configurable parameters
|
|
7
|
|
8 # Name of the default configuration file
|
|
9 OPTION(DEFAULT_CONF_FILE "Default path to configuration file?" OFF)
|
|
10
|
|
11 # Disable SCTP support completly ?
|
|
12 OPTION(DISABLE_SCTP "Disable SCTP support?")
|
|
13
|
|
14
|
|
15 ########################
|
|
16 # System checks
|
|
17
|
|
18 INCLUDE (CheckLibraryExists)
|
|
19 INCLUDE (CheckFunctionExists)
|
|
20 INCLUDE (CheckIncludeFiles)
|
|
21 INCLUDE (CheckSymbolExists)
|
|
22 INCLUDE (TestBigEndian)
|
|
23
|
|
24 # We use dlopen and dlclose
|
|
25 SET(FD_LIBS ${FD_LIBS} ${CMAKE_DL_LIBS})
|
|
26
|
|
27 # We need the threads library (pthread)
|
|
28 INCLUDE(FindThreads)
|
|
29 SET(FD_LIBS ${FD_LIBS} ${CMAKE_THREAD_LIBS_INIT})
|
|
30
|
|
31 # We need the clock_gettime function ( -lrt, -lposix4 )
|
|
32 CHECK_FUNCTION_EXISTS (clock_gettime HAVE_CLOCK_GETTIME)
|
|
33 IF (HAVE_CLOCK_GETTIME)
|
|
34 SET(CLOCK_GETTIME_LIBS "")
|
|
35 ELSE (HAVE_CLOCK_GETTIME)
|
|
36 CHECK_LIBRARY_EXISTS (rt clock_gettime "" HAVE_LIBRT)
|
|
37 IF (HAVE_LIBRT)
|
|
38 SET(CLOCK_GETTIME_LIBS "-lrt")
|
|
39 ELSE (HAVE_LIBRT)
|
|
40 CHECK_LIBRARY_EXISTS (posix4 clock_gettime "" HAVE_LIBPOSIX4)
|
|
41 IF (HAVE_LIBPOSIX4)
|
|
42 SET(CLOCK_GETTIME_LIBS "-lposix4")
|
|
43 ENDIF (HAVE_LIBPOSIX4)
|
|
44 ENDIF (HAVE_LIBRT)
|
|
45 ENDIF (HAVE_CLOCK_GETTIME)
|
|
46 SET(FD_LIBS ${FD_LIBS} ${CLOCK_GETTIME_LIBS})
|
|
47
|
|
48 # We need the sctp_getladdrs function ( -lsctp )
|
|
49 # We need the IPPROTO_SCTP symbol from sys/socket.h, netinet/in.h or netinet/sctp.h
|
|
50 IF(NOT DISABLE_SCTP)
|
|
51 CHECK_FUNCTION_EXISTS(sctp_getladdrs HAVE_NATIVE_SCTP)
|
|
52 IF(NOT HAVE_NATIVE_SCTP)
|
|
53 FIND_PACKAGE(SCTP REQUIRED)
|
|
54 INCLUDE_DIRECTORIES(${SCTP_INCLUDE_DIRS})
|
|
55 SET(FD_LIBS ${FD_LIBS} ${SCTP_LIBRARIES})
|
|
56 ENDIF(NOT HAVE_NATIVE_SCTP)
|
|
57 ENDIF(NOT DISABLE_SCTP)
|
|
58
|
|
59 # Check byte ordering
|
|
60 TEST_BIG_ENDIAN(HOST_BIG_ENDIAN)
|
|
61
|
|
62 # We need the getopt_long function
|
|
63 CHECK_FUNCTION_EXISTS (getopt_long HAVE_LONG_OPTIONS)
|
|
64 IF (NOT HAVE_LONG_OPTIONS)
|
|
65 MESSAGE(SEND_ERROR "The getopt_long function is not found, please add needed library in build system")
|
|
66 ENDIF (NOT HAVE_LONG_OPTIONS)
|
|
67
|
|
68 # Check if ntohll is provided on the system
|
|
69 CHECK_SYMBOL_EXISTS(ntohll "" HAVE_NTOHLL)
|
|
70
|
|
71 # malloc.h ?
|
|
72 CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
|
|
73
|
|
74 # The default configuration file name
|
|
75 IF (NOT DEFAULT_CONF_FILE)
|
|
76 SET(DEFAULT_CONF_FILE "freediameter.conf")
|
|
77 ENDIF (NOT DEFAULT_CONF_FILE)
|
|
78 ##########################
|
|
79
|
|
80 # Generate the host.h file
|
|
81 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/freediameter-host.h.in ${CMAKE_CURRENT_BINARY_DIR}/freediameter-host.h)
|
|
82
|
|
83 # Save the FD_LIBS for parent scope
|
|
84 SET(FD_LIBS ${FD_LIBS} PARENT_SCOPE)
|