11cmake_minimum_required (VERSION 3.13 )
22project (Http)
33
4- # Helpers
5- set (IS_CLANG "$<CXX_COMPILER_ID :Clang >" )
4+ # Policies
5+ if (POLICY CMP0127)
6+ cmake_policy (SET CMP0127 NEW )
7+ endif ()
8+ if (POLICY CMP0135)
9+ cmake_policy (SET CMP0135 OLD )
10+ endif ()
611
712# Deps
813include (FetchContent )
14+ include (CMakeDependentOption )
915find_package (Threads REQUIRED )
1016find_package (OpenSSL REQUIRED )
1117
12- if (POLICY CMP0135)
13- cmake_policy (SET CMP0135 OLD )
14- endif ()
1518set (BOOST_INCLUDE_LIBRARIES compat asio)
1619set (BOOST_ENABLE_CMAKE ON )
1720FetchContent_Declare (
@@ -21,14 +24,14 @@ FetchContent_Declare(
2124FetchContent_MakeAvailable (Boost)
2225
2326# Options
24- option (HTTP_BUILD_FUZZERS "Builds Fuzz tests (requires clang) " OFF )
27+ cmake_dependent_option (HTTP_BUILD_FUZZERS "Builds Fuzz tests" OFF "CMAKE_CXX_COMPILER_ID STREQUAL \" Clang \" " OFF )
2528
2629# Lib
2730add_library (http ${CMAKE_CURRENT_SOURCE_DIR} /../src/http.cpp )
2831target_compile_features (http PUBLIC cxx_std_17 )
2932target_include_directories (http PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} /../src )
3033target_link_libraries (http PUBLIC OpenSSL::SSL OpenSSL::Crypto Boost::asio )
31- target_compile_options (http PRIVATE $<$<AND : ${IS_CLANG} ,$< BOOL :${HTTP_BUILD_FUZZERS} > >:-fprofile -instr -generate -fcoverage -mapping >)
34+ target_compile_options (http PRIVATE $<$<BOOL :${HTTP_BUILD_FUZZERS} >:-fprofile -instr -generate -fcoverage -mapping >)
3235
3336# Examples
3437function (add_executable_20 target_name )
@@ -64,7 +67,7 @@ target_include_directories(tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/extra)
6467target_link_libraries (tests PRIVATE http )
6568
6669# Fuzz tests
67- if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND HTTP_BUILD_FUZZERS)
70+ if (HTTP_BUILD_FUZZERS)
6871 function (add_fuzz target_name )
6972 add_executable (${target_name} ${ARGN} )
7073 target_link_libraries (${target_name} PRIVATE http )
0 commit comments