From ad23bf46b607c1f75e63c72ecafd901972869f2d Mon Sep 17 00:00:00 2001 From: Konstantin Podshumok Date: Fri, 14 Aug 2020 02:07:39 +0300 Subject: [PATCH] cmake: message when ThinLTO is enabled without clang Squashed: - ENABLE_THINLTO shouldn't be enabled by default when tests or sanitizers are enabled Signed-off-by: Konstantin Podshumok --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 32edc1b7f9c..cdc23d8aac8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -263,7 +263,9 @@ if (COMPILER_CLANG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-absolute-paths") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-absolute-paths") - option(ENABLE_THINLTO "Enable Thin LTO. Only applicable for clang. It's also suppressed when building with tests or sanitizers." ON) + if (NOT ENABLE_TESTS AND NOT SANITIZE) + option(ENABLE_THINLTO "Enable Thin LTO. Only applicable for clang. It's also suppressed when building with tests or sanitizers." ON) + endif() # We cannot afford to use LTO when compiling unitests, and it's not enough # to only supply -fno-lto at the final linking stage. So we disable it @@ -294,6 +296,8 @@ if (COMPILER_CLANG) else () message(WARNING "Cannot find llvm-ranlib. System ranlib will be used instead. It does not work with ThinLTO.") endif () +elseif (ENABLE_THINLTO) + message (${RECONFIGURE_MESSAGE_LEVEL} "ThinLTO is only available with CLang") endif () option (ENABLE_LIBRARIES "Enable all libraries (Global default switch)" ON)