-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
266 lines (234 loc) · 6.22 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
cmake_minimum_required(VERSION 3.5)
project(openelp C)
#
# Installation directories
#
set(SHARE_INSTALL_PREFIX "share" CACHE PATH
"Installation prefix for all application data"
)
set(BIN_INSTALL_DIR "bin" CACHE PATH
"Installation directory for all binaries"
)
set(INCLUDE_INSTALL_DIR "include" CACHE PATH
"Installation directory for all header files"
)
set(LIB_SUFFIX "" CACHE STRING
"Suffix appended for the library installation directory"
)
set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH
"Installation directory for all shared libraries"
)
if(WIN32)
set(SYSCONF_INSTALL_DIR "./" CACHE PATH
"Installation directory for all configuration files"
)
else()
set(SYSCONF_INSTALL_DIR "etc" CACHE PATH
"Installation directory for all configuration files"
)
endif()
set(MAN_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/man" CACHE PATH
"Installation directory for all manuals"
)
set(SYSTEMD_SERVICES_INSTALL_DIR "lib/systemd/system" CACHE PATH
"Installation directory for systemd services"
)
#
# Configuration Variables
#
# Make sure we have CMAKE_BUILD_TYPE set to something
if(NOT CMAKE_BUILD_TYPE)
list(GET CMAKE_CONFIGURATION_TYPES 0 CMAKE_BUILD_TYPE)
endif()
set(OPENELP_EXTRA_VERSION "dev" CACHE STRING
"Extra value suffixed to the version number"
)
if(IS_ABSOLUTE ${SYSCONF_INSTALL_DIR})
file(TO_CMAKE_PATH
"${SYSCONF_INSTALL_DIR}/ELProxy.conf"
OPENELP_CONFIG_HINT_DEFAULT)
elseif(IS_ABSOLUTE ${BIN_INSTALL_DIR})
file(RELATIVE_PATH OPENELP_CONFIG_HINT_DEFAULT
"${BIN_INSTALL_DIR}"
"${CMAKE_PREFIX_PATH}/${SYSCONF_INSTALL_DIR}/ELProxy.conf")
else()
file(RELATIVE_PATH OPENELP_CONFIG_HINT_DEFAULT
"${CMAKE_PREFIX_PATH}/${BIN_INSTALL_DIR}"
"${CMAKE_PREFIX_PATH}/${SYSCONF_INSTALL_DIR}/ELProxy.conf")
endif()
set(BUILD_SHARED_LIBS ON CACHE BOOL
"Indicates that any libraries which are produced should be shared (.dll/.so)"
)
set(OPENELP_DOC_INTERNAL FALSE CACHE BOOL
"Include internal code when documenting API"
)
set(OPENELP_USE_OPENSSL FALSE CACHE BOOL
"Use OpenSSL for MD5 computation instead of bundled md5.c"
)
set(OPENELP_CONFIG_HINT ${OPENELP_CONFIG_HINT_DEFAULT} CACHE PATH
"Hint path when searching for the proxy configuration file at runtime"
)
if(WIN32)
set(OPENELP_BUNDLE_PCRE TRUE CACHE BOOL
"Download and compile PCRE2 instead of using the system's libpcre2-32"
)
set(OPENELP_USE_EVENTLOG TRUE CACHE BOOL
"Enable support for logging to the Windows Event Log"
)
set(OPENELP_USE_SYSLOG FALSE CACHE BOOL
"Enable support for logging to SYSLOG"
)
set(OPENELP_DOC_HTMLHELP TRUE CACHE BOOL
"Enable generation of Windows CHM help"
)
else()
if(APPLE)
set(OPENELP_BUNDLE_PCRE TRUE CACHE BOOL
"Download and compile PCRE2 instead of using the system's libpcre2-32"
)
else()
set(OPENELP_BUNDLE_PCRE FALSE CACHE BOOL
"Download and compile PCRE2 instead of using the system's libpcre2-32"
)
endif()
set(OPENELP_USE_EVENTLOG FALSE CACHE BOOL
"Enable support for logging to the Windows Event Log"
)
set(OPENELP_USE_SYSLOG TRUE CACHE BOOL
"Enable support for logging to SYSLOG"
)
set(OPENELP_DOC_HTMLHELP FALSE CACHE BOOL
"Enable generation of Windows CHM help"
)
endif()
#
# Dependencies
#
if(OPENELP_BUNDLE_PCRE)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/BundlePCRE.cmake")
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(PCRE REQUIRED libpcre2-8)
endif()
if(OPENELP_USE_OPENSSL)
find_package(OpenSSL REQUIRED)
endif()
if(OPENELP_DOC_HTMLHELP)
find_program(OPENELP_DOC_HTMLHELP_PATH hhc
PATHS
"$ENV{ProgramW6432}\\HTML Help Workshop"
"$ENV{ProgramFiles}\\HTML Help Workshop"
DOC "HTML Help Compiler Command"
)
if(NOT OPENELP_DOC_HTMLHELP_PATH)
message(FATAL_ERROR "Failed to find HTML Help Compiler (hhc)")
endif()
endif()
if(MSVC)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT runtime)
include(InstallRequiredSystemLibraries)
endif()
#
# Variables
#
set(OPENELP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(OPENELP_DOC_DIR "${OPENELP_DIR}/doc")
set(OPENELP_INCLUDE_DIR "${OPENELP_DIR}/include")
set(OPENELP_PACKAGE_DIR "${OPENELP_DIR}/package")
set(OPENELP_SOURCE_DIR "${OPENELP_DIR}/src")
set(OPENELP_TEST_DIR "${OPENELP_DIR}/test")
set(OPENELP_MAJOR_VERSION 0)
set(OPENELP_MINOR_VERSION 9)
set(OPENELP_PATCH_VERSION 4)
set(OPENELP_VERSION
${OPENELP_MAJOR_VERSION}.${OPENELP_MINOR_VERSION}.${OPENELP_PATCH_VERSION})
if(OPENELP_EXTRA_VERSION)
set(OPENELP_VERSION "${OPENELP_VERSION}-${OPENELP_EXTRA_VERSION}")
endif()
#
# Flags
#
add_compile_options(
-DOPENELP_MAJOR_VERSION=${OPENELP_MAJOR_VERSION}
-DOPENELP_MINOR_VERSION=${OPENELP_MINOR_VERSION}
-DOPENELP_PATCH_VERSION=${OPENELP_PATCH_VERSION}
-DOPENELP_VERSION=${OPENELP_VERSION}
)
if(OPENELP_EXTRA_VERSION)
add_compile_options(
-DOPENELP_EXTRA_VERSION=${OPENELP_EXTRA_VERSION}
)
endif()
if(OPENELP_CONFIG_HINT)
add_compile_options(
-DOPENELP_CONFIG_HINT=${OPENELP_CONFIG_HINT}
)
endif()
add_compile_options(
-DPCRE2_CODE_UNIT_WIDTH=8
)
if(OPENELP_BUNDLE_PCRE)
add_compile_options(
-DPCRE2_STATIC=1
)
endif()
if(OPENELP_USE_EVENTLOG)
add_compile_options(
-DHAVE_EVENTLOG=1
)
endif()
if(OPENELP_USE_SYSLOG)
add_compile_options(
-DHAVE_SYSLOG=1
)
endif()
if(OPENELP_USE_OPENSSL)
add_compile_options(
-DHAVE_OPENSSL=1
)
endif()
if(WIN32)
add_compile_options(
/W3
/D_CRT_SECURE_NO_WARNINGS
/DWIN32_LEAN_AND_MEAN
)
else()
add_compile_options(
-Wall
-Wextra
-Wunused-macros
-Wunreachable-code
)
include(CheckCCompilerFlag)
check_c_compiler_flag(-Wpedantic HAVE_W_PEDANTIC)
if(HAVE_W_PEDANTIC)
add_compile_options(-Wpedantic)
endif()
check_c_compiler_flag(-Wint-conversion HAVE_W_INT_CONVERSION)
if(HAVE_W_INT_CONVERSION)
add_compile_options(-Wint-conversion)
endif()
endif()
# Default to C90
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 90)
endif()
#
# Link Dirs
#
link_directories(
${PCRE_LIBRARY_DIRS}
${OPENSSL_LIB_DIRS}
)
#
# Subdirs
#
add_subdirectory(${OPENELP_DOC_DIR})
add_subdirectory(${OPENELP_INCLUDE_DIR})
add_subdirectory(${OPENELP_SOURCE_DIR})
include(CTest)
if(BUILD_TESTING)
add_subdirectory(${OPENELP_TEST_DIR})
endif()
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Package.cmake")