From d9e4a37dcb900070bcb52034251ffc013e451367 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 28 Oct 2024 16:18:49 +0100 Subject: [PATCH 1/4] [INFRA] Acknowledge CMake 3.30 policies --- cmake/configuration.cmake | 2 +- src/CMakeLists.txt | 2 ++ test/all/CMakeLists.txt | 2 +- test/clang_tidy/CMakeLists.txt | 2 +- test/cmake/diagnostics/list_missing_unit_tests.cmake | 2 +- test/cmake/diagnostics/list_unused_snippets.cmake | 2 +- test/cmake/diagnostics/list_unused_unit_tests.cmake | 2 +- test/cmake/hibf_add_subdirectories.cmake | 2 +- test/cmake/hibf_generate_snippet.cmake | 2 +- test/cmake/hibf_macro_benchmark.cmake | 2 +- test/cmake/hibf_path_longest_stem.cmake | 2 +- test/cmake/hibf_require_ccache.cmake | 2 +- test/cmake/hibf_test_component.cmake | 2 +- test/cmake/hibf_test_files.cmake | 2 +- test/cmake/include_dependencies/add_include_dependencies.cmake | 2 +- .../include_dependencies/generate_include_dependencies.cmake | 2 +- test/coverage/CMakeLists.txt | 2 +- test/documentation/hibf-doxygen-layout.cmake | 2 +- test/documentation/hibf-doxygen-package.cmake | 2 +- test/documentation/hibf-doxygen.cmake | 2 +- test/header/generate_header_source.cmake | 2 +- test/hibf-test.cmake | 2 +- test/iwyu/CMakeLists.txt | 2 +- test/performance/CMakeLists.txt | 2 +- test/snippet/CMakeLists.txt | 2 +- test/snippet/compare_snippet_output.cmake | 2 +- test/tutorial/CMakeLists.txt | 2 +- test/unit/CMakeLists.txt | 2 +- util/CMakeLists.txt | 2 +- 29 files changed, 30 insertions(+), 28 deletions(-) diff --git a/cmake/configuration.cmake b/cmake/configuration.cmake index a38afbf0..66d70001 100644 --- a/cmake/configuration.cmake +++ b/cmake/configuration.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.5...3.12) +cmake_minimum_required (VERSION 3.5...3.30) # ---------------------------------------------------------------------------- # Greeter diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9d240b38..765e84bc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,8 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause +cmake_minimum_required (VERSION 3.10...3.30) + set (HIBF_SOURCE_FILES hierarchical_interleaved_bloom_filter.cpp interleaved_bloom_filter.cpp diff --git a/test/all/CMakeLists.txt b/test/all/CMakeLists.txt index 118aee95..3553e44e 100644 --- a/test/all/CMakeLists.txt +++ b/test/all/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10...3.22) +cmake_minimum_required (VERSION 3.10...3.30) project (hibf_test) option (INSTALL_HIBF "" OFF) diff --git a/test/clang_tidy/CMakeLists.txt b/test/clang_tidy/CMakeLists.txt index 5ec61f52..e421bf11 100644 --- a/test/clang_tidy/CMakeLists.txt +++ b/test/clang_tidy/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) project (hibf_tidy NONE) diff --git a/test/cmake/diagnostics/list_missing_unit_tests.cmake b/test/cmake/diagnostics/list_missing_unit_tests.cmake index 6f8f61d4..6b07a426 100644 --- a/test/cmake/diagnostics/list_missing_unit_tests.cmake +++ b/test/cmake/diagnostics/list_missing_unit_tests.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) set (hibf_test_include_targets "" diff --git a/test/cmake/diagnostics/list_unused_snippets.cmake b/test/cmake/diagnostics/list_unused_snippets.cmake index 11cddf90..dc6570a3 100644 --- a/test/cmake/diagnostics/list_unused_snippets.cmake +++ b/test/cmake/diagnostics/list_unused_snippets.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) set (hibf_test_snippets "" diff --git a/test/cmake/diagnostics/list_unused_unit_tests.cmake b/test/cmake/diagnostics/list_unused_unit_tests.cmake index 17eed9f5..eb44746c 100644 --- a/test/cmake/diagnostics/list_unused_unit_tests.cmake +++ b/test/cmake/diagnostics/list_unused_unit_tests.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) set (hibf_test_targets "" diff --git a/test/cmake/hibf_add_subdirectories.cmake b/test/cmake/hibf_add_subdirectories.cmake index 2ac59911..c0b73f5d 100644 --- a/test/cmake/hibf_add_subdirectories.cmake +++ b/test/cmake/hibf_add_subdirectories.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) # Calls add_subdirectory on all (direct) subdirectories of the given directory if they contain a `CMakeLists.txt` # diff --git a/test/cmake/hibf_generate_snippet.cmake b/test/cmake/hibf_generate_snippet.cmake index c54a6507..df11e654 100644 --- a/test/cmake/hibf_generate_snippet.cmake +++ b/test/cmake/hibf_generate_snippet.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) # Generate snippets from a source_snippet # diff --git a/test/cmake/hibf_macro_benchmark.cmake b/test/cmake/hibf_macro_benchmark.cmake index c6913b42..6062d91a 100644 --- a/test/cmake/hibf_macro_benchmark.cmake +++ b/test/cmake/hibf_macro_benchmark.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) # Adds a macro benchmark target and a test which executes that macro benchmark # diff --git a/test/cmake/hibf_path_longest_stem.cmake b/test/cmake/hibf_path_longest_stem.cmake index 86d63334..ddd09c3d 100644 --- a/test/cmake/hibf_path_longest_stem.cmake +++ b/test/cmake/hibf_path_longest_stem.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) # A compatible function for cmake < 3.20 that basically returns `cmake_path (GET STEM LAST_ONLY )` function (hibf_path_longest_stem out_var filename) diff --git a/test/cmake/hibf_require_ccache.cmake b/test/cmake/hibf_require_ccache.cmake index 4f5233c7..5a5a8081 100644 --- a/test/cmake/hibf_require_ccache.cmake +++ b/test/cmake/hibf_require_ccache.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.15) +cmake_minimum_required (VERSION 3.15...3.30) include (FindPackageMessage) diff --git a/test/cmake/hibf_test_component.cmake b/test/cmake/hibf_test_component.cmake index 56f9ad43..cf0f360c 100644 --- a/test/cmake/hibf_test_component.cmake +++ b/test/cmake/hibf_test_component.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) include (hibf_path_longest_stem) diff --git a/test/cmake/hibf_test_files.cmake b/test/cmake/hibf_test_files.cmake index da01c1c0..ae7692c5 100644 --- a/test/cmake/hibf_test_files.cmake +++ b/test/cmake/hibf_test_files.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) # Finds all files relative to the `test_base_path_` which satisfy the given file pattern. # diff --git a/test/cmake/include_dependencies/add_include_dependencies.cmake b/test/cmake/include_dependencies/add_include_dependencies.cmake index 1a32e964..afd66b9a 100644 --- a/test/cmake/include_dependencies/add_include_dependencies.cmake +++ b/test/cmake/include_dependencies/add_include_dependencies.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) include (diagnostics/list_missing_unit_tests) diff --git a/test/cmake/include_dependencies/generate_include_dependencies.cmake b/test/cmake/include_dependencies/generate_include_dependencies.cmake index 5244fb78..cefff928 100644 --- a/test/cmake/include_dependencies/generate_include_dependencies.cmake +++ b/test/cmake/include_dependencies/generate_include_dependencies.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.12) +cmake_minimum_required (VERSION 3.12...3.30) function (generate_include_dependencies_impl) cmake_parse_arguments ( diff --git a/test/coverage/CMakeLists.txt b/test/coverage/CMakeLists.txt index 87bd3bd7..cb1c03ff 100644 --- a/test/coverage/CMakeLists.txt +++ b/test/coverage/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10...3.22) +cmake_minimum_required (VERSION 3.10...3.30) project (hibf_test_coverage CXX) # Add a custom build type: Coverage diff --git a/test/documentation/hibf-doxygen-layout.cmake b/test/documentation/hibf-doxygen-layout.cmake index 389ee6f4..ac3ae325 100644 --- a/test/documentation/hibf-doxygen-layout.cmake +++ b/test/documentation/hibf-doxygen-layout.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) include (${HIBF_HEADER_PATH}/../test/cmake/hibf_test_files.cmake) diff --git a/test/documentation/hibf-doxygen-package.cmake b/test/documentation/hibf-doxygen-package.cmake index 9734e69f..a5519c2f 100644 --- a/test/documentation/hibf-doxygen-package.cmake +++ b/test/documentation/hibf-doxygen-package.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) set (CPACK_GENERATOR "TXZ") diff --git a/test/documentation/hibf-doxygen.cmake b/test/documentation/hibf-doxygen.cmake index 52bb2a9f..d7a85d92 100644 --- a/test/documentation/hibf-doxygen.cmake +++ b/test/documentation/hibf-doxygen.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) ### Find doxygen and dependency to DOT tool find_package (Doxygen REQUIRED) diff --git a/test/header/generate_header_source.cmake b/test/header/generate_header_source.cmake index 33a729c6..e4d0715c 100644 --- a/test/header/generate_header_source.cmake +++ b/test/header/generate_header_source.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) option (HEADER_FILE_ABSOLUTE "") option (HEADER_FILE_INCLUDE "") diff --git a/test/hibf-test.cmake b/test/hibf-test.cmake index b53ee416..a43fa6a9 100644 --- a/test/hibf-test.cmake +++ b/test/hibf-test.cmake @@ -6,7 +6,7 @@ # HIBF. To build tests, run cmake on one of the sub-folders in this directory # which contain a CMakeLists.txt. -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) # Force alignment of benchmarked loops so that numbers are reliable. # For large loops and erratic seeming bench results the value might diff --git a/test/iwyu/CMakeLists.txt b/test/iwyu/CMakeLists.txt index 3fea3cfb..f62a4c18 100644 --- a/test/iwyu/CMakeLists.txt +++ b/test/iwyu/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) # cmake ../test/iwyu/ -DCMAKE_CXX_COMPILER="clang++-17" -DHIBF_IWYU_DIR=... # make -j2 2> out.txt diff --git a/test/performance/CMakeLists.txt b/test/performance/CMakeLists.txt index 88ae02fa..00430dfa 100644 --- a/test/performance/CMakeLists.txt +++ b/test/performance/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10...3.22) +cmake_minimum_required (VERSION 3.10...3.30) project (hibf_test_performance CXX) include (../hibf-test.cmake) diff --git a/test/snippet/CMakeLists.txt b/test/snippet/CMakeLists.txt index 275195de..f0d41f78 100644 --- a/test/snippet/CMakeLists.txt +++ b/test/snippet/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10...3.22) +cmake_minimum_required (VERSION 3.10...3.30) project (hibf_test_snippet CXX) include (../hibf-test.cmake) diff --git a/test/snippet/compare_snippet_output.cmake b/test/snippet/compare_snippet_output.cmake index c608a398..3da6eefc 100644 --- a/test/snippet/compare_snippet_output.cmake +++ b/test/snippet/compare_snippet_output.cmake @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.10...3.30) include ("${CMAKE_CURRENT_LIST_DIR}/../cmake/hibf_path_longest_stem.cmake") diff --git a/test/tutorial/CMakeLists.txt b/test/tutorial/CMakeLists.txt index de243d88..b5df3063 100644 --- a/test/tutorial/CMakeLists.txt +++ b/test/tutorial/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.16) +cmake_minimum_required (VERSION 3.16...3.30) project (hibf_test_tutorial CXX) set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 6ec535cf..5f91a718 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10...3.22) +cmake_minimum_required (VERSION 3.10...3.30) project (hibf_test_unit CXX) include (../hibf-test.cmake) diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index af84c2c8..37727852 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required (VERSION 3.10...3.22) +cmake_minimum_required (VERSION 3.10...3.30) project (hibf_util CXX) # https://cmake.org/cmake/help/latest/policy/CMP0135.html From 8ef3a7cc0f7ace2ed5a1d2bbf35e4b7b7739ecc1 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 28 Oct 2024 16:18:59 +0100 Subject: [PATCH 2/4] [INFRA] CMake Simplify LTO and other things --- cmake/configuration.cmake | 94 ++++++++++++++------------------------- 1 file changed, 33 insertions(+), 61 deletions(-) diff --git a/cmake/configuration.cmake b/cmake/configuration.cmake index 66d70001..d1739634 100644 --- a/cmake/configuration.cmake +++ b/cmake/configuration.cmake @@ -22,6 +22,8 @@ include (CheckIncludeFileCXX) include (CheckCXXSourceCompiles) include (CheckCXXSourceRuns) include (CheckCXXCompilerFlag) +include (CMakeDependentOption) +include (CheckIPOSupported) # ---------------------------------------------------------------------------- # Find or add dependencies @@ -83,6 +85,7 @@ hibf_require_ccache () # ---------------------------------------------------------------------------- set (CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) +set (HIBF_CXX_FLAGS "") set (CXXSTD_TEST_SOURCE "#if !defined (__cplusplus) || (__cplusplus < 202100) @@ -111,7 +114,7 @@ set (CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) if (HIBF_CPP23_FLAG STREQUAL "BUILTIN") hibf_config_print ("C++ Standard-23 support: builtin") elseif (HIBF_CPP23_FLAG) - set (HIBF_CXX_FLAGS "${HIBF_CXX_FLAGS} ${HIBF_FEATURE_CPP23_FLAG_${HIBF_CPP23_FLAG}}") + list (APPEND HIBF_CXX_FLAGS "${HIBF_FEATURE_CPP23_FLAG_${HIBF_CPP23_FLAG}}") hibf_config_print ("C++ Standard-23 support: via ${HIBF_FEATURE_CPP23_FLAG_${HIBF_CPP23_FLAG}}") else () hibf_config_error ("HIBF requires C++23, but your compiler does not support it.") @@ -150,7 +153,7 @@ endif () check_cxx_compiler_flag ("-Wno-psabi" HIBF_SUPPRESS_GCC4_ABI) if (HIBF_SUPPRESS_GCC4_ABI) - set (HIBF_CXX_FLAGS "${HIBF_CXX_FLAGS} -Wno-psabi") + list (APPEND HIBF_CXX_FLAGS "-Wno-psabi") hibf_config_print ("Suppressing GCC 4 warnings: via -Wno-psabi") endif () @@ -227,68 +230,38 @@ else () set (HIBF_IS_DEBUG FALSE) endif () -# Apple M1 with GCC sets `-march=apple-m1` when using `-march=native`. This option is only available with GCC >= 13. -if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm64" - AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" - AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13) - set (HIBF_M1_NO_NATIVE TRUE) -else () - set (HIBF_M1_NO_NATIVE FALSE) -endif () +check_cxx_compiler_flag ("-march=native" HIBF_HAS_MARCH_NATIVE) +cmake_dependent_option (HIBF_NATIVE_BUILD "Optimize build for current architecture." ON + "HIBF_HAS_MARCH_NATIVE;NOT HIBF_IS_DEBUG" OFF) -option (HIBF_NATIVE_BUILD "Optimize build for current architecture." ON) -if (HIBF_M1_NO_NATIVE) - hibf_config_print ("Optimize build: disabled (Apple M1 with GCC < 13)") -elseif (HIBF_IS_DEBUG) - hibf_config_print ("Optimize build: disabled") -elseif (HIBF_NATIVE_BUILD) - set (HIBF_CXX_FLAGS "${HIBF_CXX_FLAGS} -march=native") +if (HIBF_NATIVE_BUILD) + list (APPEND HIBF_CXX_FLAGS "-march=native") hibf_config_print ("Optimize build: via -march=native") else () check_cxx_compiler_flag ("-mpopcnt" HIBF_HAS_POPCNT) if (HIBF_HAS_POPCNT) - set (HIBF_CXX_FLAGS "${HIBF_CXX_FLAGS} -mpopcnt") + list (APPEND HIBF_CXX_FLAGS "-mpopcnt") hibf_config_print ("Optimize build: via -mpopcnt") else () hibf_config_print ("Optimize build: disabled") endif () endif () -option (HIBF_LTO_BUILD "Use Link Time Optimisation." ON) -if (HIBF_IS_DEBUG OR NOT HIBF_LTO_BUILD) - hibf_config_print ("Link Time Optimisation: disabled") -else () - # CMake's check_ipo_supported uses hardcoded lto flags - # macOS GCC supports -flto-auto, but not the hardcoded flag "-fno-fat-lto-objects" - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") - set (HIBF_LTO_FLAGS "-flto=auto -ffat-lto-objects") - else () - set (HIBF_LTO_FLAGS "-flto=auto") - endif () +check_ipo_supported (RESULT HIBF_HAS_LTO OUTPUT HIBF_HAS_LTO_OUTPUT) +cmake_dependent_option (HIBF_LTO_BUILD "Use Link Time Optimisation." ON "HIBF_HAS_LTO;NOT HIBF_IS_DEBUG" OFF) - set (LTO_CMAKE_SOURCE - "cmake_minimum_required(VERSION ${CMAKE_VERSION})\nproject(lto-test LANGUAGES CXX) - cmake_policy(SET CMP0069 NEW)\nadd_library(foo foo.cpp)\nadd_executable(boo main.cpp) - target_link_libraries(boo PUBLIC foo)") - set (LTO_FOO_CPP "int foo(){return 0x42;}") - set (LTO_MAIN_CPP "int foo();int main(){return foo();}") - set (testdir "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/lto-test") - set (bindir "${testdir}/bin") - set (srcdir "${testdir}/src") - file (MAKE_DIRECTORY "${bindir}") - file (MAKE_DIRECTORY "${srcdir}") - file (WRITE "${srcdir}/foo.cpp" "${LTO_FOO_CPP}") - file (WRITE "${srcdir}/main.cpp" "${LTO_MAIN_CPP}") - file (WRITE "${srcdir}/CMakeLists.txt" "${LTO_CMAKE_SOURCE}") - try_compile (HIBF_HAS_LTO "${bindir}" - "${srcdir}" "lto-test" - CMAKE_FLAGS "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DCMAKE_CXX_FLAGS:STRING=${HIBF_LTO_FLAGS}" - OUTPUT_VARIABLE output) - if (HIBF_HAS_LTO) - hibf_config_print ("Link Time Optimisation: enabled") - set (HIBF_CXX_FLAGS "${HIBF_CXX_FLAGS} ${HIBF_LTO_FLAGS}") +if (HIBF_LTO_BUILD) + set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + list (APPEND HIBF_CXX_FLAGS ${CMAKE_CXX_COMPILE_OPTIONS_IPO}) + hibf_config_print ("Link Time Optimisation: enabled") +else () + if (HIBF_IS_DEBUG) + hibf_config_print ("Link Time Optimisation: disabled") else () - hibf_config_print ("Link Time Optimisation: not available") + set (HIBF_LTO_LOG "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hibf.lto.log") + file (WRITE "${HIBF_LTO_LOG}" "${HIBF_HAS_LTO_OUTPUT}") + hibf_config_print ("Link Time Optimisation: not supported") + hibf_config_print (" See ${HIBF_LTO_LOG}") endif () endif () @@ -357,21 +330,20 @@ set (CXXSTD_TEST_SOURCE "#include int main() {}") # using try_compile instead of check_cxx_source_compiles to capture output in case of failure -file (WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx" "${CXXSTD_TEST_SOURCE}\n") - -try_compile (HIBF_PLATFORM_TEST # - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx - CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${CMAKE_CXX_FLAGS} ${HIBF_CXX_FLAGS}" +list (JOIN HIBF_CXX_FLAGS " " HIBF_TRY_COMPILE_CXX_FLAGS) +# cmake-format: off +try_compile (HIBF_PLATFORM_TEST + SOURCE_FROM_CONTENT src.cxx "#include \nint main() {}" + CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${CMAKE_CXX_FLAGS} ${HIBF_TRY_COMPILE_CXX_FLAGS}" "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_INCLUDE_PATH};${HIBF_HEADER_PATH}" COMPILE_DEFINITIONS ${HIBF_DEFINITIONS} LINK_LIBRARIES ${HIBF_LIBRARIES} OUTPUT_VARIABLE HIBF_PLATFORM_TEST_OUTPUT) - +# cmake-format: on if (HIBF_PLATFORM_TEST) hibf_config_print ("HIBF platform.hpp build: passed") else () - hibf_config_error ("HIBF platform.hpp build: failed\n${HIBF_PLATFORM_TEST_OUTPUT}") + set (HIBF_PLATFORM_TEST_LOG "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hibf.platform.compile.log") + file (WRITE "${HIBF_PLATFORM_TEST_LOG}" "${HIBF_PLATFORM_TEST_OUTPUT}") + hibf_config_error ("HIBF platform.hpp build: failed\n See ${HIBF_PLATFORM_TEST_LOG}") endif () - -separate_arguments (HIBF_CXX_FLAGS UNIX_COMMAND "${HIBF_CXX_FLAGS}") From 9599cd9b45cf64780b35d43f2895641a84897e83 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 28 Oct 2024 16:30:38 +0100 Subject: [PATCH 3/4] [FIX] tmp_directory snippet has no main() --- test/snippet/test/tmp_directory.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/snippet/test/tmp_directory.cpp b/test/snippet/test/tmp_directory.cpp index c3d384e7..962cc1ae 100644 --- a/test/snippet/test/tmp_directory.cpp +++ b/test/snippet/test/tmp_directory.cpp @@ -2,15 +2,13 @@ // SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik // SPDX-License-Identifier: CC0-1.0 -#include // for Test, AssertionResult, TestInfo, EXPECT_TRUE, Message, TEST, TestPar... - #include // for remove #include // for char_traits, operator<<, basic_ostream, ofstream #include // for operator/, sandboxed_path #include // for tmp_directory -TEST(snippet_tmp_directory, tmp_directory_) +int main() { // create a directory folder seqan::hibf::test::tmp_directory tmp{}; @@ -24,6 +22,6 @@ TEST(snippet_tmp_directory, tmp_directory_) std::filesystem::remove(tmp.path() / "somefile.txt"); } - // check that everything was cleanup properly - EXPECT_TRUE(tmp.empty()); + // check that everything was cleaned up properly + assert(tmp.empty()); } From b958084beecc3823f7cf27b96163faf5dcf6ff56 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 28 Oct 2024 16:31:06 +0100 Subject: [PATCH 4/4] [FIX] FetchContent_Populate is deprecated --- test/tutorial/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tutorial/CMakeLists.txt b/test/tutorial/CMakeLists.txt index b5df3063..46aab3d2 100644 --- a/test/tutorial/CMakeLists.txt +++ b/test/tutorial/CMakeLists.txt @@ -26,7 +26,7 @@ FetchContent_Declare ( download_data URL https://ftp.seqan.de/tutorial/hibf/tutorial_files.tar.gz URL_HASH SHA256=e07dd741196cffdc66ae4b0430ca64bdefd50c2af2aff652466585cbb56dceec) -FetchContent_Populate (download_data) +FetchContent_MakeAvailable (download_data) file (REMOVE "${download_data_SOURCE_DIR}/filenames.txt") execute_process (COMMAND "${download_data_SOURCE_DIR}/get_filenames.sh"