]> git.proxmox.com Git - ceph.git/blame - ceph/src/civetweb/CMakeLists.txt
buildsys: switch source download to quincy
[ceph.git] / ceph / src / civetweb / CMakeLists.txt
CommitLineData
7c673cae
FG
1# Determines what CMake APIs we can rely on
2cmake_minimum_required (VERSION 2.8.11)
3if (${CMAKE_VERSION} VERSION_GREATER 3.2.2)
4 cmake_policy(VERSION 3.2.2)
5endif()
6if (${CMAKE_VERSION} VERSION_GREATER 3.1 OR
7 ${CMAKE_VERSION} VERSION_EQUAL 3.1)
8 cmake_policy(SET CMP0054 NEW)
9endif()
10
11# Do not allow in source builds
12set(CMAKE_DISABLE_SOURCE_CHANGES ON)
13set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
14
15# Make sure we can import out CMake functions
16list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
17
18# Load in the needed CMake modules
19include(CheckIncludeFiles)
20include(CheckCCompilerFlag)
21include(CheckCXXCompilerFlag)
22include(AddCCompilerFlag)
23include(AddCXXCompilerFlag)
24include(DetermineTargetArchitecture)
25include(CMakeDependentOption)
26
27# Set up the project
28project (civetweb)
11fdf7f2 29set(CIVETWEB_VERSION "1.10.0" CACHE STRING "The version of the civetweb library")
7c673cae
FG
30string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" CIVETWEB_VERSION_MATCH "${CIVETWEB_VERSION}")
31if ("${CIVETWEB_VERSION_MATCH}" STREQUAL "")
32 message(FATAL_ERROR "Must specify a semantic version: major.minor.patch")
33endif()
34set(CIVETWEB_VERSION_MAJOR "${CMAKE_MATCH_1}")
35set(CIVETWEB_VERSION_MINOR "${CMAKE_MATCH_2}")
36set(CIVETWEB_VERSION_PATCH "${CMAKE_MATCH_3}")
37determine_target_architecture(CIVETWEB_ARCHITECTURE)
38
39# Detect the platform reliably
40if(NOT MACOSX AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
41 SET(DARWIN YES)
42elseif(NOT BSD AND ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
43 SET(FREEBSD YES)
44elseif(NOT LINUX AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
45 SET(LINUX YES)
46endif()
47
48# C++ wrappers
49option(CIVETWEB_ENABLE_THIRD_PARTY_OUTPUT "Shows the output of third party dependency processing" OFF)
50
7c673cae
FG
51# Thread Stack Size
52set(CIVETWEB_THREAD_STACK_SIZE 102400 CACHE STRING
53 "The stack size in bytes for each thread created")
54set_property(CACHE CIVETWEB_THREAD_STACK_SIZE PROPERTY VALUE ${CIVETWEB_THREAD_STACK_SIZE})
55message(STATUS "Thread Stack Size - ${CIVETWEB_THREAD_STACK_SIZE}")
56
57# Serve no files from the web server
58option(CIVETWEB_SERVE_NO_FILES "Configures the server to serve no static files" OFF)
59message(STATUS "Serve no static files - ${CIVETWEB_SERVE_NO_FILES}")
60
61# Serve no files from the web server
62option(CIVETWEB_DISABLE_CGI "Disables CGI, so theserver will not execute CGI scripts" OFF)
63message(STATUS "Disable CGI support - ${CIVETWEB_DISABLE_CGI}")
64
65# Disable caching
66option(CIVETWEB_DISABLE_CACHING "Disables caching, so that no timegm is used." OFF)
67message(STATUS "Disable caching support - ${CIVETWEB_DISABLE_CACHING}")
68
69# C++ wrappers
70option(CIVETWEB_ENABLE_CXX "Enables the C++ wrapper library" OFF)
71message(STATUS "C++ wrappers - ${CIVETWEB_ENABLE_CXX}")
72
73# IP Version 6
74option(CIVETWEB_ENABLE_IPV6 "Enables the IP version 6 support" OFF)
75message(STATUS "IP Version 6 - ${CIVETWEB_ENABLE_IPV6}")
76
77# Websocket support
78option(CIVETWEB_ENABLE_WEBSOCKETS "Enable websockets connections" OFF)
79message(STATUS "Websockets support - ${CIVETWEB_ENABLE_WEBSOCKETS}")
80
11fdf7f2
TL
81# Server statistics support
82option(CIVETWEB_ENABLE_SERVER_STATS "Enable server statistics" OFF)
83message(STATUS "Server statistics support - ${CIVETWEB_ENABLE_SERVER_STATS}")
84
7c673cae
FG
85# Memory debugging
86option(CIVETWEB_ENABLE_MEMORY_DEBUGGING "Enable the memory debugging features" OFF)
87message(STATUS "Memory Debugging - ${CIVETWEB_ENABLE_MEMORY_DEBUGGING}")
88
11fdf7f2
TL
89# ASAN in debug mode (-fsanitize=address, etc)
90option(CIVETWEB_ENABLE_ASAN "Enable ASAN in debug mode" ON)
91message(STATUS "ASAN in debug mode - ${CIVETWEB_ENABLE_ASAN}")
92
93# ARCH flag
94option(CIVETWEB_ARCH "Force 32/64 bit architecture" OFF)
95message(STATUS "Force x32 / x64 architecture - ${CIVETWEB_ARCH}")
96
7c673cae
FG
97# LUA CGI support
98option(CIVETWEB_ENABLE_LUA "Enable Lua CGIs" OFF)
99message(STATUS "Lua CGI support - ${CIVETWEB_ENABLE_LUA}")
100
11fdf7f2
TL
101# Enable installing CivetWeb executables
102option(CIVETWEB_INSTALL_EXECUTABLE "Enable installing CivetWeb executable" ON)
103mark_as_advanced(FORCE CIVETWEB_INSTALL_EXECUTABLE) # Advanced users can disable
104message(STATUS "Executable installation - ${CIVETWEB_INSTALL_EXECUTABLE}")
105
7c673cae 106# Allow builds to complete with warnings (do not set -Werror)
11fdf7f2
TL
107# CivetWeb Linux support is stable:
108# Builds for GCC 4.6 and clang 3.4 are free from warnings.
109# However, GCC introduced a couple of new, partially idiotic warnings,
110# that can not be disabled using a #pragma directive.
111# It seems unreasonable to have all GCC versions warning free, but only
112# some selected ones.
113option(CIVETWEB_ALLOW_WARNINGS "Do not stop build if there are warnings" ON)
7c673cae
FG
114message(STATUS "Build if there are warnings - ${CIVETWEB_ALLOW_WARNINGS}")
115
116# Link to the shared LUA library
117cmake_dependent_option(
118 CIVETWEB_ENABLE_LUA_SHARED "Link to the shared LUA system library" OFF
119 CIVETWEB_ENABLE_LUA OFF)
120if (CIVETWEB_ENABLE_LUA)
121 message(STATUS "Linking shared Lua library - ${CIVETWEB_ENABLE_LUA_SHARED}")
122endif()
123
124# Lua Third Party Settings
125if (CIVETWEB_ENABLE_LUA)
126 if (NOT CIVETWEB_ENABLE_LUA_SHARED)
127 # Lua Version
128 set(CIVETWEB_LUA_VERSION 5.2.4 CACHE STRING
129 "The version of Lua to build and include statically")
130 set_property(CACHE CIVETWEB_LUA_VERSION PROPERTY VALUE ${CIVETWEB_LUA_VERSION})
131 message(STATUS "Lua Version - ${CIVETWEB_LUA_VERSION}")
132 mark_as_advanced(CIVETWEB_LUA_VERSION)
133
134 # Lua Verification Hash
135 set(CIVETWEB_LUA_MD5_HASH 913fdb32207046b273fdb17aad70be13 CACHE STRING
136 "The hash of Lua archive to be downloaded")
137 set_property(CACHE CIVETWEB_LUA_MD5_HASH PROPERTY VALUE ${CIVETWEB_LUA_MD5_HASH})
138 mark_as_advanced(CIVETWEB_LUA_MD5_HASH)
139 endif()
140
141 # Lua Filesystem Version
142 set(CIVETWEB_LUA_FILESYSTEM_VERSION 1.6.3 CACHE STRING
143 "The version of Lua Filesystem to build and include statically")
144 set_property(CACHE CIVETWEB_LUA_FILESYSTEM_VERSION PROPERTY VALUE ${CIVETWEB_LUA_FILESYSTEM_VERSION})
145 message(STATUS "Lua Filesystem Version - ${CIVETWEB_LUA_FILESYSTEM_VERSION}")
146 mark_as_advanced(CIVETWEB_LUA_FILESYSTEM_VERSION)
147
148 # Lua Filesystem Verification Hash
149 set(CIVETWEB_LUA_FILESYSTEM_MD5_HASH d0552c7e5a082f5bb2865af63fb9dc95 CACHE STRING
150 "The hash of Lua Filesystem archive to be downloaded")
151 set_property(CACHE CIVETWEB_LUA_FILESYSTEM_MD5_HASH PROPERTY VALUE ${CIVETWEB_LUA_FILESYSTEM_MD5_HASH})
152 mark_as_advanced(CIVETWEB_LUA_FILESYSTEM_MD5_HASH)
153
154 # Lua SQLite Version
155 set(CIVETWEB_LUA_SQLITE_VERSION 0.9.3 CACHE STRING
156 "The version of Lua SQLite to build and include statically")
157 set_property(CACHE CIVETWEB_LUA_SQLITE_VERSION PROPERTY VALUE ${CIVETWEB_LUA_SQLITE_VERSION})
158 message(STATUS "Lua SQLite Version - ${CIVETWEB_LUA_SQLITE_VERSION}")
159 mark_as_advanced(CIVETWEB_LUA_SQLITE_VERSION)
160
161 # Lua SQLite Verification Hash
162 set(CIVETWEB_LUA_SQLITE_MD5_HASH 43234ae08197dfce6da02482ed14ec92 CACHE STRING
163 "The hash of Lua SQLite archive to be downloaded")
164 set_property(CACHE CIVETWEB_LUA_SQLITE_MD5_HASH PROPERTY VALUE ${CIVETWEB_LUA_SQLITE_MD5_HASH})
165 mark_as_advanced(CIVETWEB_LUA_SQLITE_MD5_HASH)
166
167 # Lua XML Version
168 set(CIVETWEB_LUA_XML_VERSION 1.8.0 CACHE STRING
169 "The version of Lua XML to build and include statically")
170 set_property(CACHE CIVETWEB_LUA_XML_VERSION PROPERTY VALUE ${CIVETWEB_LUA_XML_VERSION})
171 message(STATUS "Lua XML Version - ${CIVETWEB_LUA_XML_VERSION}")
172 mark_as_advanced(CIVETWEB_LUA_XML_VERSION)
173
174 # Lua XML Verification Hash
175 set(CIVETWEB_LUA_XML_MD5_HASH 25e4c276c5d8716af1de0c7853aec2b4 CACHE STRING
176 "The hash of Lua XML archive to be downloaded")
177 set_property(CACHE CIVETWEB_LUA_XML_MD5_HASH PROPERTY VALUE ${CIVETWEB_LUA_XML_MD5_HASH})
178 mark_as_advanced(CIVETWEB_LUA_XML_MD5_HASH)
179
180 # SQLite Version
181 set(CIVETWEB_SQLITE_VERSION 3.8.9 CACHE STRING
182 "The version of SQLite to build and include statically")
183 set_property(CACHE CIVETWEB_SQLITE_VERSION PROPERTY VALUE ${CIVETWEB_SQLITE_VERSION})
184 message(STATUS "SQLite Version - ${CIVETWEB_SQLITE_VERSION}")
185 mark_as_advanced(CIVETWEB_SQLITE_VERSION)
186
187 # SQLite Verification Hash
188 set(CIVETWEB_SQLITE_MD5_HASH 02e9c3a6daa8b8587cf6bef828c2e33f CACHE STRING
189 "The hash of SQLite archive to be downloaded")
190 set_property(CACHE CIVETWEB_SQLITE_MD5_HASH PROPERTY VALUE ${CIVETWEB_SQLITE_MD5_HASH})
191 mark_as_advanced(CIVETWEB_SQLITE_MD5_HASH)
192endif()
193
194# Duktape CGI support
195option(CIVETWEB_ENABLE_DUKTAPE "Enable Duktape CGIs" OFF)
196message(STATUS "Duktape CGI support - ${CIVETWEB_ENABLE_DUKTAPE}")
197
198# SSL support
199option(CIVETWEB_ENABLE_SSL "Enables the secure socket layer" ON)
200message(STATUS "SSL support - ${CIVETWEB_ENABLE_SSL}")
201
11fdf7f2
TL
202# OpenSSL 1.1 API
203option(CIVETWEB_SSL_OPENSSL_API_1_1 "Use the OpenSSL 1.1 API" OFF)
204message(STATUS "Compile for OpenSSL 1.1 API - ${CIVETWEB_SSL_OPENSSL_API_1_1}")
205
7c673cae
FG
206# Dynamically load or link the SSL libraries
207cmake_dependent_option(
208 CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING "Dynamically loads the SSL library rather than linking it" ON
209 CIVETWEB_ENABLE_SSL OFF)
210if (CIVETWEB_ENABLE_SSL)
211 message(STATUS "Dynamically load SSL libraries - ${CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING}")
212endif()
213
214# Third Party Download location
215set(CIVETWEB_THIRD_PARTY_DIR "${CMAKE_BINARY_DIR}/third_party" CACHE STRING
216 "The location that third party code is downloaded, built and installed")
217set_property(CACHE CIVETWEB_THIRD_PARTY_DIR PROPERTY VALUE ${CIVETWEB_THIRD_PARTY_DIR})
218
219# Unix systems can define the dynamic library names to load
220if (CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING AND NOT DARWIN AND UNIX)
221 # SSL library name
222 set(CIVETWEB_SSL_SSL_LIB "libssl.so" CACHE STRING
223 "The name of the SSL library to load")
224 set_property(CACHE CIVETWEB_SSL_SSL_LIB PROPERTY VALUE ${CIVETWEB_SSL_SSL_LIB})
225 message(STATUS "SSL Library Name - ${CIVETWEB_SSL_SSL_LIB}")
226
227 # Crytography library name
228 set(CIVETWEB_SSL_CRYPTO_LIB "libcrypto.so" CACHE STRING
229 "The name of the SSL Cryptography library to load")
230 set_property(CACHE CIVETWEB_SSL_CRYPTO_LIB PROPERTY VALUE ${CIVETWEB_SSL_CRYPTO_LIB})
231 message(STATUS "SSL Cryptography Library Name - ${CIVETWEB_SSL_CRYPTO_LIB}")
232endif()
233
234# Allow warnings in 3rd party components
235if (CIVETWEB_ENABLE_LUA OR CIVETWEB_ENABLE_DUKTAPE)
236SET(CIVETWEB_ALLOW_WARNINGS YES)
237endif()
238
239# The C and C++ standards to use
240set(CIVETWEB_C_STANDARD auto CACHE STRING
241 "The C standard to use; auto determines the latest supported by the compiler")
242set_property(CACHE CIVETWEB_C_STANDARD PROPERTY STRINGS auto c11 c99 c89)
243set(CIVETWEB_CXX_STANDARD auto CACHE STRING
244 "The C++ standard to use; auto determines the latest supported by the compiler")
245set_property(CACHE CIVETWEB_CXX_STANDARD PROPERTY STRINGS auto c++14 c++11 c++98)
246
247# Configure the linker
248if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
249 find_program(GCC_AR gcc-ar)
250 if (GCC_AR)
251 set(CMAKE_AR ${GCC_AR})
252 endif()
253 find_program(GCC_RANLIB gcc-ranlib)
254 if (GCC_RANLIB)
255 set(CMAKE_RANLIB ${GCC_RANLIB})
256 endif()
257endif()
258
259# Configure the C compiler
260message(STATUS "Configuring C Compiler")
261if ("${CIVETWEB_C_STANDARD}" STREQUAL "auto")
262 add_c_compiler_flag(-std=c11)
263 if (NOT HAVE_C_FLAG_STD_C11)
264 add_c_compiler_flag(-std=c99)
265 if (NOT HAVE_C_FLAG_STD_C99)
266 add_c_compiler_flag(-std=c89)
267 endif()
268 endif()
269else()
270 add_c_compiler_flag(-std=${CIVETWEB_C_STANDARD})
271endif()
11fdf7f2
TL
272
273#Warnings: enable everything
7c673cae
FG
274add_c_compiler_flag(-Wall)
275add_c_compiler_flag(-Wextra)
276add_c_compiler_flag(-Wshadow)
11fdf7f2 277add_c_compiler_flag(-Wconversion)
7c673cae
FG
278add_c_compiler_flag(-Wmissing-prototypes)
279add_c_compiler_flag(-Weverything)
11fdf7f2
TL
280add_c_compiler_flag(-Wparentheses)
281add_c_compiler_flag(/W4) # VisualStudio highest warning level
282
283#Warnings: Disable some warnings
284add_c_compiler_flag(-Wno-padded) # padding in structures by compiler
285add_c_compiler_flag(-Wno-unused-macros) # so what?
286add_c_compiler_flag(-Wno-reserved-id-macros) # for system headers
287add_c_compiler_flag(-Wno-format-nonliteral) # printf(myFormatStringVar, ...)
288add_c_compiler_flag(-Wno-date-time) # using __DATE__ once
289add_c_compiler_flag(-Wno-cast-qual) # const cast
7c673cae 290add_c_compiler_flag(/Wd4820) # padding
11fdf7f2 291
7c673cae
FG
292if (MINGW)
293 add_c_compiler_flag(-Wno-format)
294endif()
295if (NOT CIVETWEB_ALLOW_WARNINGS)
296 add_c_compiler_flag(-Werror)
297endif()
298add_c_compiler_flag(/WX)
299add_c_compiler_flag(-pedantic-errors)
300add_c_compiler_flag(-fvisibility=hidden)
301add_c_compiler_flag(-fstack-protector-strong RELEASE)
302add_c_compiler_flag(-flto RELEASE)
11fdf7f2 303if (${CIVETWEB_ENABLE_ASAN})
7c673cae
FG
304add_c_compiler_flag(-fsanitize=undefined DEBUG)
305add_c_compiler_flag(-fsanitize=address DEBUG)
306if (HAVE_C_FLAG_FSANITIZE_ADDRESS)
307 add_c_compiler_flag(-static-asan DEBUG)
308endif()
11fdf7f2 309endif()
7c673cae
FG
310add_c_compiler_flag(-fstack-protector-all DEBUG)
311if (MINGW)
312 add_c_compiler_flag(-mwindows)
313endif()
314
315# Coverage build type
316set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING
317 "Flags used by the C compiler during coverage builds."
318 FORCE)
319set(CMAKE_EXE_LINKER_FLAGS_COVERAGE
320 "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
321 "Flags used for linking binaries during coverage builds."
322 FORCE)
323set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
324 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
325 "Flags used by the shared libraries linker during coverage builds."
326 FORCE)
327mark_as_advanced(
328 CMAKE_CXX_FLAGS_COVERAGE
329 CMAKE_C_FLAGS_COVERAGE
330 CMAKE_EXE_LINKER_FLAGS_COVERAGE
331 CMAKE_SHARED_LINKER_FLAGS_COVERAGE)
332set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
333 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage."
334 FORCE)
335add_c_compiler_flag(--coverage COVERAGE)
336
337# Configure the C++ compiler
338if (CIVETWEB_ENABLE_CXX)
339 message(STATUS "Configuring C++ Compiler")
340 if ("${CIVETWEB_CXX_STANDARD}" STREQUAL "auto")
341 add_cxx_compiler_flag(-std=c++14)
342 if (NOT HAVE_CXX_FLAG_STD_CXX14)
343 add_cxx_compiler_flag(-std=c++11)
344 if (NOT HAVE_CXX_FLAG_STD_CXX11)
345 add_cxx_compiler_flag(-std=c++98)
346 endif()
347 endif()
348 else()
349 add_cxx_compiler_flag(-std=${CIVETWEB_CXX_STANDARD})
350 endif()
351 add_cxx_compiler_flag(-Wall)
352 add_cxx_compiler_flag(-Wextra)
353 add_cxx_compiler_flag(-Wshadow)
354 add_cxx_compiler_flag(-Wmissing-prototypes)
355 add_cxx_compiler_flag(-Weverything)
356 add_cxx_compiler_flag(/W4)
357 add_cxx_compiler_flag(-Wno-padded)
358 add_cxx_compiler_flag(/Wd4820) # padding
359 add_cxx_compiler_flag(-Wno-unused-macros)
360 add_cxx_compiler_flag(-Wno-format-nonliteral)
361 if (MINGW)
362 add_cxx_compiler_flag(-Wno-format)
363 endif()
364 if (NOT CIVETWEB_ALLOW_WARNINGS)
365 add_cxx_compiler_flag(-Werror)
366 endif()
367 add_cxx_compiler_flag(/WX)
368 add_cxx_compiler_flag(-pedantic-errors)
369 add_cxx_compiler_flag(-fvisibility=hidden)
370 add_cxx_compiler_flag(-fstack-protector-strong RELEASE)
371 add_cxx_compiler_flag(-flto RELEASE)
11fdf7f2 372 if (${CIVETWEB_ENABLE_ASAN})
7c673cae
FG
373 add_cxx_compiler_flag(-fsanitize=undefined DEBUG)
374 add_cxx_compiler_flag(-fsanitize=address DEBUG)
375 if (HAVE_CXX_FLAG_FSANITIZE_ADDRESS)
376 add_cxx_compiler_flag(-static-asan DEBUG)
377 endif()
11fdf7f2 378 endif()
7c673cae
FG
379 add_cxx_compiler_flag(-fstack-protector-all DEBUG)
380 if (MINGW)
381 add_cxx_compiler_flag(-mwindows)
382 endif()
383 set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
384 "Flags used by the C++ compiler during coverage builds."
385 FORCE)
386 add_cxx_compiler_flag(--coverage COVERAGE)
387endif()
388
7c673cae
FG
389# Set up the definitions
390if (${CMAKE_BUILD_TYPE} MATCHES "[Dd]ebug")
391 add_definitions(-DDEBUG)
392endif()
7c673cae
FG
393if (CIVETWEB_ENABLE_IPV6)
394 add_definitions(-DUSE_IPV6)
395endif()
396if (CIVETWEB_ENABLE_WEBSOCKETS)
397 add_definitions(-DUSE_WEBSOCKET)
398endif()
11fdf7f2
TL
399if (CIVETWEB_ENABLE_SERVER_STATS)
400 add_definitions(-DUSE_SERVER_STATS)
401endif()
7c673cae
FG
402if (CIVETWEB_SERVE_NO_FILES)
403 add_definitions(-DNO_FILES)
404endif()
405if (CIVETWEB_DISABLE_CGI)
406 add_definitions(-DNO_CGI)
407endif()
408if (CIVETWEB_DISABLE_CACHING)
409 add_definitions(-DNO_CACHING)
410endif()
411if (CIVETWEB_ENABLE_LUA)
412 add_definitions(-DUSE_LUA)
413endif()
414if (CIVETWEB_ENABLE_DUKTAPE)
415 add_definitions(-DUSE_DUKTAPE)
416endif()
417if (CIVETWEB_ENABLE_MEMORY_DEBUGGING)
418 add_definitions(-DMEMORY_DEBUGGING)
419endif()
420if (NOT CIVETWEB_ENABLE_SSL)
421 add_definitions(-DNO_SSL)
422elseif (NOT CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING)
423 add_definitions(-DNO_SSL_DL)
424else()
425 if(CIVETWEB_SSL_SSL_LIB)
426 add_definitions(-DSSL_LIB="${CIVETWEB_SSL_SSL_LIB}")
427 endif()
428 if(CIVETWEB_SSL_CRYPTO_LIB)
429 add_definitions(-DCRYPTO_LIB="${CIVETWEB_SSL_CRYPTO_LIB}")
430 endif()
431endif()
11fdf7f2
TL
432if(CIVETWEB_SSL_OPENSSL_API_1_1)
433 add_definitions(-DOPENSSL_API_1_1)
434endif()
7c673cae 435add_definitions(-DUSE_STACK_SIZE=${CIVETWEB_THREAD_STACK_SIZE})
11fdf7f2
TL
436
437# Set 32 or 64 bit environment
438if (${CMAKE_ARCH} MATCHES "[Xx]86")
439add_c_compiler_flag(-m32)
440endif()
441if (${CMAKE_ARCH} MATCHES "[Xx]64")
442add_c_compiler_flag(-m64)
443endif()
444# TODO: add support for -march
7c673cae
FG
445
446# Build the targets
447add_subdirectory(src)
448
449# Enable the testing of the library/executable
450include(CTest)
451if (BUILD_TESTING)
452 # Check unit testing framework Version
11fdf7f2 453 set(CIVETWEB_CHECK_VERSION 0.11.0 CACHE STRING
7c673cae
FG
454 "The version of Check unit testing framework to build and include statically")
455 set_property(CACHE CIVETWEB_CHECK_VERSION PROPERTY VALUE ${CIVETWEB_CHECK_VERSION})
456 message(STATUS "Check Unit Testing Framework Version - ${CIVETWEB_CHECK_VERSION}")
457 mark_as_advanced(CIVETWEB_CHECK_VERSION)
458
459 # Check unit testing framework Verification Hash
11fdf7f2
TL
460 # Hash for Check 0.10.0: 67a34c40b5bc888737f4e5ae82e9939f
461 # Hash for Check 0.11.0: 1b14ee307dca8e954a8219c34484d7c4
462 set(CIVETWEB_CHECK_MD5_HASH 1b14ee307dca8e954a8219c34484d7c4 CACHE STRING
7c673cae
FG
463 "The hash of Check unit testing framework archive to be downloaded")
464 set_property(CACHE CIVETWEB_CHECK_MD5_HASH PROPERTY VALUE ${CIVETWEB_CHECK_MD5_HASH})
465 mark_as_advanced(CIVETWEB_CHECK_MD5_HASH)
466
467 # Build the testing
468 add_subdirectory(test)
469endif()
470
471# Set up CPack
472include(InstallRequiredSystemLibraries)
473set(CPACK_PACKAGE_VENDOR "civetweb Contributors")
474set(CPACK_PACKAGE_CONTACT "civetweb@github.com")
475set(CPACK_PACKAGE_VERSION_MAJOR "${CIVETWEB_VERSION_MAJOR}")
476set(CPACK_PACKAGE_VERSION_MINOR "${CIVETWEB_VERSION_MINOR}")
477set(CPACK_PACKAGE_VERSION_PATCH "${CIVETWEB_VERSION_PATCH}")
478set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A HTTP library and server")
479set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
480set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md")
481set(CPACK_STRIP_FILES TRUE)
482set(CPACK_PACKAGE_DEPENDS "openssl")
483if (CIVETWEB_ENABLE_LUA_SHARED)
484 set(CPACK_PACKAGE_DEPENDS "lua, ${CPACK_PACKAGE_DEPENDS}")
485endif()
486
487# RPM Packaging
488set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
489set(CPACK_RPM_PACKAGE_LICENSE "MIT")
490set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CIVETWEB_ARCHITECTURE}")
491set(CPACK_RPM_PACKAGE_REQUIRES "${CPACK_PACKAGE_DEPENDS}")
492
493# Debian Packaging
494set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CIVETWEB_ARCHITECTURE}")
495set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/civetweb/civetweb")
496set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_PACKAGE_DEPENDS}")
497
498# WiX Packaging
499# TODO: www.cmake.org/cmake/help/v3.0/module/CPackWIX.html
500
501# Finalize CPack settings
502include(CPack)