CMakeLists.txt 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. cmake_minimum_required(VERSION 3.15)
  2. project(cpr VERSION 1.9.0 LANGUAGES CXX)
  3. math(EXPR cpr_VERSION_NUM "${cpr_VERSION_MAJOR} * 0x10000 + ${cpr_VERSION_MINOR} * 0x100 + ${cpr_VERSION_PATCH}" OUTPUT_FORMAT HEXADECIMAL)
  4. configure_file("${cpr_SOURCE_DIR}/cmake/cprver.h.in" "${cpr_BINARY_DIR}/cpr_generated_includes/cpr/cprver.h")
  5. # Only change the folder behaviour if cpr is not a subproject
  6. if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
  7. set_property(GLOBAL PROPERTY USE_FOLDERS ON)
  8. set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
  9. set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
  10. set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
  11. else()
  12. # Check required c++ standard of parent project
  13. if(CMAKE_CXX_STANDARD)
  14. set(PARENT_CXX_STANDARD ${CMAKE_CXX_STANDARD})
  15. message(STATUS "CXX standard of parent project: ${PARENT_CXX_STANDARD}")
  16. endif()
  17. endif()
  18. # Avoid the dll boilerplate code for windows
  19. set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
  20. if (PARENT_CXX_STANDARD)
  21. # Don't set CMAKE_CXX_STANDARD if it is already set by parent project
  22. if (PARENT_CXX_STANDARD LESS 17)
  23. message(FATAL_ERROR "cpr ${cpr_VERSION} does not support ${PARENT_CXX_STANDARD}. Please use cpr <= 1.9.x")
  24. endif()
  25. else()
  26. # Set standard version if not already set by potential parent project
  27. set(CMAKE_CXX_STANDARD 17)
  28. endif()
  29. message(STATUS "CXX standard: ${CMAKE_CXX_STANDARD}")
  30. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  31. set(CPR_LIBRARIES cpr CACHE INTERNAL "")
  32. macro(cpr_option OPTION_NAME OPTION_TEXT OPTION_DEFAULT)
  33. option(${OPTION_NAME} ${OPTION_TEXT} ${OPTION_DEFAULT})
  34. if(DEFINED ENV{${OPTION_NAME}})
  35. # Allow overriding the option through an environment variable
  36. set(${OPTION_NAME} $ENV{${OPTION_NAME}})
  37. endif()
  38. if(${OPTION_NAME})
  39. add_definitions(-D${OPTION_NAME})
  40. endif()
  41. message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}")
  42. endmacro()
  43. option(BUILD_SHARED_LIBS "Build libraries as shared libraries" ON)
  44. message(STATUS "C++ Requests CMake Options")
  45. message(STATUS "=======================================================")
  46. cpr_option(CPR_GENERATE_COVERAGE "Set to ON to generate coverage reports." OFF)
  47. cpr_option(CPR_CURL_NOSIGNAL "Set to ON to disable use of signals in libcurl." OFF)
  48. cpr_option(CURL_VERBOSE_LOGGING "Curl verbose logging during building curl" OFF)
  49. cpr_option(CPR_USE_SYSTEM_GTEST "If ON, this project will look in the system paths for an installed gtest library. If none is found it will use the build in one." OFF)
  50. cpr_option(CPR_USE_SYSTEM_CURL "If enabled we will use the curl lib already installed on this system." OFF)
  51. cpr_option(CPR_ENABLE_SSL "Enables or disables the SSL backend. Required to perform HTTPS requests." ON)
  52. cpr_option(CPR_FORCE_OPENSSL_BACKEND "Force to use the OpenSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, and CPR_FORCE_WINSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF)
  53. cpr_option(CPR_FORCE_WINSSL_BACKEND "Force to use the WinSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, and CPR_FORCE_WINSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF)
  54. cpr_option(CPR_FORCE_DARWINSSL_BACKEND "Force to use the DarwinSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, and CPR_FORCE_WINSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF)
  55. cpr_option(CPR_FORCE_MBEDTLS_BACKEND "Force to use the Mbed TLS backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, and CPR_FORCE_WINSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF)
  56. cpr_option(CPR_ENABLE_LINTING "Set to ON to enable clang linting." OFF)
  57. cpr_option(CPR_ENABLE_CPPCHECK "Set to ON to enable Cppcheck static analysis. Requires CPR_BUILD_TESTS and CPR_BUILD_TESTS_SSL to be OFF to prevent checking google tests source code." OFF)
  58. cpr_option(CPR_BUILD_TESTS "Set to ON to build cpr tests." OFF)
  59. cpr_option(CPR_BUILD_TESTS_SSL "Set to ON to build cpr ssl tests" ${CPR_BUILD_TESTS})
  60. cpr_option(CPR_BUILD_TESTS_PROXY "Set to ON to build proxy tests. They fail in case there is no valid proxy server available in proxy_tests.cpp" OFF)
  61. cpr_option(CPR_SKIP_CA_BUNDLE_SEARCH "Skip searching for Certificate Authority certs. Turn ON systems like iOS where file access is restricted and prevents https from working." OFF)
  62. cpr_option(CPR_USE_BOOST_FILESYSTEM "Set to ON to use the Boost.Filesystem library on OSX." OFF)
  63. message(STATUS "=======================================================")
  64. if (CPR_FORCE_USE_SYSTEM_CURL)
  65. message(WARNING "The variable CPR_FORCE_USE_SYSTEM_CURL is deprecated, please use CPR_USE_SYSTEM_CURL instead")
  66. set(CPR_USE_SYSTEM_CURL ${CPR_FORCE_USE_SYSTEM_CURL})
  67. endif()
  68. include(GNUInstallDirs)
  69. include(FetchContent)
  70. include(cmake/code_coverage.cmake)
  71. include(cmake/sanitizer.cmake)
  72. include(cmake/clear_variable.cmake)
  73. # So CMake can find FindMbedTLS.cmake
  74. set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
  75. # Linting
  76. if(CPR_ENABLE_LINTING)
  77. include(cmake/clang-tidy.cmake)
  78. endif()
  79. # Cppcheck
  80. if(CPR_ENABLE_CPPCHECK)
  81. if(CPR_BUILD_TESTS OR CPR_BUILD_TESTS_SSL)
  82. message(FATAL_ERROR "Cppcheck is incompatible with building tests. Make sure to disable CPR_ENABLE_CPPCHECK or disable tests by setting CPR_BUILD_TESTS and CPR_BUILD_TESTS_SSL to OFF. This is because Cppcheck would try to check the google tests source code and then fail. ")
  83. endif()
  84. include(cmake/cppcheck.cmake)
  85. endif()
  86. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
  87. else()
  88. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror")
  89. endif()
  90. # SSL
  91. if(CPR_ENABLE_SSL)
  92. if(CPR_FORCE_OPENSSL_BACKEND OR CPR_FORCE_WINSSL_BACKEND OR CPR_FORCE_DARWINSSL_BACKEND OR CPR_FORCE_MBEDTLS_BACKEND)
  93. message(STATUS "Disabled SSL backend auto detect since either CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, or CPR_FORCE_WINSSL_BACKEND is enabled.")
  94. set(DETECT_SSL_BACKEND OFF CACHE INTERNAL "" FORCE)
  95. else()
  96. message(STATUS "Automatically detecting SSL backend.")
  97. set(DETECT_SSL_BACKEND ON CACHE INTERNAL "" FORCE)
  98. endif()
  99. if(CPR_FORCE_WINSSL_BACKEND AND (NOT WIN32))
  100. message(FATAL_ERROR "WinSSL is only available on Windows! Use either OpenSSL (CPR_FORCE_OPENSSL_BACKEND) or DarwinSSL (CPR_FORCE_DARWINSSL_BACKEND) instead.")
  101. endif()
  102. if(DETECT_SSL_BACKEND)
  103. message(STATUS "Detecting SSL backend...")
  104. if(WIN32)
  105. message(STATUS "SSL auto detect: Using WinSSL.")
  106. set(SSL_BACKEND_USED "WinSSL")
  107. elseif(APPLE)
  108. message(STATUS "SSL auto detect: Using DarwinSSL.")
  109. set(CPR_BUILD_TESTS_SSL OFF)
  110. set(SSL_BACKEND_USED "DarwinSSL")
  111. else()
  112. find_package(OpenSSL)
  113. if(OPENSSL_FOUND)
  114. message(STATUS "SSL auto detect: Using OpenSSL.")
  115. set(SSL_BACKEND_USED "OpenSSL")
  116. else()
  117. find_package(MbedTLS)
  118. if(MBEDTLS_FOUND)
  119. set(SSL_BACKEND_USED "MbedTLS")
  120. else()
  121. message(FATAL_ERROR "No valid SSL backend found! Please install OpenSSL, Mbed TLS or disable SSL by setting CPR_ENABLE_SSL to OFF.")
  122. endif()
  123. endif()
  124. endif()
  125. else()
  126. if(CPR_FORCE_OPENSSL_BACKEND)
  127. find_package(OpenSSL)
  128. if(OPENSSL_FOUND)
  129. message(STATUS "Using OpenSSL.")
  130. set(SSL_BACKEND_USED "OpenSSL")
  131. else()
  132. message(FATAL_ERROR "CPR_FORCE_OPENSSL_BACKEND enabled but we were not able to find OpenSSL!")
  133. endif()
  134. elseif(CPR_FORCE_WINSSL_BACKEND)
  135. message(STATUS "Using WinSSL.")
  136. set(SSL_BACKEND_USED "WinSSL")
  137. elseif(CPR_FORCE_DARWINSSL_BACKEND)
  138. message(STATUS "Using DarwinSSL.")
  139. set(CPR_BUILD_TESTS_SSL OFF)
  140. set(SSL_BACKEND_USED "DarwinSSL")
  141. elseif(CPR_FORCE_MBEDTLS_BACKEND)
  142. message(STATUS "Using Mbed TLS.")
  143. set(CPR_BUILD_TESTS_SSL OFF)
  144. set(SSL_BACKEND_USED "MbedTLS")
  145. endif()
  146. endif()
  147. endif()
  148. if(SSL_BACKEND_USED STREQUAL "OpenSSL")
  149. # Fix missing OpenSSL includes for Windows since in 'ssl_ctx.cpp' we include OpenSSL directly
  150. find_package(OpenSSL REQUIRED)
  151. add_compile_definitions(OPENSSL_BACKEND_USED)
  152. endif()
  153. get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
  154. if (NOT isMultiConfig)
  155. set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${ALLOWED_BUILD_TYPES}")
  156. if (NOT CMAKE_BUILD_TYPE)
  157. set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
  158. elseif(NOT CMAKE_BUILD_TYPE IN_LIST ALLOWED_BUILD_TYPES)
  159. message(FATAL_ERROR "Invalid build type: ${CMAKE_BUILD_TYPE}")
  160. endif()
  161. else ()
  162. unset(CMAKE_BUILD_TYPE)
  163. foreach(TYPE ${ALLOWED_BUILD_TYPES})
  164. if (NOT ${TYPE} IN_LIST CMAKE_CONFIGURATION_TYPES)
  165. list(APPEND CMAKE_CONFIGURATION_TYPES ${TYPE})
  166. endif()
  167. endforeach()
  168. endif()
  169. # Curl configuration
  170. if(CPR_USE_SYSTEM_CURL)
  171. if(CPR_ENABLE_SSL)
  172. find_package(CURL COMPONENTS HTTP HTTPS)
  173. if(CURL_FOUND)
  174. message(STATUS "Curl ${CURL_VERSION_STRING} found on this system.")
  175. # To be able to load certificates under Windows when using OpenSSL:
  176. if(CMAKE_USE_OPENSSL AND WIN32 AND (NOT (CURL_VERSION_STRING VERSION_GREATER_EQUAL "7.71.0")))
  177. message(FATAL_ERROR "Your system curl version (${CURL_VERSION_STRING}) is too old to support OpenSSL on Windows which requires curl >= 7.71.0. Update your curl version, use WinSSL, disable SSL or use the build in version of curl.")
  178. endif()
  179. else()
  180. find_package(CURL COMPONENTS HTTP)
  181. if(CURL_FOUND)
  182. message(FATAL_ERROR "Curl found on this system but WITHOUT HTTPS/SSL support. Either disable SSL by setting CPR_ENABLE_SSL to OFF or use the build in version of curl by setting CPR_USE_SYSTEM_CURL to OFF.")
  183. else()
  184. message(FATAL_ERROR "Curl not found on this system. To use the build in version set CPR_USE_SYSTEM_CURL to OFF.")
  185. endif()
  186. endif()
  187. else()
  188. find_package(CURL COMPONENTS HTTP)
  189. if(CURL_FOUND)
  190. message(STATUS "Curl found on this system.")
  191. else()
  192. message(FATAL_ERROR "Curl not found on this system. To use the build in version set CPR_USE_SYSTEM_CURL to OFF.")
  193. endif()
  194. endif()
  195. else()
  196. message(STATUS "Configuring build in curl...")
  197. # ZLIB is optional for curl
  198. # to disable it:
  199. # * from command line:
  200. # -DCURL_ZLIB=OFF
  201. # * from CMake script:
  202. # SET(CURL_ZLIB OFF CACHE STRING "" FORCE)
  203. if (CURL_ZLIB OR CURL_ZLIB STREQUAL AUTO OR NOT DEFINED CACHE{CURL_ZLIB})
  204. include(cmake/zlib_external.cmake)
  205. endif()
  206. # We only need HTTP (and HTTPS) support:
  207. set(HTTP_ONLY ON CACHE INTERNAL "" FORCE)
  208. set(BUILD_CURL_EXE OFF CACHE INTERNAL "" FORCE)
  209. set(BUILD_TESTING OFF)
  210. if (CURL_VERBOSE_LOGGING)
  211. message(STATUS "Enabled curl debug features")
  212. set(ENABLE_DEBUG ON CACHE INTERNAL "" FORCE)
  213. endif()
  214. if (CPR_ENABLE_SSL)
  215. set(SSL_ENABLED ON CACHE INTERNAL "" FORCE)
  216. if(ANDROID)
  217. set(CURL_CA_PATH "/system/etc/security/cacerts" CACHE INTERNAL "")
  218. elseif(CPR_SKIP_CA_BUNDLE_SEARCH)
  219. set(CURL_CA_PATH "none" CACHE INTERNAL "")
  220. else()
  221. set(CURL_CA_PATH "auto" CACHE INTERNAL "")
  222. endif()
  223. if(CPR_SKIP_CA_BUNDLE_SEARCH)
  224. set(CURL_CA_BUNDLE "none" CACHE INTERNAL "")
  225. elseif(NOT DEFINED CURL_CA_BUNDLE)
  226. set(CURL_CA_BUNDLE "auto" CACHE INTERNAL "")
  227. endif()
  228. if(SSL_BACKEND_USED STREQUAL "WinSSL")
  229. set(CMAKE_USE_SCHANNEL ON CACHE INTERNAL "" FORCE)
  230. endif()
  231. if(SSL_BACKEND_USED STREQUAL "OpenSSL")
  232. set(CMAKE_USE_OPENSSL ON CACHE INTERNAL "" FORCE)
  233. endif()
  234. if(SSL_BACKEND_USED STREQUAL "DarwinSSL")
  235. set(CMAKE_USE_SECTRANSP ON CACHE INTERNAL "" FORCE)
  236. endif()
  237. if(SSL_BACKEND_USED STREQUAL "MbedTLS")
  238. set(CMAKE_USE_MBEDTLS ON CACHE INTERNAL "" FORCE)
  239. endif()
  240. message(STATUS "Enabled curl SSL")
  241. else()
  242. set(SSL_ENABLED OFF CACHE INTERNAL "" FORCE)
  243. set(CURL_CA_PATH "none" CACHE INTERNAL "" FORCE)
  244. set(CMAKE_USE_SCHANNEL OFF CACHE INTERNAL "" FORCE)
  245. set(CMAKE_USE_OPENSSL OFF CACHE INTERNAL "" FORCE)
  246. set(CMAKE_USE_SECTRANSP OFF CACHE INTERNAL "" FORCE)
  247. set(CMAKE_USE_MBEDTLS OFF CACHE INTERNAL "" FORCE)
  248. message(STATUS "Disabled curl SSL")
  249. endif()
  250. # Disable linting for curl
  251. clear_variable(DESTINATION CMAKE_CXX_CLANG_TIDY BACKUP CMAKE_CXX_CLANG_TIDY_BKP)
  252. FetchContent_Declare(curl
  253. URL https://github.com/curl/curl/releases/download/curl-7_80_0/curl-7.80.0.tar.xz
  254. URL_HASH SHA256=a132bd93188b938771135ac7c1f3ac1d3ce507c1fcbef8c471397639214ae2ab # the file hash for curl-7.80.0.tar.xz
  255. USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress
  256. FetchContent_MakeAvailable(curl)
  257. restore_variable(DESTINATION CMAKE_CXX_CLANG_TIDY BACKUP CMAKE_CXX_CLANG_TIDY_BKP)
  258. # Group under the "external" project folder in IDEs such as Visual Studio.
  259. if(BUILD_CURL_EXE)
  260. set_property(TARGET curl PROPERTY FOLDER "external")
  261. endif()
  262. set_property(TARGET libcurl PROPERTY FOLDER "external")
  263. endif()
  264. # GTest configuration
  265. if(CPR_BUILD_TESTS)
  266. if(CPR_USE_SYSTEM_GTEST)
  267. find_package(GTest)
  268. endif()
  269. if(NOT CPR_USE_SYSTEM_GTEST OR NOT GTEST_FOUND)
  270. message(STATUS "Not using system gtest, using built-in googletest project instead.")
  271. if(MSVC)
  272. # By default, GTest compiles on Windows in CRT static linkage mode. We use this
  273. # variable to force it into using the CRT in dynamic linkage (DLL), just as CPR
  274. # does.
  275. set(gtest_force_shared_crt ON CACHE BOOL "Force gtest to use the shared c runtime")
  276. endif()
  277. # Disable linting for google test
  278. clear_variable(DESTINATION CMAKE_CXX_CLANG_TIDY BACKUP CMAKE_CXX_CLANG_TIDY_BKP)
  279. FetchContent_Declare(googletest
  280. URL https://github.com/google/googletest/archive/release-1.11.0.tar.gz
  281. URL_HASH SHA256=b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5 # the file hash for release-1.11.0.tar.gz
  282. USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress
  283. FetchContent_MakeAvailable(googletest)
  284. restore_variable(DESTINATION CMAKE_CXX_CLANG_TIDY BACKUP CMAKE_CXX_CLANG_TIDY_BKP)
  285. add_library(gtest_int INTERFACE)
  286. target_link_libraries(gtest_int INTERFACE gtest)
  287. target_include_directories(gtest_int INTERFACE ${googletest_SOURCE_DIR}/include)
  288. add_library(GTest::GTest ALIAS gtest_int)
  289. # Group under the "tests/gtest" project folder in IDEs such as Visual Studio.
  290. set_property(TARGET gtest PROPERTY FOLDER "tests/gtest")
  291. set_property(TARGET gtest_main PROPERTY FOLDER "tests/gtest")
  292. endif()
  293. endif()
  294. # Mongoose configuration
  295. if(CPR_BUILD_TESTS)
  296. message(STATUS "Building mongoose project for test support.")
  297. if(CPR_BUILD_TESTS_SSL)
  298. if(NOT CPR_ENABLE_SSL)
  299. message(FATAL_ERROR "OpenSSL is required to build SSL test but CPR_ENABLE_SSL is disabled. Either set CPR_ENABLE_SSL to ON or disable CPR_BUILD_TESTS_SSL.")
  300. endif()
  301. if(NOT(SSL_BACKEND_USED STREQUAL "OpenSSL"))
  302. message(FATAL_ERROR "OpenSSL is required for SSL test, but it seams like OpenSSL is not being used as SSL backend. Either set CPR_BUILD_TESTS_SSL to OFF or set CPR_FORCE_OPENSSL_BACKEND to ON and try again.")
  303. endif()
  304. set(ENABLE_SSL_TESTS ON CACHE INTERNAL "")
  305. else()
  306. set(ENABLE_SSL_TESTS OFF CACHE INTERNAL "")
  307. endif()
  308. # Disable linting for mongoose
  309. clear_variable(DESTINATION CMAKE_CXX_CLANG_TIDY BACKUP CMAKE_CXX_CLANG_TIDY_BKP)
  310. FetchContent_Declare(mongoose
  311. URL https://github.com/cesanta/mongoose/archive/7.7.tar.gz
  312. URL_HASH SHA256=4e5733dae31c3a81156af63ca9aa3a6b9b736547f21f23c3ab2f8e3f1ecc16c0 # the hash for 7.7.tar.gz
  313. USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress
  314. # We can not use FetchContent_MakeAvailable, since we need to patch mongoose to use CMake
  315. if (NOT mongoose_POPULATED)
  316. FetchContent_POPULATE(mongoose)
  317. file(INSTALL cmake/mongoose.CMakeLists.txt DESTINATION ${mongoose_SOURCE_DIR})
  318. file(RENAME ${mongoose_SOURCE_DIR}/mongoose.CMakeLists.txt ${mongoose_SOURCE_DIR}/CMakeLists.txt)
  319. add_subdirectory(${mongoose_SOURCE_DIR} ${mongoose_BINARY_DIR})
  320. endif()
  321. # Group under the "external" project folder in IDEs such as Visual Studio.
  322. set_property(TARGET mongoose PROPERTY FOLDER "external")
  323. restore_variable(DESTINATION CMAKE_CXX_CLANG_TIDY BACKUP CMAKE_CXX_CLANG_TIDY_BKP)
  324. endif()
  325. add_subdirectory(cpr)
  326. add_subdirectory(include)
  327. if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND CPR_BUILD_TESTS)
  328. # Disable linting for tests since they are currently not up to the standard
  329. clear_variable(DESTINATION CMAKE_CXX_CLANG_TIDY BACKUP CMAKE_CXX_CLANG_TIDY_BKP)
  330. enable_testing()
  331. add_subdirectory(test)
  332. restore_variable(DESTINATION CMAKE_CXX_CLANG_TIDY BACKUP CMAKE_CXX_CLANG_TIDY_BKP)
  333. endif()