From 218435d88eb86d474beda94a0c8551d7f39847b7 Mon Sep 17 00:00:00 2001 From: "Anton D. Kachalov" Date: Mon, 14 Dec 2020 09:03:29 -0800 Subject: [PATCH] Make compiler/linker flags visible to dependencies. PiperOrigin-RevId: 347396613 Change-Id: Ic80b6a731a3b182f3aa320d36b598d074e7f3802 --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b06272c..446fc20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,14 @@ set(SAPI_SOURCE_DIR "${PROJECT_SOURCE_DIR}" CACHE INTERNAL "" FORCE) include(CheckCXXCompilerFlag) +# TODO(cblichmann): Only apply this to SAPI and its dependencies +add_compile_options(-fno-exceptions) + +if(SAPI_HARDENED_SOURCE) + add_compile_options(-fstack-protector -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2) + add_link_options(-Wl,-z,relro -Wl,-z,now) +endif() + # Sapi CMake modules, order matters list(APPEND CMAKE_MODULE_PATH "${SAPI_SOURCE_DIR}/cmake") include(SapiOptions) @@ -55,14 +63,6 @@ if(SAPI_FORCE_COLOR_OUTPUT) endif() endif() -# TODO(cblichmann): Only apply this to SAPI and its dependencies -add_compile_options(-fno-exceptions) - -if(SAPI_HARDENED_SOURCE) - add_compile_options(-fstack-protector -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2) - add_link_options(-Wl,-z,relro -Wl,-z,now) -endif() - # Make Bazel-style includes work configure_file(cmake/libcap_capability.h.in libcap/include/sys/capability.h