diff --git a/CMakeLists.txt b/CMakeLists.txt index 4829708262cd55ceda3dc96888e740fc566ec978..b8d0bbc120dc6ad76e95d39de7635072cf72a997 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,8 @@ if (ENABLE_HARDENING) set(HARDENING_LDFLAGS "-pie -z relro -z now") endif() add_compile_flags("C;CXX" ${HARDENING_FLAGS}) + set(DEPENDENCY_CFLAGS "${DEPENDENCY_CFLAGS} ${HARDENING_FLAGS}") + set(DEPENDENCY_CXXFLAGS "${DEPENDENCY_CXXFLAGS} ${HARDENING_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${HARDENING_LDFLAGS}") endif() @@ -458,14 +460,14 @@ option(BUNDLED_LIBCURL_USE_NGHTTP2 "Build curl with bundled nghttp2" if (ENABLE_BUNDLED_LIBCURL) if(BUNDLED_LIBCURL_USE_ARES) include(BuildAres) - ares_build(${HARDENING_FLAGS}) + ares_build() endif() if(BUNDLED_LIBCURL_USE_NGHTTP2) include(BuildNghttp2) - nghttp2_build(${HARDENING_FLAGS}) + nghttp2_build() endif() include(BuildLibCURL) - curl_build(${HARDENING_FLAGS}) + curl_build() add_dependencies(build_bundled_libs bundled-libcurl) else() set(CURL_FIND_REQUIRED ON) @@ -542,7 +544,7 @@ if(ENABLE_BACKTRACE) endif() include(BuildLibUnwind) - libunwind_build(${HARDENING_FLAGS}) + libunwind_build() add_dependencies(build_bundled_libs bundled-libunwind bundled-libunwind-platform) diff --git a/cmake/BuildAres.cmake b/cmake/BuildAres.cmake index 5dc3584f4a81f8b5b6854e01e3c363d438afaa32..b86d793d1454a5058d81d229b6fd15caceb09b24 100644 --- a/cmake/BuildAres.cmake +++ b/cmake/BuildAres.cmake @@ -1,11 +1,11 @@ # A macro to build the bundled libcares -macro(ares_build CFLAGS) +macro(ares_build) set(ARES_SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/c-ares) set(ARES_BINARY_DIR ${PROJECT_BINARY_DIR}/build/ares/work) set(ARES_INSTALL_DIR ${PROJECT_BINARY_DIR}/build/ares/dest) # See BuildLibCURL.cmake for details. - set(ARES_CFLAGS ${CFLAGS}) + set(ARES_CFLAGS ${DEPENDENCY_CFLAGS}) if (TARGET_OS_DARWIN AND NOT "${CMAKE_OSX_SYSROOT}" STREQUAL "") set(ARES_CFLAGS "${ARES_CFLAGS} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}") endif() diff --git a/cmake/BuildCDT.cmake b/cmake/BuildCDT.cmake index 8c89e8a117d58e01ec6ec928ba313a94d52e0a2c..e2e46290284b98c0623fbce7611a8ba2e6d6ff55 100644 --- a/cmake/BuildCDT.cmake +++ b/cmake/BuildCDT.cmake @@ -7,7 +7,7 @@ macro(libccdt_build) ${CMAKE_CURRENT_BINARY_DIR}/third_party/c-dt/build/) set_target_properties(cdt PROPERTIES COMPILE_FLAGS - "-DDT_NAMESPACE=tnt_ -DDT_PARSE_ISO_YEAR0 -DDT_PARSE_ISO_TNT" + "${DEPENDENCY_CFLAGS} -DDT_NAMESPACE=tnt_ -DDT_PARSE_ISO_YEAR0 -DDT_PARSE_ISO_TNT" ) add_definitions("-DDT_NAMESPACE=tnt_") endmacro() diff --git a/cmake/BuildDecNumber.cmake b/cmake/BuildDecNumber.cmake index abc6c64c4195689e7e66d69d64062a4b002d60a2..e51d59b27a9049b73902556e5ce397059f95b358 100644 --- a/cmake/BuildDecNumber.cmake +++ b/cmake/BuildDecNumber.cmake @@ -8,6 +8,7 @@ macro(decnumber_build) ) add_library(decNumber STATIC ${decnumber_src}) + set_target_properties(decNumber PROPERTIES COMPILE_FLAGS "${DEPENDENCY_CFLAGS}") set(DECNUMBER_INCLUDE_DIR ${PROJECT_BINARY_DIR}/third_party/decNumber) unset(decnumber_src) diff --git a/cmake/BuildLibCORO.cmake b/cmake/BuildLibCORO.cmake index 860aabd5e3b50117cb93855aced943373f295a60..de8c0664b4233791b61d5f76f143d69bea60169c 100644 --- a/cmake/BuildLibCORO.cmake +++ b/cmake/BuildLibCORO.cmake @@ -5,7 +5,7 @@ macro(libcoro_build) ${PROJECT_SOURCE_DIR}/third_party/coro/coro.c ) set_source_files_properties(${coro_src} PROPERTIES - COMPILE_FLAGS -fomit-frame-pointer) + COMPILE_FLAGS "${DEPENDENCY_CFLAGS} -fomit-frame-pointer") add_library(coro STATIC ${coro_src}) diff --git a/cmake/BuildLibCURL.cmake b/cmake/BuildLibCURL.cmake index 99f1ead0fce4af4a8bd642fb2e8dfa4dbb8af6d0..32c4aec088a5c55dac37a282478de70bdf30cd85 100644 --- a/cmake/BuildLibCURL.cmake +++ b/cmake/BuildLibCURL.cmake @@ -1,9 +1,9 @@ # A macro to build the bundled libcurl -macro(curl_build CFLAGS) +macro(curl_build) set(LIBCURL_SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/curl) set(LIBCURL_BINARY_DIR ${PROJECT_BINARY_DIR}/build/curl/work) set(LIBCURL_INSTALL_DIR ${PROJECT_BINARY_DIR}/build/curl/dest) - set(LIBCURL_CFLAGS ${CFLAGS}) + set(LIBCURL_CFLAGS ${DEPENDENCY_CFLAGS}) get_filename_component(FOUND_ZLIB_ROOT_DIR ${ZLIB_INCLUDE_DIR} DIRECTORY) list(APPEND LIBCURL_CMAKE_FLAGS "-DZLIB_ROOT=${FOUND_ZLIB_ROOT_DIR}") diff --git a/cmake/BuildLibEIO.cmake b/cmake/BuildLibEIO.cmake index 57561b56cc4a781a2d2b64a7cb70b8dae7a1b88d..a542a3deafcd645276516a7a37083510c2c20a80 100644 --- a/cmake/BuildLibEIO.cmake +++ b/cmake/BuildLibEIO.cmake @@ -1,7 +1,7 @@ # # A macro to build the bundled libeio macro(libeio_build) - set(eio_compile_flags) + set(eio_compile_flags ${DEPENDENCY_CFLAGS}) # See comments in BuildLibEV.cmake set(eio_compile_flags "${eio_compile_flags} -w") diff --git a/cmake/BuildLibEV.cmake b/cmake/BuildLibEV.cmake index 58e970851e834d7b7f9b8344069bf7e80e3052d5..a8fef0a8d01653e9273ca8de1d363c125b1e817f 100644 --- a/cmake/BuildLibEV.cmake +++ b/cmake/BuildLibEV.cmake @@ -1,7 +1,7 @@ # # A macro to build the bundled libev macro(libev_build) - set(ev_compile_flags) + set(ev_compile_flags ${DEPENDENCY_CFLAGS}) set(ev_link_libraries) # There are warnings in libev code which are impossible to selectively # turn off, see diff --git a/cmake/BuildLibUnwind.cmake b/cmake/BuildLibUnwind.cmake index 750e6df6d04508f9c7ab2b2915be3e19ce4f9bfa..27d7961d18389eeb76c155c35676e50db2380ffe 100644 --- a/cmake/BuildLibUnwind.cmake +++ b/cmake/BuildLibUnwind.cmake @@ -18,12 +18,12 @@ Cache Variables The paths to the libunwind libraries. #]========================================================================] -macro(libunwind_build CFLAGS) +macro(libunwind_build) set(LIBUNWIND_SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/libunwind) set(LIBUNWIND_BUILD_DIR ${PROJECT_BINARY_DIR}/build/libunwind) set(LIBUNWIND_BINARY_DIR ${LIBUNWIND_BUILD_DIR}/work) set(LIBUNWIND_INSTALL_DIR ${LIBUNWIND_BUILD_DIR}/dest) - set(LIBUNWIND_CFLAGS "-g -O2 ${CFLAGS}") + set(LIBUNWIND_CFLAGS "${DEPENDENCY_CFLAGS} -g -O2") set(LIBUNWIND_CXXFLAGS "-g -O2") include(ExternalProject) diff --git a/cmake/BuildLibXXhash.cmake b/cmake/BuildLibXXhash.cmake index d9b8e6180bfc4b128bd049bb4be657d6d06483fe..9a96bf9e1387cd249dc4a42c808677632639cf1e 100644 --- a/cmake/BuildLibXXhash.cmake +++ b/cmake/BuildLibXXhash.cmake @@ -12,7 +12,7 @@ macro(libxxhash_build) # Remaining properties are the same as for zstd # (see cmake/BuildZSTD.cmake). set_source_files_properties(${xxhash_src} - PROPERTIES COMPILE_FLAGS "-Ofast -DXXH_NAMESPACE=tnt_") + PROPERTIES COMPILE_FLAGS "${DEPENDENCY_CFLAGS} -Ofast -DXXH_NAMESPACE=tnt_") add_library(xxhash STATIC ${xxhash_src}) set(XXHASH_LIBRARIES xxhash) diff --git a/cmake/BuildLibYAML.cmake b/cmake/BuildLibYAML.cmake index 7caa1828cad1d946f2ee91e533cf096f161842a3..a1bc8b4efbe3fbb6b983a45670a299bea1e3bcfd 100644 --- a/cmake/BuildLibYAML.cmake +++ b/cmake/BuildLibYAML.cmake @@ -6,7 +6,7 @@ macro(libyaml_build) add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/libyaml EXCLUDE_FROM_ALL) # See comments in BuildLibEV.cmake - set_target_properties(yaml PROPERTIES COMPILE_FLAGS "-w") + set_target_properties(yaml PROPERTIES COMPILE_FLAGS "${DEPENDENCY_CFLAGS} -w") find_package_message(LIBYAML "Using bundled libyaml" @@ -14,4 +14,3 @@ macro(libyaml_build) unset(yaml_src) endmacro(libyaml_build) - diff --git a/cmake/BuildMisc.cmake b/cmake/BuildMisc.cmake index 7b11acb1145508e4f59cd5cb83391bf11ec2c747..edd076528bc844872d2844da41050021aa7cfeaf 100644 --- a/cmake/BuildMisc.cmake +++ b/cmake/BuildMisc.cmake @@ -32,6 +32,7 @@ macro(libmisc_build) endif() add_library(misc STATIC ${misc_src}) + set_target_properties(misc PROPERTIES COMPILE_FLAGS "${DEPENDENCY_CFLAGS}") if (HAVE_OPENMP) if(BUILD_STATIC) diff --git a/cmake/BuildNghttp2.cmake b/cmake/BuildNghttp2.cmake index 54c37137fa0c76323cabb9fde6bd8c89d14a5bbf..464eafaecf9de7318a72e55ffb507d226b1dc5c4 100644 --- a/cmake/BuildNghttp2.cmake +++ b/cmake/BuildNghttp2.cmake @@ -1,12 +1,12 @@ # # A macro to build the bundled nghttp2 library. -macro(nghttp2_build CFLAGS) +macro(nghttp2_build) set(NGHTTP2_SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/nghttp2) set(NGHTTP2_BINARY_DIR ${PROJECT_BINARY_DIR}/build/nghttp2/work) set(NGHTTP2_INSTALL_DIR ${PROJECT_BINARY_DIR}/build/nghttp2/dest) # See BuildLibCURL.cmake for details. - set(NGHTTP2_CFLAGS ${CFLAGS}) + set(NGHTTP2_CFLAGS ${DEPENDENCY_CFLAGS}) if (TARGET_OS_DARWIN AND NOT "${CMAKE_OSX_SYSROOT}" STREQUAL "") set(NGHTTP2_CFLAGS "${NGHTTP2_CFLAGS} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}") endif() diff --git a/cmake/BuildZSTD.cmake b/cmake/BuildZSTD.cmake index 9b2e1b9dbae9dd09a3d1e2f1a697c149a3a8dd85..995a5245de8d0acc404443b2f67d9fb4483827b6 100644 --- a/cmake/BuildZSTD.cmake +++ b/cmake/BuildZSTD.cmake @@ -26,13 +26,12 @@ macro(zstd_build) third_party/zstd/lib/compress/zstd_compress_sequences.c third_party/zstd/lib/compress/zstd_compress_literals.c ) - + set(zstd_cflags "${DEPENDENCY_CFLAGS} -Ofast") if (CC_HAS_WNO_IMPLICIT_FALLTHROUGH) - set_source_files_properties(${zstd_src} - PROPERTIES COMPILE_FLAGS -Wno-implicit-fallthrough) + set(zstd_cflags "${zstd_cflags} -Wno-implicit-fallthrough") endif() set_source_files_properties(${zstd_src} - PROPERTIES COMPILE_FLAGS -Ofast) + PROPERTIES COMPILE_FLAGS ${zstd_cflags}) add_library(zstd STATIC ${zstd_src}) set(ZSTD_LIBRARIES zstd)