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_IA "Buils InetAccess STG module." ON )
15 option ( BUILD_MOD_SGCONFIG "Build SGConfig STG module." ON )
16 option ( BUILD_MOD_PING "Build Ping STG module." ON )
17 option ( BUILD_MOD_RSCRYPT "Build RScrypt STG module." ON )
18 option ( BUILD_MOD_SMUX "Buils SMUX STG module." ON )
19 option ( BUILD_MOD_STORE_FILES "Build file store STG module." ON )
20 option ( BUILD_MOD_CAP_NF "Build NetFlow capture STG module." ON )
23 option ( BUILD_MOD_CAP_ETHER_LINUX "Build Linux Ethernet capture STG module." OFF )
24 option ( BUILD_MOD_CAP_ETHER_FREEBSD "Build FreeBSD Ethernet capture STG module." OFF )
25 option ( BUILD_MOD_CAP_DIVERT "Build FreeBSD divert-socket capture STG MODULE." OFF )
27 # Lib-specific modules
28 option ( BUILD_MOD_STORE_FIREBIRD "Build Firebird store STG module." OFF )
29 option ( BUILD_MOD_STORE_POSTGRESQL "Build PostgreSQL store STG module." OFF )
30 option ( BUILD_MOD_STORE_MYSQL "Build MySQL store STG module." OFF )
31 option ( BUILD_MOD_RPCCONFIG "Build XML-RPC configuretion STG module." OFF )
32 option ( BUILD_MOD_CAP_PCAP "Build PCap capture STG module." OFF )
33 option ( BUILD_MOD_CAP_NFQUEUE "Build NFQueue capture 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_SGCONF ON )
52 set ( BUILD_LIB_COMMON ON )
54 if ( BUILD_SGAUTH OR BUILD_ALL_LIBS )
55 set ( BUILD_LIB_CONFFILES ON )
56 set ( BUILD_LIB_CRYPTO ON )
57 set ( BUILD_LIB_IA ON )
58 endif ( BUILD_SGAUTH OR BUILD_ALL_LIBS )
60 if ( BUILD_SGCONF OR BUILD_ALL_LIBS )
61 set ( BUILD_LIB_CRYPTO ON )
62 set ( BUILD_LIB_SRVCONF ON )
63 endif ( BUILD_SGCONF OR BUILD_ALL_LIBS )
65 if ( BUILD_RSCRIPTD OR BUILD_ALL_LIBS )
66 set ( BUILD_LIB_CONFFILES ON )
67 set ( BUILD_LIB_CRYPTO ON )
68 set ( BUILD_LIB_LOGGER ON )
69 set ( BUILD_LIB_SCRIPTEXECUTER ON )
70 endif ( BUILD_RSCRIPTD OR BUILD_ALL_LIBS )
73 set ( BUILD_LIB_CRYPTO ON )
74 endif ( BUILD_ALL_LIBS )
76 if ( BUILD_STG OR BUILD_ALL_LIBS )
77 set ( BUILD_LIB_CONFFILES ON )
78 set ( BUILD_LIB_CRYPTO ON )
79 set ( BUILD_LIB_DOTCONFPP ON )
80 set ( BUILD_LIB_LOGGER ON )
81 set ( BUILD_LIB_SCRIPTEXECUTER ON )
82 endif ( BUILD_STG OR BUILD_ALL_LIBS )
85 set ( BUILD_MOD_STORE_FIREBIRD ON )
86 set ( BUILD_MOD_STORE_MYSQL ON )
87 set ( BUILD_MOD_STORE_POSTGRESQL ON )
88 set ( BUILD_MOD_RPCCONFIG ON )
89 set ( BUILD_MOD_CAP_PCAP ON )
90 endif ( BUILD_ALL_MODS )
92 if ( BUILD_MOD_STORE_FIREBIRD OR BUILD_ALL_LIBS )
93 set ( BUILD_LIB_IBPP ON )
94 endif ( BUILD_MOD_STORE_FIREBIRD OR BUILD_ALL_LIBS )
96 if ( BUILD_MOD_PING OR BUILD_ALL_LIBS )
97 set ( BUILD_LIB_PINGER ON )
98 endif ( BUILD_MOD_PING OR BUILD_ALL_LIBS )
100 if ( BUILD_MOD_SMUX OR BUILD_ALL_LIBS )
101 set ( BUILD_LIB_SMUX ON )
102 endif ( BUILD_MOD_SMUX OR BUILD_ALL_LIBS )
104 enable_language (CXX)
105 set (CMAKE_CXX_STANDARD 17)
106 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Wextra -Wshadow -Wno-long-long -Wold-style-cast -Wstrict-aliasing -pedantic")
108 if ( CMAKE_COMPILER_IS_GNUCC )
110 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlogical-op -Wuseless-cast")
111 endif ( CMAKE_COMPILER_IS_GNUCC )
113 if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
114 add_definitions ( -DLINUX )
115 set ( BUILD_MOD_CAP_ETHER_LINUX ON )
116 if ( BUILD_LIB_IBPP )
117 add_definitions ( -DIBPP_LINUX )
118 endif ( BUILD_LIB_IBPP )
119 if ( BUILD_ALL_MODS )
120 set ( BUILD_MOD_CAP_NFQUEUE ON )
121 endif ( BUILD_ALL_MODS )
122 elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" )
123 add_definitions ( -DFREE_BSD )
124 set ( BUILD_MOD_CAP_ETHER_FREEBSD ON )
125 set ( BUILD_MOD_CAP_DIVERT ON )
126 if ( BUILD_LIB_IBPP )
127 add_definitions ( -DIBPP_LINUX )
128 message ( WARNING "IBPP does not support '${CMAKE_SYSTEM_NAME}'" )
129 endif ( BUILD_LIB_IBPP )
130 elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
131 add_definitions ( -DDARWIN )
132 if ( BUILD_LIB_IBPP )
133 add_definitions ( -DIBPP_DARWIN )
134 endif ( BUILD_LIB_IBPP )
136 message ( WARNING "Unsupported system: '${CMAKE_SYSTEM_NAME}'" )
139 include_directories ( include )
140 include_directories ( 3rdparty/jthread/source )
142 add_subdirectory ( libs )
143 add_subdirectory ( projects )
147 add_subdirectory ( tests )
148 endif ( BUILD_TESTS )