1 cmake_minimum_required (VERSION 3.1)
3 set ( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
5 option ( BUILD_STG "Build Stargazer server." OFF )
6 option ( BUILD_SGCONF "Build SGConf client." OFF )
7 option ( BUILD_RSCRIPTD "Build RScriptD server." OFF )
8 option ( BUILD_RLM_STG "Build rlm_stg FreeRADIUS module." OFF )
9 option ( BUILD_SGAUTH "Build SGAuth client." OFF )
12 option ( BUILD_MOD_AO "Build AlwaysOnline STG module." ON )
13 option ( BUILD_MOD_IA "Buils InetAccess STG module." ON )
14 option ( BUILD_MOD_SGCONFIG "Build SGConfig STG module." ON )
15 option ( BUILD_MOD_PING "Build Ping STG module." ON )
16 option ( BUILD_MOD_RSCRYPT "Build RScrypt STG module." ON )
17 option ( BUILD_MOD_SMUX "Buils SMUX STG module." ON )
18 option ( BUILD_MOD_STORE_FILES "Build file store STG module." ON )
19 option ( BUILD_MOD_CAP_NF "Build NetFlow capture STG module." ON )
22 option ( BUILD_MOD_CAP_ETHER_LINUX "Build Linux Ethernet capture STG module." OFF )
23 option ( BUILD_MOD_CAP_ETHER_FREEBSD "Build FreeBSD Ethernet capture STG module." OFF )
24 option ( BUILD_MOD_CAP_DIVERT "Build FreeBSD divert-socket capture STG MODULE." OFF )
26 # Lib-specific modules
27 option ( BUILD_MOD_STORE_FIREBIRD "Build Firebird store STG module." OFF )
28 option ( BUILD_MOD_STORE_POSTGRESQL "Build PostgreSQL store STG module." OFF )
29 option ( BUILD_MOD_STORE_MYSQL "Build MySQL store STG module." OFF )
30 option ( BUILD_MOD_RPCCONFIG "Build XML-RPC configuretion STG module." OFF )
31 option ( BUILD_MOD_CAP_PCAP "Build PCap capture STG module." OFF )
32 option ( BUILD_MOD_CAP_NFQUEUE "Build NFQueue capture STG module." OFF )
33 option ( BUILD_MOD_RADIUS "Build rlm_stg backend STG module." OFF )
36 option ( BUILD_ALL_MODS "Build all modules." OFF )
37 option ( BUILD_ALL_LIBS "Build all libraries." OFF )
38 option ( BUILD_TESTS "Build tests." OFF )
39 option ( BUILD_ALL "Build binaries, libraries and tests." OFF )
40 option ( ENABLE_COVERAGE "Enable code coverage analysis." OFF )
43 set ( BUILD_ALL_MODS ON )
44 set ( BUILD_ALL_LIBS ON )
45 set ( BUILD_TESTS ON )
46 set ( BUILD_SGAUTH ON )
47 set ( BUILD_RSCRIPTD ON )
48 set ( BUILD_RLM_STG ON )
49 set ( BUILD_SGCONF ON )
53 set ( BUILD_LIB_COMMON ON )
55 if ( BUILD_SGAUTH OR BUILD_ALL_LIBS )
56 set ( BUILD_LIB_CONFFILES ON )
57 set ( BUILD_LIB_CRYPTO ON )
58 set ( BUILD_LIB_IA ON )
59 endif ( BUILD_SGAUTH OR BUILD_ALL_LIBS )
61 if ( BUILD_SGCONF OR BUILD_ALL_LIBS )
62 set ( BUILD_LIB_CRYPTO ON )
63 set ( BUILD_LIB_SRVCONF ON )
64 endif ( BUILD_SGCONF OR BUILD_ALL_LIBS )
66 if ( BUILD_RSCRIPTD OR BUILD_ALL_LIBS )
67 set ( BUILD_LIB_CONFFILES ON )
68 set ( BUILD_LIB_CRYPTO ON )
69 set ( BUILD_LIB_LOGGER ON )
70 set ( BUILD_LIB_SCRIPTEXECUTER ON )
71 endif ( BUILD_RSCRIPTD OR BUILD_ALL_LIBS )
73 if ( BUILD_RLM_STG OR BUILD_ALL_LIBS )
74 set ( BUILD_LIB_CRYPTO ON )
75 set ( BUILD_LIB_JSON ON )
76 endif ( BUILD_RLM_STG OR BUILD_ALL_LIBS )
78 if ( BUILD_STG OR BUILD_ALL_LIBS )
79 set ( BUILD_LIB_CONFFILES ON )
80 set ( BUILD_LIB_CRYPTO ON )
81 set ( BUILD_LIB_DOTCONFPP ON )
82 set ( BUILD_LIB_LOGGER ON )
83 set ( BUILD_LIB_SCRIPTEXECUTER ON )
84 endif ( BUILD_STG OR BUILD_ALL_LIBS )
87 set ( BUILD_MOD_STORE_FIREBIRD ON )
88 set ( BUILD_MOD_STORE_MYSQL ON )
89 set ( BUILD_MOD_STORE_POSTGRESQL ON )
90 set ( BUILD_MOD_RPCCONFIG ON )
91 set ( BUILD_MOD_CAP_PCAP ON )
92 set ( BUILD_MOD_CAP_NFQUEUE ON )
93 set ( BUILD_MOD_RADIUS ON )
94 endif ( BUILD_ALL_MODS )
96 if ( BUILD_MOD_STORE_FIREBIRD OR BUILD_ALL_LIBS )
97 set ( BUILD_LIB_IBPP ON )
98 endif ( BUILD_MOD_STORE_FIREBIRD OR BUILD_ALL_LIBS )
100 if ( BUILD_MOD_RADIUS OR BUILD_ALL_LIBS )
101 set ( BUILD_LIB_JSON ON )
102 set ( BUILD_LIB_IBPP ON )
103 endif ( BUILD_MOD_RADIUS OR BUILD_ALL_LIBS )
105 if ( BUILD_MOD_PING OR BUILD_ALL_LIBS )
106 set ( BUILD_LIB_PINGER ON )
107 endif ( BUILD_MOD_PING OR BUILD_ALL_LIBS )
109 if ( BUILD_MOD_SMUX OR BUILD_ALL_LIBS )
110 set ( BUILD_LIB_SMUX ON )
111 endif ( BUILD_MOD_SMUX OR BUILD_ALL_LIBS )
113 enable_language (CXX)
114 set (CMAKE_CXX_STANDARD 17)
115 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Wextra -Wshadow -Wlogical-op -Wuseless-cast -Wno-long-long -Wold-style-cast -Wstrict-aliasing -pedantic")
117 if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
118 add_definitions ( -DLINUX )
119 set ( BUILD_MOD_CAP_ETHER_LINUX ON )
120 if ( BUILD_LIB_IBPP )
121 add_definitions ( -DIBPP_LINUX )
122 endif ( BUILD_LIB_IBPP )
123 elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" )
124 add_definitions ( -DFREE_BSD )
125 set ( BUILD_MOD_CAP_ETHER_FREEBSD ON )
126 set ( BUILD_MOD_CAP_DIVERT ON )
127 if ( BUILD_LIB_IBPP )
128 add_definitions ( -DIBPP_LINUX )
129 message ( WARNING "IBPP does not support '${CMAKE_SYSTEM_NAME}'" )
130 endif ( BUILD_LIB_IBPP )
131 elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
132 add_definitions ( -DDARWIN )
133 if ( BUILD_LIB_IBPP )
134 add_definitions ( -DIBPP_DARWIN )
135 endif ( BUILD_LIB_IBPP )
137 message ( WARNING "Unsupported system: '${CMAKE_SYSTEM_NAME}'" )
140 include_directories ( include )
142 add_subdirectory ( libs )
145 add_subdirectory ( rlm_stg )
146 endif ( BUILD_RLM_STG )
148 if ( BUILD_RSCRIPTD )
149 add_subdirectory ( rscriptd )
150 endif ( BUILD_RSCRIPTD )
153 add_subdirectory ( sgauth )
154 endif ( BUILD_SGAUTH )
157 add_subdirectory ( sgconf )
158 endif ( BUILD_SGCONF )
161 add_subdirectory ( stargazer )
165 add_subdirectory ( tests )
166 endif ( BUILD_TESTS )
168 add_custom_target (cppcheck COMMAND cppcheck --enable=all --std=c++14 ${CMAKE_SOURCE_DIR}/rlm_stg ${CMAKE_SOURCE_DIR}/rscriptd ${CMAKE_SOURCE_DIR}/sgauth ${CMAKE_SOURCE_DIR}/sgconf ${CMAKE_SOURCE_DIR}/sgconv ${CMAKE_SOURCE_DIR}/stargazer)