From b0a5a7606516e9b6656d1786e04ad310cc4f55ad Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Wed, 24 Nov 2021 17:40:14 +0100 Subject: [PATCH] adding LTO to tests --- CMakeLists.txt | 6 +++++- cmake/SlsAddFlag.cmake | 16 ++++++++-------- .../moenchExecutables/CMakeLists.txt | 2 +- slsDetectorGui/CMakeLists.txt | 2 +- slsReceiverSoftware/CMakeLists.txt | 4 ++-- tests/CMakeLists.txt | 4 ++++ 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4db277142..85f79865d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,7 +70,11 @@ find_package(ClangFormat) #Enable LTO if available include(CheckIPOSupported) check_ipo_supported(RESULT SLS_LTO_AVAILABLE) -message(STATUS "SLS_LTO_AVAILABLE:" ${SLS_LTO_AVAILABLE}) +if (SLS_LTO_AVAILABLE) + message(STATUS "Building with link time optimization") +else() + message(STATUS "Link time optimization is not available") +endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/cmake/SlsAddFlag.cmake b/cmake/SlsAddFlag.cmake index b4f754afc..4eae60fbe 100644 --- a/cmake/SlsAddFlag.cmake +++ b/cmake/SlsAddFlag.cmake @@ -7,9 +7,9 @@ function(enable_cxx_warning flag target) check_cxx_compiler_flag(${flag} ${flag_name}) if(${flag_name}) target_compile_options(${target} INTERFACE ${flag}) - message("Adding: ${flag} to ${target}") + message(STATUS "Adding: ${flag} to ${target}") else() - message("Flag: ${flag} not supported") + message(STATUS "Flag: ${flag} not supported") endif() endfunction() @@ -18,9 +18,9 @@ function(enable_c_warning flag target) check_c_compiler_flag(${flag} ${flag_name}) if(${flag_name}) target_compile_options(${target} INTERFACE ${flag}) - message("Adding: ${flag} to ${target}") + message(STATUS "Adding: ${flag} to ${target}") else() - message("Flag: ${flag} not supported") + message(STATUS "Flag: ${flag} not supported") endif() endfunction() @@ -31,10 +31,10 @@ function(disable_cxx_warning flag target) if(${flag_name}) string(REPLACE "-W" "-Wno-" neg_flag ${flag}) - message("Adding: ${neg_flag} to ${target}") + message(STATUS "Adding: ${neg_flag} to ${target}") target_compile_options(${target} INTERFACE ${neg_flag}) else() - message("Warning: ${flag} not supported no need to disable") + message(STATUS "Warning: ${flag} not supported no need to disable") endif() endfunction() @@ -43,10 +43,10 @@ function(disable_c_warning flag target) check_c_compiler_flag(${flag} ${flag_name}) if(${flag_name}) string(REPLACE "-W" "-Wno-" neg_flag ${flag}) - message("Adding: ${neg_flag} to ${target}") + message(STATUS "Adding: ${neg_flag} to ${target}") target_compile_options(${target} INTERFACE ${neg_flag}) else() - message("Warning: ${flag} not supported no need to disable") + message(STATUS "Warning: ${flag} not supported no need to disable") endif() endfunction() diff --git a/slsDetectorCalibration/moenchExecutables/CMakeLists.txt b/slsDetectorCalibration/moenchExecutables/CMakeLists.txt index cd7cb6182..e52360f1f 100644 --- a/slsDetectorCalibration/moenchExecutables/CMakeLists.txt +++ b/slsDetectorCalibration/moenchExecutables/CMakeLists.txt @@ -39,7 +39,7 @@ foreach(exe ${MOENCH_EXECUTABLES}) set_target_properties(${exe} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) - if(SLS_LTO_AVAILABLE) + if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) set_property(TARGET ${exe} PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() diff --git a/slsDetectorGui/CMakeLists.txt b/slsDetectorGui/CMakeLists.txt index 75f4ed2f6..aa5583894 100755 --- a/slsDetectorGui/CMakeLists.txt +++ b/slsDetectorGui/CMakeLists.txt @@ -110,7 +110,7 @@ target_link_libraries(slsDetectorGui PUBLIC set_target_properties(slsDetectorGui PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -if(SLS_LTO_AVAILABLE) +if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) set_property(TARGET slsDetectorGui PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() diff --git a/slsReceiverSoftware/CMakeLists.txt b/slsReceiverSoftware/CMakeLists.txt index e138d8fa5..14efab277 100755 --- a/slsReceiverSoftware/CMakeLists.txt +++ b/slsReceiverSoftware/CMakeLists.txt @@ -104,7 +104,7 @@ if (SLS_USE_RECEIVER_BINARIES) set_target_properties(slsReceiver PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) - if(SLS_LTO_AVAILABLE) + if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) set_property(TARGET slsReceiver PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() @@ -124,7 +124,7 @@ if (SLS_USE_RECEIVER_BINARIES) set_target_properties(slsMultiReceiver PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) - if(SLS_LTO_AVAILABLE) + if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) set_property(TARGET slsMultiReceiver PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9c4cc368a..b66f84d37 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -43,6 +43,10 @@ if (SLS_USE_RECEIVER) endif (SLS_USE_RECEIVER) +if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) + set_property(TARGET tests PROPERTY INTERPROCEDURAL_OPTIMIZATION True) +endif() + set_target_properties(tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )