1 cmake_minimum_required (VERSION 3.12)
5 set ( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
7 if ( CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.5 )
8 message ( FATAL_ERROR "Require at least gcc-6.5" )
9 endif( CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.5 )
11 option ( BUILD_STG "Build Stargazer server." OFF )
12 option ( BUILD_SGCONF "Build SGConf client." OFF )
13 option ( BUILD_RSCRIPTD "Build RScriptD server." OFF )
14 option ( BUILD_RLM_STG "Build rlm_stg FreeRADIUS module." OFF )
15 option ( BUILD_SGAUTH "Build SGAuth client." OFF )
18 option ( BUILD_MOD_AO "Build AlwaysOnline STG module." ON )
19 option ( BUILD_MOD_IA "Buils InetAccess STG module." ON )
20 option ( BUILD_MOD_SGCONFIG "Build SGConfig STG module." ON )
21 option ( BUILD_MOD_PING "Build Ping STG module." ON )
22 option ( BUILD_MOD_RSCRYPT "Build RScrypt STG module." ON )
23 option ( BUILD_MOD_SMUX "Buils SMUX STG module." ON )
24 option ( BUILD_MOD_STORE_FILES "Build file store STG module." ON )
25 option ( BUILD_MOD_CAP_NF "Build NetFlow capture STG module." ON )
28 option ( BUILD_MOD_CAP_ETHER_LINUX "Build Linux Ethernet capture STG module." OFF )
29 option ( BUILD_MOD_CAP_ETHER_FREEBSD "Build FreeBSD Ethernet capture STG module." OFF )
30 option ( BUILD_MOD_CAP_DIVERT "Build FreeBSD divert-socket capture STG MODULE." OFF )
32 # Lib-specific modules
33 option ( BUILD_MOD_STORE_FIREBIRD "Build Firebird store STG module." OFF )
34 option ( BUILD_MOD_STORE_POSTGRESQL "Build PostgreSQL store STG module." OFF )
35 option ( BUILD_MOD_STORE_MYSQL "Build MySQL store STG module." OFF )
36 option ( BUILD_MOD_RPCCONFIG "Build XML-RPC configuretion STG module." OFF )
37 option ( BUILD_MOD_CAP_PCAP "Build PCap capture STG module." OFF )
38 option ( BUILD_MOD_CAP_NFQUEUE "Build NFQueue capture STG module." OFF )
39 option ( BUILD_MOD_RADIUS "Build rlm_stg backend STG module." OFF )
42 option ( BUILD_ALL_MODS "Build all modules." OFF )
43 option ( BUILD_ALL_LIBS "Build all libraries." OFF )
44 option ( BUILD_TESTS "Build tests." OFF )
45 option ( BUILD_ALL "Build binaries, libraries and tests." OFF )
46 option ( ENABLE_COVERAGE "Enable code coverage analysis." OFF )
49 set ( BUILD_ALL_MODS ON )
50 set ( BUILD_ALL_LIBS ON )
51 set ( BUILD_TESTS ON )
52 set ( BUILD_SGAUTH ON )
53 set ( BUILD_RSCRIPTD ON )
54 set ( BUILD_RLM_STG ON )
55 set ( BUILD_SGCONF ON )
59 set ( BUILD_LIB_COMMON ON )
61 if ( BUILD_SGAUTH OR BUILD_ALL_LIBS )
62 set ( BUILD_LIB_CONFFILES ON )
63 set ( BUILD_LIB_CRYPTO ON )
64 set ( BUILD_LIB_IA ON )
65 endif ( BUILD_SGAUTH OR BUILD_ALL_LIBS )
67 if ( BUILD_SGCONF OR BUILD_ALL_LIBS )
68 set ( BUILD_LIB_CRYPTO ON )
69 set ( BUILD_LIB_SRVCONF ON )
70 endif ( BUILD_SGCONF OR BUILD_ALL_LIBS )
72 if ( BUILD_RSCRIPTD OR BUILD_ALL_LIBS )
73 set ( BUILD_LIB_CONFFILES ON )
74 set ( BUILD_LIB_CRYPTO ON )
75 set ( BUILD_LIB_LOGGER ON )
76 set ( BUILD_LIB_SCRIPTEXECUTER ON )
77 endif ( BUILD_RSCRIPTD OR BUILD_ALL_LIBS )
79 if ( BUILD_RLM_STG OR BUILD_ALL_LIBS )
80 set ( BUILD_LIB_CRYPTO ON )
81 set ( BUILD_LIB_JSON ON )
82 endif ( BUILD_RLM_STG OR BUILD_ALL_LIBS )
84 if ( BUILD_STG OR BUILD_ALL_LIBS )
85 set ( BUILD_LIB_CONFFILES ON )
86 set ( BUILD_LIB_CRYPTO ON )
87 set ( BUILD_LIB_DOTCONFPP ON )
88 set ( BUILD_LIB_LOGGER ON )
89 set ( BUILD_LIB_SCRIPTEXECUTER ON )
90 endif ( BUILD_STG OR BUILD_ALL_LIBS )
93 set ( BUILD_MOD_STORE_FIREBIRD ON )
94 set ( BUILD_MOD_STORE_MYSQL ON )
95 set ( BUILD_MOD_STORE_POSTGRESQL ON )
96 set ( BUILD_MOD_RPCCONFIG ON )
97 set ( BUILD_MOD_CAP_PCAP ON )
98 set ( BUILD_MOD_RADIUS ON )
99 endif ( BUILD_ALL_MODS )
101 if ( BUILD_MOD_STORE_FIREBIRD OR BUILD_ALL_LIBS )
102 set ( BUILD_LIB_IBPP ON )
103 endif ( BUILD_MOD_STORE_FIREBIRD OR BUILD_ALL_LIBS )
105 if ( BUILD_MOD_RADIUS OR BUILD_ALL_LIBS )
106 set ( BUILD_LIB_JSON ON )
107 set ( BUILD_LIB_IBPP ON )
108 endif ( BUILD_MOD_RADIUS OR BUILD_ALL_LIBS )
110 if ( BUILD_MOD_PING OR BUILD_ALL_LIBS )
111 set ( BUILD_LIB_PINGER ON )
112 endif ( BUILD_MOD_PING OR BUILD_ALL_LIBS )
114 if ( BUILD_MOD_SMUX OR BUILD_ALL_LIBS )
115 set ( BUILD_LIB_SMUX ON )
116 endif ( BUILD_MOD_SMUX OR BUILD_ALL_LIBS )
118 enable_language (CXX)
119 set (CMAKE_CXX_STANDARD 14)
120 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Wextra -Wshadow -Wno-long-long -Wold-style-cast -Wstrict-aliasing -pedantic")
122 if ( CMAKE_COMPILER_IS_GNUCC )
124 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlogical-op -Wuseless-cast")
125 endif ( CMAKE_COMPILER_IS_GNUCC )
127 if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
128 add_definitions ( -DLINUX )
129 set ( BUILD_MOD_CAP_ETHER_LINUX ON )
130 if ( BUILD_LIB_IBPP )
131 add_definitions ( -DIBPP_LINUX )
132 endif ( BUILD_LIB_IBPP )
133 if ( BUILD_ALL_MODS )
134 set ( BUILD_MOD_CAP_NFQUEUE ON )
135 endif ( BUILD_ALL_MODS )
136 elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" )
137 add_definitions ( -DFREE_BSD )
138 set ( BUILD_MOD_CAP_ETHER_FREEBSD ON )
139 set ( BUILD_MOD_CAP_DIVERT ON )
140 if ( BUILD_LIB_IBPP )
141 add_definitions ( -DIBPP_LINUX )
142 message ( WARNING "IBPP does not support '${CMAKE_SYSTEM_NAME}'" )
143 endif ( BUILD_LIB_IBPP )
144 elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
145 add_definitions ( -DDARWIN )
146 if ( BUILD_LIB_IBPP )
147 add_definitions ( -DIBPP_DARWIN )
148 endif ( BUILD_LIB_IBPP )
150 message ( WARNING "Unsupported system: '${CMAKE_SYSTEM_NAME}'" )
153 include_directories ( include )
155 add_subdirectory ( libs )
158 add_subdirectory ( rlm_stg )
159 endif ( BUILD_RLM_STG )
161 if ( BUILD_RSCRIPTD )
162 add_subdirectory ( rscriptd )
163 endif ( BUILD_RSCRIPTD )
166 add_subdirectory ( sgauth )
167 endif ( BUILD_SGAUTH )
170 add_subdirectory ( sgconf )
171 endif ( BUILD_SGCONF )
174 add_subdirectory ( stargazer )
178 add_subdirectory ( tests )
179 endif ( BUILD_TESTS )
181 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)