-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
161 lines (129 loc) · 4 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
cmake_minimum_required(VERSION 3.12)
if(POLICY CMP0127)
cmake_policy(SET CMP0127 NEW)
endif()
project(
gross
VERSION 1.1.0
LANGUAGES C
)
set(VERSION_SUFFIX ~git)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(GNUInstallDirs)
include(CTest)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckSymbolExists)
include(CheckTypeSize)
include(CMakeDependentOption)
if(NOT CMAKE_C_BYTE_ORDER)
# cmake < 3.20
include(TestBigEndian)
test_big_endian(BIG_ENDIAN)
endif()
if(CMAKE_C_BYTE_ORDER STREQUAL "BIG_ENDIAN" OR BIG_ENDIAN)
add_compile_definitions(BIG_ENDIAN)
endif()
if(CMAKE_C_BYTE_ORDER STREQUAL "LITTLE_ENDIAN" OR NOT CMAKE_C_BYTE_ORDER AND NOT BIG_ENDIAN)
add_compile_definitions(LITTLE_ENDIAN)
endif()
find_library(MATH_LIBRARY m DOC "standard math library")
find_package(Threads REQUIRED)
if(NOT CMAKE_USE_PTHREADS_INIT)
message(SEND_ERROR "POSIX threads not found")
endif()
find_file(NETINET_IN_H "netinet/in.h")
if(NETINET_IN_H)
add_compile_definitions(HAVE_NETINET_IN_H)
endif()
check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
check_symbol_exists(CLOCK_HIRES "time.h" HAVE_CLOCK_HIRES)
check_symbol_exists(CLOCK_REALTIME "time.h" HAVE_CLOCK_REALTIME)
check_symbol_exists(gettimeofday "sys/time.h" HAVE_GETTIMEOFDAY)
if(HAVE_CLOCK_GETTIME)
if(HAVE_CLOCK_MONOTONIC)
add_compile_definitions(USE_CLOCK_MONOTONIC)
elseif(HAVE_CLOCK_HIRES)
add_compile_definitions(USE_CLOCK_HIRES)
elseif(HAVE_CLOCK_REALTIME)
add_compile_definitions(USE_CLOCK_REALTIME)
elseif(HAVE_GETTIMEOFDAY)
add_compile_definitions(USE_GETTIMEOFDAY)
else()
message(SEND_ERROR "no suitable clock type found")
endif()
elseif(HAVE_GETTIMEOFDAY)
add_compile_definitions(USE_GETTIMEOFDAY)
else()
message(SEND_ERROR "no suitable clock type found")
endif()
set(CMAKE_REQUIRED_INCLUDES "semaphore.h")
set(CMAKE_REQUIRED_LIBRARIES Threads::Threads)
check_function_exists(sem_init HAVE_SEM_INIT)
check_function_exists(sem_open HAVE_SEM_OPEN)
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_LIBRARIES)
if(HAVE_SEM_INIT)
elseif(HAVE_SEM_OPEN)
add_compile_definitions(USE_SEM_OPEN)
else()
message(SEND_ERROR "cannot compile without semaphores")
endif()
check_include_file("stdbool.h" HAVE_STDBOOL_H)
if(HAVE_STDBOOL_H)
add_compile_definitions(HAVE_STDBOOL_H)
endif()
set(CMAKE_EXTRA_INCLUDE_FILES "stdbool.h")
check_type_size(bool BOOL)
if(HAVE_BOOL)
add_compile_definitions(HAVE_BOOL)
endif()
check_include_file("stdatomic.h" HAVE_STDATOMIC_H)
if(HAVE_STDATOMIC_H)
set(CMAKE_EXTRA_INCLUDE_FILES "stdatomic.h")
check_type_size(atomic_bool ATOMIC_BOOL)
if(HAVE_ATOMIC_BOOL)
add_compile_definitions(HAVE_ATOMIC_BOOL)
else()
message(SEND_ERROR "type atomic_bool not defined")
endif()
else()
message(SEND_ERROR "stdatomic.h not found")
endif()
unset(CMAKE_EXTRA_INCLUDE_FILES)
set(CMAKE_EXTRA_INCLUDE_FILES "unistd.h")
check_type_size(useconds_t USECONDS_T)
if(HAVE_USECONDS_T)
add_compile_definitions(HAVE_USECONDS_T)
endif()
unset(CMAKE_EXTRA_INCLUDE_FILES)
find_package(c-ares)
find_package(Milter)
find_package(LibSpf2)
find_package(Asciidoctor)
if(NOT Asciidoctor_FOUND)
message(WARNING "asciidoctor not found, manual pages will not be built")
endif()
cmake_dependent_option(DNSBL "Enable DNSBL checking" ON c-ares_FOUND OFF)
cmake_dependent_option(SPF "Enable SPF checking" ON LibSpf2_FOUND OFF)
cmake_dependent_option(MILTER "Enable milter support" ON Milter_FOUND OFF)
cmake_dependent_option(BUILD_DOCS "Build documentation" ON Asciidoctor_FOUND OFF)
if(DNSBL)
add_compile_definitions(DNSBL)
endif()
if(MILTER)
add_compile_definitions(MILTER)
endif()
if(SPF)
add_compile_definitions(SPF)
endif()
add_compile_definitions(
CONFIGFILE=\"${CMAKE_INSTALL_FULL_SYSCONFDIR}/grossd.conf\"
VERSION=\"${CMAKE_PROJECT_VERSION}${VERSION_SUFFIX}\"
)
add_subdirectory("src")
add_subdirectory("man")
install(FILES doc/examples/grossd.conf
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}
)