1 cmake_minimum_required (VERSION 3.12)
5 set ( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
7 option ( BUILD_STG "Build Stargazer server." OFF )
8 option ( BUILD_SGCONF "Build SGConf client." OFF )
9 option ( BUILD_RSCRIPTD "Build RScriptD server." OFF )
10 option ( BUILD_SGAUTH "Build SGAuth client." OFF )
13 option ( BUILD_MOD_AO "Build AlwaysOnline STG module." ON )
14 option ( BUILD_MOD_RADIUS "Build Radius STG module." ON )
15 option ( BUILD_MOD_IA "Buils InetAccess STG module." ON )
16 option ( BUILD_MOD_SGCONFIG "Build SGConfig STG module." ON )
17 option ( BUILD_MOD_PING "Build Ping STG module." ON )
18 option ( BUILD_MOD_RSCRYPT "Build RScrypt STG module." ON )
19 option ( BUILD_MOD_SMUX "Buils SMUX STG module." ON )
20 option ( BUILD_MOD_STORE_FILES "Build file store STG module." ON )
21 option ( BUILD_MOD_CAP_NF "Build NetFlow capture STG module." ON )
24 option ( BUILD_MOD_CAP_ETHER_LINUX "Build Linux Ethernet capture STG module." OFF )
25 option ( BUILD_MOD_CAP_ETHER_FREEBSD "Build FreeBSD Ethernet capture STG module." OFF )
26 option ( BUILD_MOD_CAP_DIVERT "Build FreeBSD divert-socket capture STG MODULE." OFF )
28 # Lib-specific modules
29 option ( BUILD_MOD_STORE_FIREBIRD "Build Firebird store STG module." OFF )
30 option ( BUILD_MOD_STORE_POSTGRESQL "Build PostgreSQL store STG module." OFF )
31 option ( BUILD_MOD_STORE_MYSQL "Build MySQL store STG module." OFF )
32 option ( BUILD_MOD_RPCCONFIG "Build XML-RPC configuretion STG module." OFF )
33 option ( BUILD_MOD_CAP_PCAP "Build PCap capture STG module." OFF )
34 option ( BUILD_MOD_CAP_NFQUEUE "Build NFQueue capture STG module." OFF )
36 # Firebird is getting deprecated, negation option
37 option ( BUILD_NO_MOD_STORE_FIREBIRD "Do not build Firebird store STG module." OFF )
40 option ( BUILD_ALL_MODS "Build all modules." OFF )
41 option ( BUILD_ALL_LIBS "Build all libraries." OFF )
42 option ( BUILD_TESTS "Build tests." OFF )
43 option ( BUILD_ALL "Build binaries, libraries and tests." OFF )
44 option ( ENABLE_COVERAGE "Enable code coverage analysis." OFF )
47 option ( CPPCHECK_FOREIGN "Run cppcheck over foreign lib code" OFF )
50 set ( BUILD_ALL_MODS ON )
51 set ( BUILD_ALL_LIBS ON )
52 set ( BUILD_TESTS ON )
53 set ( BUILD_SGAUTH ON )
54 set ( BUILD_RSCRIPTD 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 )
80 set ( BUILD_LIB_CRYPTO ON )
81 endif ( BUILD_ALL_LIBS )
83 if ( BUILD_STG OR BUILD_ALL_LIBS )
84 set ( BUILD_LIB_CONFFILES ON )
85 set ( BUILD_LIB_CRYPTO ON )
86 set ( BUILD_LIB_DOTCONFPP ON )
87 set ( BUILD_LIB_LOGGER ON )
88 set ( BUILD_LIB_SCRIPTEXECUTER ON )
89 endif ( BUILD_STG OR BUILD_ALL_LIBS )
92 set ( BUILD_MOD_STORE_FIREBIRD ON )
93 set ( BUILD_MOD_STORE_MYSQL ON )
94 set ( BUILD_MOD_STORE_POSTGRESQL ON )
95 set ( BUILD_MOD_RPCCONFIG ON )
96 set ( BUILD_MOD_CAP_PCAP ON )
97 endif ( BUILD_ALL_MODS )
99 if ( BUILD_NO_MOD_STORE_FIREBIRD )
100 set ( BUILD_MOD_STORE_FIREBIRD OFF )
101 endif ( BUILD_NO_MOD_STORE_FIREBIRD )
103 if ( BUILD_MOD_STORE_FIREBIRD OR BUILD_ALL_LIBS )
104 set ( BUILD_LIB_IBPP ON )
105 endif ( BUILD_MOD_STORE_FIREBIRD OR BUILD_ALL_LIBS )
107 if ( BUILD_MOD_PING OR BUILD_ALL_LIBS )
108 set ( BUILD_LIB_PINGER ON )
109 endif ( BUILD_MOD_PING OR BUILD_ALL_LIBS )
111 if ( BUILD_MOD_SMUX OR BUILD_ALL_LIBS )
112 set ( BUILD_LIB_SMUX ON )
113 endif ( BUILD_MOD_SMUX OR BUILD_ALL_LIBS )
116 find_program( CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable" )
117 if ( NOT CLANG_TIDY_EXE )
118 message( STATUS "clang-tidy not found." )
120 message( STATUS "clang-tidy found: ${CLANG_TIDY_EXE}" )
121 set( DO_CLANG_TIDY "${CLANG_TIDY_EXE}"
130 -modernize-avoid-bind,\
131 -modernize-use-trailing-return-type,\
132 -readability-braces-around-statements, \
133 -readability-magic-numbers, \
134 -readability-identifier-length, \
135 -bugprone-easily-swappable-parameters" )
140 find_program( INCLUDE_WHAT_YOU_USE_EXE NAMES "include-what-you-use" DOC "Path to include-what-you-use executable" )
141 if ( NOT INCLUDE_WHAT_YOU_USE_EXE )
142 message( STATUS "include-what-you-use not found." )
144 message( STATUS "include-what-you-use found: ${INCLUDE_WHAT_YOU_USE_EXE}" )
145 set( DO_INCLUDE_WHAT_YOU_USE "${INCLUDE_WHAT_YOU_USE_EXE}" )
149 enable_language (CXX)
150 set (CMAKE_CXX_STANDARD 17)
151 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Wextra -Wshadow -Wno-long-long -Wold-style-cast -Wstrict-aliasing -pedantic")
153 if ( CMAKE_COMPILER_IS_GNUCC )
155 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlogical-op -Wuseless-cast")
156 endif ( CMAKE_COMPILER_IS_GNUCC )
158 if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
159 add_definitions ( -DLINUX )
160 set ( BUILD_MOD_CAP_ETHER_LINUX ON )
161 if ( BUILD_LIB_IBPP )
162 add_definitions ( -DIBPP_LINUX )
163 endif ( BUILD_LIB_IBPP )
164 if ( BUILD_ALL_MODS )
165 set ( BUILD_MOD_CAP_NFQUEUE ON )
166 endif ( BUILD_ALL_MODS )
167 elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" )
168 add_definitions ( -DFREE_BSD )
169 set ( BUILD_MOD_CAP_ETHER_FREEBSD ON )
170 set ( BUILD_MOD_CAP_DIVERT ON )
171 if ( BUILD_LIB_IBPP )
172 add_definitions ( -DIBPP_LINUX )
173 message ( WARNING "IBPP does not support '${CMAKE_SYSTEM_NAME}'" )
174 endif ( BUILD_LIB_IBPP )
175 elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
176 add_definitions ( -DDARWIN )
177 if ( BUILD_LIB_IBPP )
178 add_definitions ( -DIBPP_DARWIN )
179 endif ( BUILD_LIB_IBPP )
181 message ( WARNING "Unsupported system: '${CMAKE_SYSTEM_NAME}'" )
184 include_directories ( include )
185 include_directories ( 3rdparty/jthread/source )
187 add_subdirectory ( libs )
188 add_subdirectory ( projects )
192 add_subdirectory ( tests )
193 endif ( BUILD_TESTS )