]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/opentelemetry-cpp/third_party/prometheus-cpp/3rdparty/civetweb/CMakeLists.txt
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / third_party / prometheus-cpp / 3rdparty / civetweb / CMakeLists.txt
CommitLineData
1e59de90
TL
1# Use at least CMake 3.3
2cmake_minimum_required (VERSION 3.3.0)
3cmake_policy(VERSION 3.2.2)
4cmake_policy(SET CMP0054 NEW)
5
6# Set up the project
7project (civetweb)
8
9# Detect the platform reliably
10if(ZEPHYR_BASE)
11 if (NOT CONFIG_CIVETWEB)
12 return()
13 endif()
14 SET(ZEPHYR YES)
15elseif(NOT MACOSX AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
16 SET(DARWIN YES)
17elseif(NOT BSD AND ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
18 SET(FREEBSD YES)
19elseif(NOT LINUX AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
20 SET(LINUX YES)
21endif()
22
23# Do not allow in source builds
24set(CMAKE_DISABLE_SOURCE_CHANGES ON)
25set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
26
27# Make sure we can import out CMake functions
28list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
29
30# Load in the needed CMake modules
31include(CheckIncludeFiles)
32include(CheckCCompilerFlag)
33include(CheckCXXCompilerFlag)
34include(AddCCompilerFlag)
35include(AddCXXCompilerFlag)
36include(DetermineTargetArchitecture)
37include(CMakeDependentOption)
38
39set(CIVETWEB_VERSION "1.15.0" CACHE STRING "The version of the civetweb library")
40string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" CIVETWEB_VERSION_MATCH "${CIVETWEB_VERSION}")
41if ("${CIVETWEB_VERSION_MATCH}" STREQUAL "")
42 message(FATAL_ERROR "Must specify a semantic version: major.minor.patch")
43endif()
44set(CIVETWEB_VERSION_MAJOR "${CMAKE_MATCH_1}")
45set(CIVETWEB_VERSION_MINOR "${CMAKE_MATCH_2}")
46set(CIVETWEB_VERSION_PATCH "${CMAKE_MATCH_3}")
47determine_target_architecture(CIVETWEB_ARCHITECTURE)
48include(GNUInstallDirs)
49
50# CTest automation
51option(CIVETWEB_BUILD_TESTING "Enable automated testing of civetweb" ON)
52message(STATUS "Enabling tests in the build - ${CIVETWEB_BUILD_TESTING}")
53
54# C++ wrappers
55option(CIVETWEB_ENABLE_THIRD_PARTY_OUTPUT "Shows the output of third party dependency processing" OFF)
56
57# Thread Stack Size
58set(CIVETWEB_THREAD_STACK_SIZE 102400 CACHE STRING
59 "The stack size in bytes for each thread created")
60set_property(CACHE CIVETWEB_THREAD_STACK_SIZE PROPERTY VALUE ${CIVETWEB_THREAD_STACK_SIZE})
61message(STATUS "Thread Stack Size - ${CIVETWEB_THREAD_STACK_SIZE}")
62
63option(CIVETWEB_ENABLE_SERVER_EXECUTABLE "Enable building of the server executable" ON)
64message(STATUS "Enabling server executable - ${CIVETWEB_ENABLE_SERVER_EXECUTABLE}")
65
66# Serve no files from the web server
67option(CIVETWEB_SERVE_NO_FILES "Configures the server to serve no static files" OFF)
68message(STATUS "Serve no static files - ${CIVETWEB_SERVE_NO_FILES}")
69
70# Serve no files from the web server
71option(CIVETWEB_DISABLE_CGI "Disables CGI, so theserver will not execute CGI scripts" OFF)
72message(STATUS "Disable CGI support - ${CIVETWEB_DISABLE_CGI}")
73
74# Disable caching
75option(CIVETWEB_DISABLE_CACHING "Disables caching, so that no timegm is used." OFF)
76message(STATUS "Disable caching support - ${CIVETWEB_DISABLE_CACHING}")
77
78# C++ wrappers
79option(CIVETWEB_ENABLE_CXX "Enables the C++ wrapper library" OFF)
80message(STATUS "C++ wrappers - ${CIVETWEB_ENABLE_CXX}")
81
82# IP Version 6
83option(CIVETWEB_ENABLE_IPV6 "Enables the IP version 6 support" OFF)
84message(STATUS "IP Version 6 - ${CIVETWEB_ENABLE_IPV6}")
85
86# Websocket support
87option(CIVETWEB_ENABLE_WEBSOCKETS "Enable websockets connections" OFF)
88message(STATUS "Websockets support - ${CIVETWEB_ENABLE_WEBSOCKETS}")
89
90# Server statistics support
91option(CIVETWEB_ENABLE_SERVER_STATS "Enable server statistics" OFF)
92message(STATUS "Server statistics support - ${CIVETWEB_ENABLE_SERVER_STATS}")
93
94# Memory debugging
95option(CIVETWEB_ENABLE_MEMORY_DEBUGGING "Enable the memory debugging features" OFF)
96message(STATUS "Memory Debugging - ${CIVETWEB_ENABLE_MEMORY_DEBUGGING}")
97
98# ASAN in debug mode (-fsanitize=address, etc)
99option(CIVETWEB_ENABLE_ASAN "Enable ASAN in debug mode" ON)
100message(STATUS "ASAN in debug mode - ${CIVETWEB_ENABLE_ASAN}")
101
102# ARCH flag
103option(CIVETWEB_ARCH "Force 32/64 bit architecture" OFF)
104message(STATUS "Force x32 / x64 architecture - ${CIVETWEB_ARCH}")
105
106# LUA CGI support
107option(CIVETWEB_ENABLE_LUA "Enable Lua CGIs" OFF)
108message(STATUS "Lua CGI support - ${CIVETWEB_ENABLE_LUA}")
109
110# zlib compression support
111option(CIVETWEB_ENABLE_ZLIB "Enables zlib compression support" OFF)
112message(STATUS "zlib support - ${CIVETWEB_ENABLE_ZLIB}")
113
114# Enable installing CivetWeb executables
115option(CIVETWEB_INSTALL_EXECUTABLE "Enable installing CivetWeb executable" ON)
116mark_as_advanced(FORCE CIVETWEB_INSTALL_EXECUTABLE) # Advanced users can disable
117message(STATUS "Executable installation - ${CIVETWEB_INSTALL_EXECUTABLE}")
118
119# Allow builds to complete with warnings (do not set -Werror)
120# CivetWeb Linux support is stable:
121# Builds for GCC 4.6 and clang 3.4 are free from warnings.
122# However, GCC introduced a couple of new, partially idiotic warnings,
123# that can not be disabled using a #pragma directive.
124# It seems unreasonable to have all GCC versions warning free, but only
125# some selected ones.
126option(CIVETWEB_ALLOW_WARNINGS "Do not stop build if there are warnings" ON)
127message(STATUS "Build if there are warnings - ${CIVETWEB_ALLOW_WARNINGS}")
128
129if (NOT CIVETWEB_ALLOW_WARNINGS)
130 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
131 message(FATAL_ERROR "Cannot compile with warning as errors, until this GCC bug is solved: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431")
132 endif()
133endif()
134
135# Link to the shared LUA library
136cmake_dependent_option(
137 CIVETWEB_ENABLE_LUA_SHARED "Link to the shared LUA system library" OFF
138 CIVETWEB_ENABLE_LUA OFF)
139if (CIVETWEB_ENABLE_LUA)
140 message(STATUS "Linking shared Lua library - ${CIVETWEB_ENABLE_LUA_SHARED}")
141endif()
142
143# Lua Third Party Settings
144if (CIVETWEB_ENABLE_LUA)
145 if (NOT CIVETWEB_ENABLE_LUA_SHARED)
146 # Lua Version
147 set(CIVETWEB_LUA_VERSION 5.2.4 CACHE STRING
148 "The version of Lua to build and include statically")
149 set_property(CACHE CIVETWEB_LUA_VERSION PROPERTY VALUE ${CIVETWEB_LUA_VERSION})
150 message(STATUS "Lua Version - ${CIVETWEB_LUA_VERSION}")
151 mark_as_advanced(CIVETWEB_LUA_VERSION)
152
153 # Lua Verification Hash
154 set(CIVETWEB_LUA_MD5_HASH 913fdb32207046b273fdb17aad70be13 CACHE STRING
155 "The hash of Lua archive to be downloaded")
156 set_property(CACHE CIVETWEB_LUA_MD5_HASH PROPERTY VALUE ${CIVETWEB_LUA_MD5_HASH})
157 mark_as_advanced(CIVETWEB_LUA_MD5_HASH)
158 endif()
159
160 # Lua Filesystem Version
161 set(CIVETWEB_LUA_FILESYSTEM_VERSION 1.6.3 CACHE STRING
162 "The version of Lua Filesystem to build and include statically")
163 set_property(CACHE CIVETWEB_LUA_FILESYSTEM_VERSION PROPERTY VALUE ${CIVETWEB_LUA_FILESYSTEM_VERSION})
164 message(STATUS "Lua Filesystem Version - ${CIVETWEB_LUA_FILESYSTEM_VERSION}")
165 mark_as_advanced(CIVETWEB_LUA_FILESYSTEM_VERSION)
166
167 # Lua Filesystem Verification Hash
168 set(CIVETWEB_LUA_FILESYSTEM_MD5_HASH d0552c7e5a082f5bb2865af63fb9dc95 CACHE STRING
169 "The hash of Lua Filesystem archive to be downloaded")
170 set_property(CACHE CIVETWEB_LUA_FILESYSTEM_MD5_HASH PROPERTY VALUE ${CIVETWEB_LUA_FILESYSTEM_MD5_HASH})
171 mark_as_advanced(CIVETWEB_LUA_FILESYSTEM_MD5_HASH)
172
173 # Lua SQLite Version
174 set(CIVETWEB_LUA_SQLITE_VERSION 0.9.3 CACHE STRING
175 "The version of Lua SQLite to build and include statically")
176 set_property(CACHE CIVETWEB_LUA_SQLITE_VERSION PROPERTY VALUE ${CIVETWEB_LUA_SQLITE_VERSION})
177 message(STATUS "Lua SQLite Version - ${CIVETWEB_LUA_SQLITE_VERSION}")
178 mark_as_advanced(CIVETWEB_LUA_SQLITE_VERSION)
179
180 # Lua SQLite Verification Hash
181 set(CIVETWEB_LUA_SQLITE_MD5_HASH 43234ae08197dfce6da02482ed14ec92 CACHE STRING
182 "The hash of Lua SQLite archive to be downloaded")
183 set_property(CACHE CIVETWEB_LUA_SQLITE_MD5_HASH PROPERTY VALUE ${CIVETWEB_LUA_SQLITE_MD5_HASH})
184 mark_as_advanced(CIVETWEB_LUA_SQLITE_MD5_HASH)
185
186 # Lua XML Version
187 set(CIVETWEB_LUA_XML_VERSION 1.8.0 CACHE STRING
188 "The version of Lua XML to build and include statically")
189 set_property(CACHE CIVETWEB_LUA_XML_VERSION PROPERTY VALUE ${CIVETWEB_LUA_XML_VERSION})
190 message(STATUS "Lua XML Version - ${CIVETWEB_LUA_XML_VERSION}")
191 mark_as_advanced(CIVETWEB_LUA_XML_VERSION)
192
193 # Lua XML Verification Hash
194 set(CIVETWEB_LUA_XML_MD5_HASH 25e4c276c5d8716af1de0c7853aec2b4 CACHE STRING
195 "The hash of Lua XML archive to be downloaded")
196 set_property(CACHE CIVETWEB_LUA_XML_MD5_HASH PROPERTY VALUE ${CIVETWEB_LUA_XML_MD5_HASH})
197 mark_as_advanced(CIVETWEB_LUA_XML_MD5_HASH)
198
199 # SQLite Version
200 set(CIVETWEB_SQLITE_VERSION 3.8.9 CACHE STRING
201 "The version of SQLite to build and include statically")
202 set_property(CACHE CIVETWEB_SQLITE_VERSION PROPERTY VALUE ${CIVETWEB_SQLITE_VERSION})
203 message(STATUS "SQLite Version - ${CIVETWEB_SQLITE_VERSION}")
204 mark_as_advanced(CIVETWEB_SQLITE_VERSION)
205
206 # SQLite Verification Hash
207 set(CIVETWEB_SQLITE_MD5_HASH 02e9c3a6daa8b8587cf6bef828c2e33f CACHE STRING
208 "The hash of SQLite archive to be downloaded")
209 set_property(CACHE CIVETWEB_SQLITE_MD5_HASH PROPERTY VALUE ${CIVETWEB_SQLITE_MD5_HASH})
210 mark_as_advanced(CIVETWEB_SQLITE_MD5_HASH)
211endif()
212
213# Duktape CGI support
214option(CIVETWEB_ENABLE_DUKTAPE "Enable Duktape CGIs" OFF)
215message(STATUS "Duktape CGI support - ${CIVETWEB_ENABLE_DUKTAPE}")
216
217# SSL support
218option(CIVETWEB_ENABLE_SSL "Enables the secure socket layer" ON)
219message(STATUS "SSL support - ${CIVETWEB_ENABLE_SSL}")
220
221# OpenSSL 1.0 API
222option(CIVETWEB_SSL_OPENSSL_API_1_0 "Use the OpenSSL 1.0 API" OFF)
223message(STATUS "Compile for OpenSSL 1.0 API - ${CIVETWEB_SSL_OPENSSL_API_1_0}")
224
225# OpenSSL 1.1 API
226option(CIVETWEB_SSL_OPENSSL_API_1_1 "Use the OpenSSL 1.1 API" ON)
227message(STATUS "Compile for OpenSSL 1.1 API - ${CIVETWEB_SSL_OPENSSL_API_1_1}")
228
229# Dynamically load or link the SSL libraries
230cmake_dependent_option(
231 CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING "Dynamically loads the SSL library rather than linking it" ON
232 CIVETWEB_ENABLE_SSL OFF)
233if (CIVETWEB_ENABLE_SSL)
234 message(STATUS "Dynamically load SSL libraries - ${CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING}")
235endif()
236
237# Link time optimization
238option(CIVETWEB_ENABLE_LTO "Enable link time optimization" OFF)
239if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
240 "${BUILD_SHARED_LIBS}" STREQUAL "SHARED" OR
241 ${CMAKE_CXX_COMPILER_VERSION} GREATER 5)
242 option(CIVETWEB_CXX_ENABLE_LTO "Enable link time optimization for the C++ wrapper library" ON)
243else()
244 option(CIVETWEB_CXX_ENABLE_LTO "Enable link time optimization for the C++ wrapper library" OFF)
245endif()
246
247# Third Party Download location
248set(CIVETWEB_THIRD_PARTY_DIR "${CMAKE_BINARY_DIR}/third_party" CACHE STRING
249 "The location that third party code is downloaded, built and installed")
250set_property(CACHE CIVETWEB_THIRD_PARTY_DIR PROPERTY VALUE ${CIVETWEB_THIRD_PARTY_DIR})
251
252# Unix systems can define the dynamic library names to load
253if (CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING AND NOT DARWIN AND UNIX)
254 # SSL library name
255 set(CIVETWEB_SSL_SSL_LIB "libssl.so" CACHE STRING
256 "The name of the SSL library to load")
257 set_property(CACHE CIVETWEB_SSL_SSL_LIB PROPERTY VALUE ${CIVETWEB_SSL_SSL_LIB})
258 message(STATUS "SSL Library Name - ${CIVETWEB_SSL_SSL_LIB}")
259
260 # Crytography library name
261 set(CIVETWEB_SSL_CRYPTO_LIB "libcrypto.so" CACHE STRING
262 "The name of the SSL Cryptography library to load")
263 set_property(CACHE CIVETWEB_SSL_CRYPTO_LIB PROPERTY VALUE ${CIVETWEB_SSL_CRYPTO_LIB})
264 message(STATUS "SSL Cryptography Library Name - ${CIVETWEB_SSL_CRYPTO_LIB}")
265endif()
266
267# Allow warnings in 3rd party components
268if (CIVETWEB_ENABLE_LUA OR CIVETWEB_ENABLE_DUKTAPE)
269SET(CIVETWEB_ALLOW_WARNINGS YES)
270endif()
271
272# The C and C++ standards to use
273set(CIVETWEB_C_STANDARD auto CACHE STRING
274 "The C standard to use; auto determines the latest supported by the compiler")
275set_property(CACHE CIVETWEB_C_STANDARD PROPERTY STRINGS auto c11 c99 c89)
276set(CIVETWEB_CXX_STANDARD auto CACHE STRING
277 "The C++ standard to use; auto determines the latest supported by the compiler")
278set_property(CACHE CIVETWEB_CXX_STANDARD PROPERTY STRINGS auto c++14 c++11 c++98)
279
280# Configure the linker
281if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
282 find_program(GCC_AR gcc-ar)
283 if (GCC_AR)
284 set(CMAKE_AR ${GCC_AR})
285 endif()
286 find_program(GCC_RANLIB gcc-ranlib)
287 if (GCC_RANLIB)
288 set(CMAKE_RANLIB ${GCC_RANLIB})
289 endif()
290endif()
291
292# Configure the C compiler
293message(STATUS "Configuring C Compiler")
294if ("${CIVETWEB_C_STANDARD}" STREQUAL "auto")
295 add_c_compiler_flag(-std=c11)
296 if (NOT HAVE_C_FLAG_STD_C11)
297 add_c_compiler_flag(-std=c99)
298 if (NOT HAVE_C_FLAG_STD_C99)
299 add_c_compiler_flag(-std=c89)
300 endif()
301 endif()
302else()
303 add_c_compiler_flag(-std=${CIVETWEB_C_STANDARD})
304endif()
305
306if (MINGW)
307 add_c_compiler_flag(-Wno-format)
308endif()
309if (NOT CIVETWEB_ALLOW_WARNINGS)
310 add_c_compiler_flag(-Werror)
311 add_c_compiler_flag(/WX)
312endif()
313if (${CIVETWEB_ENABLE_LTO})
314 add_c_compiler_flag(-flto RELEASE)
315endif()
316if (${CIVETWEB_ENABLE_ASAN})
317add_c_compiler_flag(-fsanitize=undefined DEBUG)
318add_c_compiler_flag(-fsanitize=address DEBUG)
319if (HAVE_C_FLAG_FSANITIZE_ADDRESS)
320 add_c_compiler_flag(-static-asan DEBUG)
321endif()
322endif()
323if (MINGW)
324 add_c_compiler_flag(-mwindows)
325endif()
326
327# Coverage build type
328set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING
329 "Flags used by the C compiler during coverage builds."
330 FORCE)
331set(CMAKE_EXE_LINKER_FLAGS_COVERAGE
332 "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
333 "Flags used for linking binaries during coverage builds."
334 FORCE)
335set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
336 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
337 "Flags used by the shared libraries linker during coverage builds."
338 FORCE)
339mark_as_advanced(
340 CMAKE_CXX_FLAGS_COVERAGE
341 CMAKE_C_FLAGS_COVERAGE
342 CMAKE_EXE_LINKER_FLAGS_COVERAGE
343 CMAKE_SHARED_LINKER_FLAGS_COVERAGE)
344set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
345 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage."
346 FORCE)
347add_c_compiler_flag(--coverage COVERAGE)
348
349# Configure the C++ compiler
350if (CIVETWEB_ENABLE_CXX)
351 message(STATUS "Configuring C++ Compiler")
352 if ("${CIVETWEB_CXX_STANDARD}" STREQUAL "auto")
353 add_cxx_compiler_flag(-std=c++14)
354 if (NOT HAVE_CXX_FLAG_STD_CXX14)
355 add_cxx_compiler_flag(-std=c++11)
356 if (NOT HAVE_CXX_FLAG_STD_CXX11)
357 add_cxx_compiler_flag(-std=c++98)
358 endif()
359 endif()
360 else()
361 add_cxx_compiler_flag(-std=${CIVETWEB_CXX_STANDARD})
362 endif()
363 add_cxx_compiler_flag(-Wall)
364 add_cxx_compiler_flag(-Wextra)
365 add_cxx_compiler_flag(-Wshadow)
366 add_cxx_compiler_flag(-Wmissing-prototypes)
367 add_cxx_compiler_flag(-Weverything)
368 add_cxx_compiler_flag(/W4)
369 add_cxx_compiler_flag(-Wno-padded)
370 add_cxx_compiler_flag(/Wd4820) # padding
371 add_cxx_compiler_flag(-Wno-unused-macros)
372 add_cxx_compiler_flag(-Wno-format-nonliteral)
373 if (MINGW)
374 add_cxx_compiler_flag(-Wno-format)
375 endif()
376 if (NOT CIVETWEB_ALLOW_WARNINGS)
377 add_cxx_compiler_flag(-Werror)
378 add_cxx_compiler_flag(/WX)
379 endif()
380 add_cxx_compiler_flag(-pedantic-errors)
381 add_cxx_compiler_flag(-fvisibility=hidden)
382 add_cxx_compiler_flag(-fstack-protector-strong RELEASE)
383
384 if (${CIVETWEB_CXX_ENABLE_LTO})
385 add_cxx_compiler_flag(-flto RELEASE)
386 endif()
387 if (${CIVETWEB_ENABLE_ASAN})
388 add_cxx_compiler_flag(-fsanitize=undefined DEBUG)
389 add_cxx_compiler_flag(-fsanitize=address DEBUG)
390 if (HAVE_CXX_FLAG_FSANITIZE_ADDRESS)
391 add_cxx_compiler_flag(-static-asan DEBUG)
392 endif()
393 endif()
394 add_cxx_compiler_flag(-fstack-protector-all DEBUG)
395 if (MINGW)
396 add_cxx_compiler_flag(-mwindows)
397 endif()
398 set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
399 "Flags used by the C++ compiler during coverage builds."
400 FORCE)
401 add_cxx_compiler_flag(--coverage COVERAGE)
402endif()
403
404if (NOT ZEPHYR)
405 #Warnings: enable everything
406 add_c_compiler_flag(-Wall)
407 add_c_compiler_flag(-Wextra)
408 add_c_compiler_flag(-Wshadow)
409 add_c_compiler_flag(-Wconversion)
410 add_c_compiler_flag(-Wmissing-prototypes)
411 add_c_compiler_flag(-Weverything)
412 add_c_compiler_flag(-Wparentheses)
413 add_c_compiler_flag(/W4) # VisualStudio highest warning level
414
415 #Warnings: Disable some warnings
416 add_c_compiler_flag(-Wno-padded) # padding in structures by compiler
417 add_c_compiler_flag(-Wno-unused-macros) # so what?
418 Check_C_Compiler_Flag( HAVE_NO_RESERVED_ID_MACROS -Wno-reserved-id-macros)
419 if (HAVE_NO_RESERVED_ID_MACROS)
420 add_c_compiler_flag(-Wno-reserved-id-macros) # for system headers
421 endif (HAVE_NO_RESERVED_ID_MACROS)
422 add_c_compiler_flag(-Wno-format-nonliteral) # printf(myFormatStringVar, ...)
423 add_c_compiler_flag(-Wno-cast-qual) # const cast
424 add_c_compiler_flag(/Wd4820) # padding
425
426 add_c_compiler_flag(-pedantic-errors)
427 add_c_compiler_flag(-fvisibility=hidden)
428 add_c_compiler_flag(-fstack-protector-strong RELEASE)
429 add_c_compiler_flag(-fstack-protector-all DEBUG)
430else()
431 # This policy is needed to override options with variables
432 cmake_policy(SET CMP0077 NEW)
433
434 # Configure what you need/support in Zephyr
435 set(CIVETWEB_SERVE_NO_FILES ON)
436 set(CIVETWEB_SERVE_NO_FILESYSTEMS ON)
437 set(CIVETWEB_DISABLE_CGI ON)
438 set(CIVETWEB_DISABLE_CACHING ON)
439 set(CIVETWEB_ENABLE_SSL OFF)
440 set(CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING OFF)
441
442 set(CIVETWEB_ENABLE_LUA OFF)
443 set(CIVETWEB_ENABLE_DUKTAPE OFF)
444 set(CIVETWEB_ENABLE_MEMORY_DEBUGGING OFF)
445 set(CIVETWEB_ENABLE_SERVER_EXECUTABLE OFF)
446 set(CIVETWEB_ENABLE_ASAN OFF)
447 set(CIVETWEB_INSTALL_EXECUTABLE OFF)
448
449 set(CIVETWEB_THREAD_STACK_SIZE 0)
450
451 set(BUILD_SHARED_LIBS OFF)
452
453 add_definitions(-DMG_EXTERNAL_FUNCTION_mg_cry_internal_impl)
454 add_definitions(-DMG_EXTERNAL_FUNCTION_log_access)
455
456 add_definitions(-DNO_ALTERNATIVE_QUEUE)
457 add_definitions(-DZEPHYR_VERSION=${KERNEL_VERSION_STRING})
458
459 zephyr_interface_library_named(CIVETWEB)
460
461 target_include_directories(CIVETWEB INTERFACE src)
462 target_include_directories(CIVETWEB INTERFACE include)
463 target_include_directories(CIVETWEB INTERFACE ${CMAKE_SOURCE_DIR}/src)
464
465 zephyr_include_directories(include)
466
467 zephyr_library()
468 zephyr_library_sources(
469 src/civetweb.c
470 )
471
472 zephyr_library_link_libraries(CIVETWEB)
473 target_link_libraries(CIVETWEB INTERFACE zephyr_interface)
474endif()
475
476
477# Set up the definitions
478option(CIVETWEB_ENABLE_DEBUG_TOOLS "For Debug builds enable verbose logging and assertions" ON)
479if (${CMAKE_BUILD_TYPE} MATCHES "[Dd]ebug")
480 if(CIVETWEB_ENABLE_DEBUG_TOOLS)
481 add_definitions(-DDEBUG)
482 endif()
483 add_definitions(-O0)
484 add_definitions(-g)
485endif()
486if (CIVETWEB_ENABLE_IPV6)
487 add_definitions(-DUSE_IPV6)
488endif()
489if (CIVETWEB_ENABLE_WEBSOCKETS)
490 add_definitions(-DUSE_WEBSOCKET)
491endif()
492if (CIVETWEB_ENABLE_SERVER_STATS)
493 add_definitions(-DUSE_SERVER_STATS)
494endif()
495if (CIVETWEB_SERVE_NO_FILES)
496 add_definitions(-DNO_FILES)
497endif()
498if (CIVETWEB_SERVE_NO_FILESYSTEMS)
499 add_definitions(-DNO_FILESYSTEMS)
500endif()
501if (CIVETWEB_DISABLE_CGI)
502 add_definitions(-DNO_CGI)
503endif()
504if (CIVETWEB_DISABLE_CACHING)
505 add_definitions(-DNO_CACHING)
506endif()
507if (CIVETWEB_ENABLE_LUA)
508 add_definitions(-DUSE_LUA)
509endif()
510if (CIVETWEB_ENABLE_ZLIB)
511 add_definitions(-DUSE_ZLIB)
512endif()
513if (CIVETWEB_ENABLE_DUKTAPE)
514 add_definitions(-DUSE_DUKTAPE)
515endif()
516if (CIVETWEB_ENABLE_MEMORY_DEBUGGING)
517 add_definitions(-DMEMORY_DEBUGGING)
518endif()
519if (NOT CIVETWEB_ENABLE_SSL)
520 add_definitions(-DNO_SSL)
521elseif (NOT CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING)
522 add_definitions(-DNO_SSL_DL)
523else()
524 if(CIVETWEB_SSL_SSL_LIB)
525 add_definitions(-DSSL_LIB="${CIVETWEB_SSL_SSL_LIB}")
526 endif()
527 if(CIVETWEB_SSL_CRYPTO_LIB)
528 add_definitions(-DCRYPTO_LIB="${CIVETWEB_SSL_CRYPTO_LIB}")
529 endif()
530endif()
531
532if(CIVETWEB_SSL_OPENSSL_API_1_0)
533 add_definitions(-DOPENSSL_API_1_0)
534endif()
535if(CIVETWEB_SSL_OPENSSL_API_1_1)
536 add_definitions(-DOPENSSL_API_1_1)
537endif()
538if(CIVETWEB_SSL_OPENSSL_API_1_0 AND CIVETWEB_SSL_OPENSSL_API_1_1)
539 message(FATAL_ERROR "Multiple SSL API versions defined")
540endif()
541
542add_definitions(-DUSE_STACK_SIZE=${CIVETWEB_THREAD_STACK_SIZE})
543
544# Set 32 or 64 bit environment
545if (${CMAKE_ARCH} MATCHES "[Xx]86")
546add_c_compiler_flag(-m32)
547endif()
548if (${CMAKE_ARCH} MATCHES "[Xx]64")
549add_c_compiler_flag(-m64)
550endif()
551# TODO: add support for -march
552
553if (ZEPHYR)
554 return()
555endif()
556
557# Build the targets
558add_subdirectory(src)
559
560# Enable the testing of the library/executable
561include(CTest)
562if (CIVETWEB_BUILD_TESTING)
563 # Check unit testing framework Version
564 set(CIVETWEB_CHECK_VERSION 0.11.0 CACHE STRING
565 "The version of Check unit testing framework to build and include statically")
566 set_property(CACHE CIVETWEB_CHECK_VERSION PROPERTY VALUE ${CIVETWEB_CHECK_VERSION})
567 message(STATUS "Check Unit Testing Framework Version - ${CIVETWEB_CHECK_VERSION}")
568 mark_as_advanced(CIVETWEB_CHECK_VERSION)
569
570 # Check unit testing framework Verification Hash
571 # Hash for Check 0.10.0: 67a34c40b5bc888737f4e5ae82e9939f
572 # Hash for Check 0.11.0: 1b14ee307dca8e954a8219c34484d7c4
573 set(CIVETWEB_CHECK_MD5_HASH 1b14ee307dca8e954a8219c34484d7c4 CACHE STRING
574 "The hash of Check unit testing framework archive to be downloaded")
575 set_property(CACHE CIVETWEB_CHECK_MD5_HASH PROPERTY VALUE ${CIVETWEB_CHECK_MD5_HASH})
576 mark_as_advanced(CIVETWEB_CHECK_MD5_HASH)
577
578 # Build the testing
579 add_subdirectory(unittest)
580endif()
581
582# cmake config file
583
584include(CMakePackageConfigHelpers)
585
586install(
587 EXPORT ${PROJECT_NAME}-targets
588 NAMESPACE ${PROJECT_NAME}::
589 FILE ${PROJECT_NAME}-targets.cmake
590 DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
591 COMPONENT civetweb-cmake-config
592)
593
594configure_package_config_file(
595 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake.in"
596 ${PROJECT_NAME}-config.cmake
597 INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
598 NO_CHECK_REQUIRED_COMPONENTS_MACRO
599 PATH_VARS CMAKE_INSTALL_INCLUDEDIR
600)
601
602write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake
603 VERSION ${CIVETWEB_VERSION}
604 COMPATIBILITY AnyNewerVersion
605)
606
607install(
608 FILES
609 "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
610 "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
611 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindLibDl.cmake"
612 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindLibRt.cmake"
613 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindWinSock.cmake"
614 DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
615 COMPONENT civetweb-cmake-config
616)
617
618# Set up CPack
619include(InstallRequiredSystemLibraries)
620set(CPACK_PACKAGE_VENDOR "civetweb Contributors")
621set(CPACK_PACKAGE_CONTACT "civetweb@users.noreply.github.com")
622set(CPACK_PACKAGE_VERSION_MAJOR "${CIVETWEB_VERSION_MAJOR}")
623set(CPACK_PACKAGE_VERSION_MINOR "${CIVETWEB_VERSION_MINOR}")
624set(CPACK_PACKAGE_VERSION_PATCH "${CIVETWEB_VERSION_PATCH}")
625set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A HTTP library and server")
626set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
627set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md")
628set(CPACK_STRIP_FILES TRUE)
629set(CPACK_PACKAGE_DEPENDS "openssl")
630if (CIVETWEB_ENABLE_LUA_SHARED)
631 set(CPACK_PACKAGE_DEPENDS "lua, ${CPACK_PACKAGE_DEPENDS}")
632endif()
633
634# RPM Packaging
635set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
636set(CPACK_RPM_PACKAGE_LICENSE "MIT")
637set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CIVETWEB_ARCHITECTURE}")
638set(CPACK_RPM_PACKAGE_REQUIRES "${CPACK_PACKAGE_DEPENDS}")
639
640# Debian Packaging
641set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CIVETWEB_ARCHITECTURE}")
642set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/civetweb/civetweb")
643set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_PACKAGE_DEPENDS}")
644
645# WiX Packaging
646# TODO: www.cmake.org/cmake/help/v3.0/module/CPackWIX.html
647
648# Finalize CPack settings
649include(CPack)
650