Skip to content

Commit

Permalink
[INFRA] Remove workarounds for older CMake versions
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Dec 6, 2024
1 parent bda7377 commit df6bb22
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 82 deletions.
17 changes: 5 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,11 @@ 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
10 changes: 3 additions & 7 deletions test/cmake/include_dependencies/add_include_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,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
10 changes: 1 addition & 9 deletions test/cmake/seqan3_path_longest_stem.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@

# 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
42 changes: 18 additions & 24 deletions test/external_project/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ 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
7 changes: 2 additions & 5 deletions test/external_project/seqan3_installed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,5 @@ find_package (seqan3 3.0 REQUIRED)
# build app with seqan3
add_executable (hello_world ../src/hello_world.cpp)
target_link_libraries (hello_world seqan3::seqan3)
if (CMAKE_VERSION VERSION_LESS 3.14)
install (TARGETS hello_world RUNTIME DESTINATION bin)
else ()
install (TARGETS hello_world) # RUNTIME DESTINATION not needed anymore since cmake 3.14
endif ()

install (TARGETS hello_world)
6 changes: 1 addition & 5 deletions test/external_project/seqan3_setup_tutorial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,4 @@ add_executable (another_program another_program.cpp)
target_link_libraries (another_program seqan3::seqan3)
## [adding_files]

if (CMAKE_VERSION VERSION_LESS 3.14)
install (TARGETS hello_world another_program RUNTIME DESTINATION bin)
else ()
install (TARGETS hello_world another_program) # RUNTIME DESTINATION not needed anymore since cmake 3.14
endif ()
install (TARGETS hello_world another_program)
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,4 @@ add_executable (another_program another_program.cpp)
target_link_libraries (another_program seqan3::seqan3 sharg::sharg)
## [adding_files]

if (CMAKE_VERSION VERSION_LESS 3.14)
install (TARGETS hello_world another_program RUNTIME DESTINATION bin)
else ()
install (TARGETS hello_world another_program) # RUNTIME DESTINATION not needed anymore since cmake 3.14
endif ()
install (TARGETS hello_world another_program)
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,5 @@ find_package (sharg 1.0 REQUIRED)
# build app with seqan3
add_executable (hello_world ../src/hello_world.cpp)
target_link_libraries (hello_world seqan3::seqan3 sharg::sharg)
if (CMAKE_VERSION VERSION_LESS 3.14)
install (TARGETS hello_world RUNTIME DESTINATION bin)
else ()
install (TARGETS hello_world) # RUNTIME DESTINATION not needed anymore since cmake 3.14
endif ()

install (TARGETS hello_world)
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,5 @@ add_subdirectory ("${SEQAN3_ROOT}" "seqan3_build")
# build app with seqan3
add_executable (hello_world ../src/hello_world.cpp)
target_link_libraries (hello_world seqan3::seqan3)
if (CMAKE_VERSION VERSION_LESS 3.14)
install (TARGETS hello_world RUNTIME DESTINATION bin)
else ()
install (TARGETS hello_world) # RUNTIME DESTINATION not needed anymore since cmake 3.14
endif ()

install (TARGETS hello_world)
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,4 @@ find_package (seqan3 3.0 REQUIRED)
# build app with seqan3
add_executable (hello_world ../src/hello_world.cpp)
target_link_libraries (hello_world seqan3::seqan3)
if (CMAKE_VERSION VERSION_LESS 3.14)
install (TARGETS hello_world RUNTIME DESTINATION bin)
else ()
install (TARGETS hello_world) # RUNTIME DESTINATION not needed anymore since cmake 3.14
endif ()
install (TARGETS hello_world)

0 comments on commit df6bb22

Please sign in to comment.