CMakeLists.txt 17 KB

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