Skip to content

Commit

Permalink
[INFRA] Bump CMake
Browse files Browse the repository at this point in the history
CPP23 detection needs 3.20, 3.10 and older will also be deprecated
  • Loading branch information
eseiler committed Dec 4, 2024
1 parent 91a148a commit 71019b0
Show file tree
Hide file tree
Showing 42 changed files with 82 additions and 126 deletions.
19 changes: 6 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,18 @@
# SeqAn3. To build tests, run cmake on one of the sub-folders in this directory
# which contain a CMakeLists.txt.

cmake_minimum_required (VERSION 3.5...3.30)
cmake_minimum_required (VERSION 3.20...3.31)

find_path (SEQAN3_MODULE_PATH "seqan3-config.cmake" HINTS "${CMAKE_CURRENT_LIST_DIR}/cmake/")
list (APPEND CMAKE_MODULE_PATH "${SEQAN3_MODULE_PATH}")

include (seqan3-config-version)

if (CMAKE_VERSION VERSION_LESS 3.12)
project (seqan3
LANGUAGES CXX
VERSION "${SEQAN3_PROJECT_VERSION}")
else ()
project (seqan3
LANGUAGES CXX
VERSION "${SEQAN3_PROJECT_VERSION}"
DESCRIPTION "SeqAn3 -- the modern C++ library for sequence analysis" # since cmake 3.9
HOMEPAGE_URL "https://github.com/seqan/seqan3" # since cmake 3.12
)
endif ()
project (seqan3
LANGUAGES CXX
VERSION "${SEQAN3_PROJECT_VERSION}"
DESCRIPTION "SeqAn3 -- the modern C++ library for sequence analysis"
HOMEPAGE_URL "https://github.com/seqan/seqan3")

find_package (SeqAn3 3.0 REQUIRED HINTS ${SEQAN3_MODULE_PATH})

Expand Down
8 changes: 5 additions & 3 deletions cmake/seqan3-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#
# ============================================================================

cmake_minimum_required (VERSION 3.5...3.30)
cmake_minimum_required (VERSION 3.20...3.31)

# ----------------------------------------------------------------------------
# Set initial variables
Expand Down Expand Up @@ -350,7 +350,8 @@ set (CXXSTD_TEST_SOURCE "#include <seqan3/core/platform.hpp>
# 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 (SEQAN3_PLATFORM_TEST #
# cmake-format: off
try_compile (SEQAN3_PLATFORM_TEST
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_INCLUDE_PATH};${SEQAN3_INCLUDE_DIR};${SEQAN3_DEPENDENCY_INCLUDE_DIRS}"
Expand All @@ -360,6 +361,7 @@ try_compile (SEQAN3_PLATFORM_TEST #
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
OUTPUT_VARIABLE SEQAN3_PLATFORM_TEST_OUTPUT)
# cmake-format: on

if (SEQAN3_PLATFORM_TEST)
seqan3_config_print ("SeqAn3 platform.hpp build: passed.")
Expand Down Expand Up @@ -401,7 +403,7 @@ set (SEQAN3_INCLUDE_DIRS ${SEQAN3_INCLUDE_DIR} ${SEQAN3_DEPENDENCY_INCLUDE_DIRS}
if (SEQAN3_FOUND AND NOT TARGET seqan3::seqan3)
add_library (seqan3_seqan3 INTERFACE)
target_compile_definitions (seqan3_seqan3 INTERFACE ${SEQAN3_DEFINITIONS})
target_compile_features(seqan3_seqan3 INTERFACE cxx_std_23)
target_compile_features (seqan3_seqan3 INTERFACE cxx_std_23)
target_link_libraries (seqan3_seqan3 INTERFACE "${SEQAN3_LIBRARIES}")
# include seqan3/include/ as -I, because seqan3 should never produce warnings.
target_include_directories (seqan3_seqan3 INTERFACE "${SEQAN3_INCLUDE_DIR}")
Expand Down
2 changes: 1 addition & 1 deletion cmake/seqan3-install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# This file describes where and which parts of SeqAn3 should be installed to.

cmake_minimum_required (VERSION 3.14...3.30)
cmake_minimum_required (VERSION 3.20...3.31)

include (GNUInstallDirs)

Expand Down
2 changes: 1 addition & 1 deletion cmake/seqan3-package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# This file describes how SeqAn3 will be packaged.

cmake_minimum_required (VERSION 3.7...3.30)
cmake_minimum_required (VERSION 3.20...3.31)

set (CPACK_GENERATOR "TXZ")

Expand Down
2 changes: 1 addition & 1 deletion doc/setup/quickstart_cmake/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ For example, after adding `another_program.cpp` your `CMakeLists.txt` may look l
# Including SeqAn3 as external project

```cmake
cmake_minimum_required (VERSION 3.14...3.30)
cmake_minimum_required (VERSION 3.20...3.31)
project (my_app LANGUAGES CXX VERSION 1.0.0)
Expand Down
2 changes: 1 addition & 1 deletion test/analyse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.30)
cmake_minimum_required (VERSION 3.20...3.31)
project (seqan3_test_analyze CXX)

include (../seqan3-test.cmake)
Expand Down
2 changes: 1 addition & 1 deletion test/api_stability/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
# SPDX-License-Identifier: CC0-1.0

cmake_minimum_required (VERSION 3.8...3.30)
cmake_minimum_required (VERSION 3.20...3.31)

project (api_stability)

Expand Down
2 changes: 1 addition & 1 deletion test/cmake/add_subdirectories.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.30)
cmake_minimum_required (VERSION 3.20...3.31)

# Calls add_subdirectory on all (direct) subdirectories of the given directory if they contain a `CMakeLists.txt`
#
Expand Down
2 changes: 1 addition & 1 deletion test/cmake/diagnostics/list_missing_unit_tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.30)
cmake_minimum_required (VERSION 3.20...3.31)

set (seqan3_test_include_targets
""
Expand Down
2 changes: 1 addition & 1 deletion test/cmake/diagnostics/list_unused_snippets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.30)
cmake_minimum_required (VERSION 3.20...3.31)

set (seqan3_test_snippets
""
Expand Down
2 changes: 1 addition & 1 deletion test/cmake/diagnostics/list_unused_unit_tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.30)
cmake_minimum_required (VERSION 3.20...3.31)

set (seqan3_test_targets
""
Expand Down
12 changes: 4 additions & 8 deletions test/cmake/include_dependencies/add_include_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.30)
cmake_minimum_required (VERSION 3.20...3.31)

include (diagnostics/list_missing_unit_tests)

Expand Down Expand Up @@ -58,13 +58,9 @@ function (add_include_dependencies target target_cyclic_depending_includes)
return ()
endif ()

# in cmake 3.20 they changed the way how the dependency files are generated,
# we can for now re-enable the old behaviour by setting this config.
if (NOT CMAKE_VERSION VERSION_LESS 3.20) # cmake >= 3.20
if (NOT (DEFINED CMAKE_DEPENDS_USE_COMPILER) OR CMAKE_DEPENDS_USE_COMPILER)
message (FATAL_ERROR "Starting with CMake 3.20, you need to specify -DCMAKE_DEPENDS_USE_COMPILER=OFF when "
"using -DSEQAN3_USE_INCLUDE_DEPENDENCIES=ON.")
endif ()
if (NOT (DEFINED CMAKE_DEPENDS_USE_COMPILER) OR CMAKE_DEPENDS_USE_COMPILER)
message (FATAL_ERROR "Starting with CMake 3.20, you need to specify -DCMAKE_DEPENDS_USE_COMPILER=OFF when "
"using -DSEQAN3_USE_INCLUDE_DEPENDENCIES=ON.")
endif ()

get_include_target (include_target TARGET "${target}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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...3.30)
cmake_minimum_required (VERSION 3.20...3.31)

function (generate_include_dependencies_impl)
cmake_parse_arguments (
Expand Down
2 changes: 1 addition & 1 deletion test/cmake/seqan3_generate_snippet.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.30)
cmake_minimum_required (VERSION 3.20...3.31)

# Generate snippets from a source_snippet
#
Expand Down
2 changes: 1 addition & 1 deletion test/cmake/seqan3_macro_benchmark.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.30)
cmake_minimum_required (VERSION 3.20...3.31)

# Adds a macro benchmark target and a test which executes that macro benchmark
#
Expand Down
12 changes: 2 additions & 10 deletions test/cmake/seqan3_path_longest_stem.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@
# 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)
cmake_minimum_required (VERSION 3.20...3.31)

# A compatible function for cmake < 3.20 that basically returns `cmake_path (GET <filename> STEM LAST_ONLY <out_var>)`
function (seqan3_path_longest_stem out_var filename)
if (CMAKE_VERSION VERSION_LESS 3.20) # cmake < 3.20
get_filename_component (result "${filename}" NAME)
if (result MATCHES "\\.")
string (REGEX REPLACE "(.+)[.].*" "\\1" result "${result}")
endif ()
else () # cmake >= 3.20
cmake_path (GET filename STEM LAST_ONLY result)
endif ()

cmake_path (GET filename STEM LAST_ONLY result)
set ("${out_var}"
"${result}"
PARENT_SCOPE) # out-var
Expand Down
2 changes: 1 addition & 1 deletion test/cmake/seqan3_require_ccache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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...3.30)
cmake_minimum_required (VERSION 3.20...3.31)

# This file's only purpose is to be replaced with the content of the use_ccache CMakeLists.txt file
# when creating the source package.
Expand Down
2 changes: 1 addition & 1 deletion test/cmake/seqan3_test_component.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.30)
cmake_minimum_required (VERSION 3.20...3.31)

include (seqan3_path_longest_stem)

Expand Down
2 changes: 1 addition & 1 deletion test/cmake/seqan3_test_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.30)
cmake_minimum_required (VERSION 3.20...3.31)

# Finds all files relative to the `test_base_path_` which satisfy the given file pattern.
#
Expand Down
2 changes: 1 addition & 1 deletion test/coverage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.30)
cmake_minimum_required (VERSION 3.20...3.31)
project (seqan3_test_coverage CXX)

# Add a custom build type: Coverage
Expand Down
2 changes: 1 addition & 1 deletion test/documentation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: BSD-3-Clause

# Minimum cmake version
cmake_minimum_required (VERSION 3.7...3.30)
cmake_minimum_required (VERSION 3.20...3.31)

### Find seqan3
include (../../cmake/seqan3-config-version.cmake)
Expand Down
2 changes: 1 addition & 1 deletion test/documentation/seqan3-doxygen-layout.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.30)
cmake_minimum_required (VERSION 3.20...3.31)

include (${SEQAN3_INCLUDE_DIR}/../test/cmake/seqan3_test_files.cmake)

Expand Down
2 changes: 1 addition & 1 deletion test/documentation/seqan3-doxygen-package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.30)
cmake_minimum_required (VERSION 3.20...3.31)

set (CPACK_GENERATOR "TXZ")

Expand Down
2 changes: 1 addition & 1 deletion test/documentation/seqan3-doxygen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.30)
cmake_minimum_required (VERSION 3.20...3.31)

### Find doxygen and dependency to DOT tool
message (STATUS "Searching for doxygen.")
Expand Down
44 changes: 19 additions & 25 deletions test/external_project/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
# SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
# SPDX-License-Identifier: BSD-3-Clause

cmake_minimum_required (VERSION 3.5...3.30)
cmake_minimum_required (VERSION 3.20...3.31)
project (seqan3_test_external_project CXX)

include (../seqan3-test.cmake) # for SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS, SEQAN3_VERSION
include (ExternalProject)

set (SEQAN3_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../")

if (NOT ${CMAKE_VERSION} VERSION_LESS 3.14) # cmake 3.14 version is needed to install seqan3.
include (install-seqan3.cmake)
include (install-sharg.cmake)
endif ()
include (install-seqan3.cmake)
include (install-sharg.cmake)

option (SEQAN3_EXTERNAL_PROJECT_FIND_DEBUG_MODE
"Enable this option if you want to get a detailed list which paths were considered for find_package(...)" false)
Expand Down Expand Up @@ -72,16 +70,14 @@ ExternalProject_Add (
# We need CMake >= 3.14 to be able to package seqan3, but we actually expect that this
# test works with CMake >= 3.5.
# (ExternalProject_Add simulates a fresh and separate invocation of cmake ../)
if (NOT ${CMAKE_VERSION} VERSION_LESS 3.14) # cmake 3.14 version is needed to install seqan3.
ExternalProject_Add (
seqan3_installed
PREFIX seqan3_installed
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/seqan3_installed"
CMAKE_ARGS ${SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS}
"-DCMAKE_FIND_DEBUG_MODE=${SEQAN3_EXTERNAL_PROJECT_FIND_DEBUG_MODE}"
"-DCMAKE_SYSTEM_PREFIX_PATH=${SEQAN3_SYSTEM_PREFIX}")
add_dependencies (seqan3_installed seqan3_test_prerequisite)
endif ()
ExternalProject_Add (
seqan3_installed
PREFIX seqan3_installed
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/seqan3_installed"
CMAKE_ARGS ${SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS}
"-DCMAKE_FIND_DEBUG_MODE=${SEQAN3_EXTERNAL_PROJECT_FIND_DEBUG_MODE}"
"-DCMAKE_SYSTEM_PREFIX_PATH=${SEQAN3_SYSTEM_PREFIX}")
add_dependencies (seqan3_installed seqan3_test_prerequisite)

# 4) This tests test/external_project/seqan3_fetch_content_zip/CMakeLists.txt
# It uses fetch_content (a CMake 3.14 feature) to download our zip-release (e.g. zip, tar.xz) from
Expand All @@ -90,16 +86,14 @@ endif ()
# Note that FetchContent is a CMake >= 3.14 feature.
# This is expected to work with CMake >= 3.14.
# (ExternalProject_Add simulates a fresh and separate invocation of cmake ../)
if (NOT ${CMAKE_VERSION} VERSION_LESS 3.14) # cmake 3.14 version is needed to use fetch_content.
ExternalProject_Add (
seqan3_fetch_content_zip
PREFIX seqan3_fetch_content_zip
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/seqan3_fetch_content_zip"
CMAKE_ARGS ${SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS}
"-DCMAKE_FIND_DEBUG_MODE=${SEQAN3_EXTERNAL_PROJECT_FIND_DEBUG_MODE}"
"-DSEQAN3_PACKAGE_ZIP_URL=${SEQAN3_PACKAGE_ZIP_URL}")
add_dependencies (seqan3_fetch_content_zip seqan3_test_prerequisite)
endif ()
ExternalProject_Add (
seqan3_fetch_content_zip
PREFIX seqan3_fetch_content_zip
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/seqan3_fetch_content_zip"
CMAKE_ARGS ${SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS}
"-DCMAKE_FIND_DEBUG_MODE=${SEQAN3_EXTERNAL_PROJECT_FIND_DEBUG_MODE}"
"-DSEQAN3_PACKAGE_ZIP_URL=${SEQAN3_PACKAGE_ZIP_URL}")
add_dependencies (seqan3_fetch_content_zip seqan3_test_prerequisite)

# 5) This test is the same as 2) but emulates the settings within the setup tutorial.
# This test is used as snippet in the setup tutorial.
Expand Down
2 changes: 1 addition & 1 deletion test/external_project/install-seqan3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.14...3.30)
cmake_minimum_required (VERSION 3.20...3.31)

# install and package seqan3 library
ExternalProject_Add (
Expand Down
2 changes: 1 addition & 1 deletion test/external_project/install-sharg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.14...3.30)
cmake_minimum_required (VERSION 3.20...3.31)

# We can only set one CMAKE_SYSTEM_PREFIX_PATH, i.e. it cannot be a list.
# Hence we need to reuse the SEQAN3_SYSTEM_PREFIX.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.14...3.30)
cmake_minimum_required (VERSION 3.20...3.31)
project (seqan3_app CXX)

# --- helper scripts
Expand Down
Loading

0 comments on commit 71019b0

Please sign in to comment.