Skip to content

Commit

Permalink
Merge pull request #3313 from eseiler/infra/cpp23
Browse files Browse the repository at this point in the history
[MISC] Use cpp23
  • Loading branch information
eseiler authored Dec 13, 2024
2 parents 2d84062 + c4d9939 commit 254ccb2
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
compiler: ["clang-19", "clang-18", "clang-17", "gcc-14", "gcc-13", "gcc-12", "gcc-11", "intel"]
compiler: ["clang-19", "clang-18", "clang-17", "gcc-14", "gcc-13", "gcc-12", "intel"]
include:
- compiler: "intel"
cxx_flags: "-fp-model=strict -Wno-overriding-option"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
compiler: ["clang-19", "clang-18", "clang-17", "gcc-14", "gcc-13", "gcc-12", "gcc-11"]
compiler: ["clang-19", "clang-18", "clang-17", "gcc-14", "gcc-13", "gcc-12"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
compiler: ["clang-19", "gcc-14", "gcc-11", "intel"]
compiler: ["clang-19", "gcc-14", "gcc-12", "intel"]
build: ["snippet", "performance", "header"]
include:
- compiler: "intel"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cron_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
compiler: ["gcc-14", "gcc-13", "gcc-12", "gcc-11"]
compiler: ["gcc-14", "gcc-13", "gcc-12"]
container:
image: ghcr.io/seqan/${{ matrix.compiler }}
volumes:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cron_avx2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
compiler: ["clang-19", "clang-18", "clang-17", "gcc-14", "gcc-13", "gcc-12", "gcc-11", "intel"]
compiler: ["clang-19", "clang-18", "clang-17", "gcc-14", "gcc-13", "gcc-12", "intel"]
build: [unit, snippet, performance, header]
include:
- compiler: "intel"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cron_latest_libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
compiler: ["clang-19", "clang-18", "clang-17", "gcc-14", "gcc-13", "gcc-12", "gcc-11", "intel"]
compiler: ["clang-19", "clang-18", "clang-17", "gcc-14", "gcc-13", "gcc-12", "intel"]
build: [unit, snippet, performance, header]
include:
- compiler: "intel"
Expand Down
3 changes: 1 addition & 2 deletions cmake/package-lock.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ CPMDeclarePackage (googletest
VERSION ${SEQAN3_GOOGLETEST_VERSION}
GITHUB_REPOSITORY google/googletest
SYSTEM TRUE
OPTIONS "BUILD_GMOCK OFF" "INSTALL_GTEST OFF" "CMAKE_CXX_STANDARD 20"
"CMAKE_MESSAGE_LOG_LEVEL WARNING")
OPTIONS "BUILD_GMOCK OFF" "INSTALL_GTEST OFF" "CMAKE_MESSAGE_LOG_LEVEL WARNING")
# doxygen-awesome
set (SEQAN3_DOXYGEN_AWESOME_VERSION 2.3.4)
CPMDeclarePackage (doxygen_awesome
Expand Down
64 changes: 12 additions & 52 deletions cmake/seqan3-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,15 @@
# SEQAN3_INCLUDE_DIRS -- to be passed to include_directories ()
# SEQAN3_LIBRARIES -- to be passed to target_link_libraries ()
# SEQAN3_DEFINITIONS -- to be passed to add_definitions ()
# SEQAN3_CXX_FLAGS -- to be added to CMAKE_CXX_FLAGS
#
# Additionally, the following [IMPORTED][IMPORTED] targets are defined:
#
# seqan3::seqan3 -- interface target where
# target_link_libraries(target seqan3::seqan3)
# automatically sets
# target_include_directories(target $SEQAN3_INCLUDE_DIRS),
# target_link_libraries(target $SEQAN3_LIBRARIES),
# target_compile_definitions(target $SEQAN3_DEFINITIONS) and
# target_compile_options(target $SEQAN3_CXX_FLAGS)
# target_link_libraries(target $SEQAN3_LIBRARIES) and
# target_compile_definitions(target $SEQAN3_DEFINITIONS)
# for a target.
#
# [IMPORTED]: https://cmake.org/cmake/help/v3.10/prop_tgt/IMPORTED.html#prop_tgt:IMPORTED
Expand Down Expand Up @@ -201,53 +199,14 @@ option (SEQAN3_NO_BZIP2 "Don't use BZip2, even if present." OFF)
# Check supported compilers
# ----------------------------------------------------------------------------

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10)
message (FATAL_ERROR "GCC < 10 is not supported. The detected compiler version is ${CMAKE_CXX_COMPILER_VERSION}.")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12)
message (FATAL_ERROR "GCC < 12 is not supported. The detected compiler version is ${CMAKE_CXX_COMPILER_VERSION}.")
endif ()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
message (FATAL_ERROR "Clang < 17 is not supported. The detected compiler version is ${CMAKE_CXX_COMPILER_VERSION}.")
endif ()

# ----------------------------------------------------------------------------
# Require C++20
# ----------------------------------------------------------------------------

set (CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})

set (CXXSTD_TEST_SOURCE
"#if !defined (__cplusplus) || (__cplusplus < 202002L)
#error NOCXX20
#endif
int main() {}")

set (SEQAN3_FEATURE_CPP20_FLAG_BUILTIN "")
set (SEQAN3_FEATURE_CPP20_FLAG_STD20 "-std=c++20")

set (SEQAN3_CPP20_FLAG "")

foreach (_FLAG BUILTIN STD20)
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_SAVE} ${SEQAN3_FEATURE_CPP20_FLAG_${_FLAG}}")

check_cxx_source_compiles ("${CXXSTD_TEST_SOURCE}" CPP20_FLAG_${_FLAG})

if (CPP20_FLAG_${_FLAG})
set (SEQAN3_CPP20_FLAG ${_FLAG})
break ()
endif ()
endforeach ()

set (CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})

if (SEQAN3_CPP20_FLAG STREQUAL "BUILTIN")
seqan3_config_print ("C++ Standard-20 support: builtin")
elseif (SEQAN3_CPP20_FLAG)
set (SEQAN3_CXX_FLAGS "${SEQAN3_CXX_FLAGS} ${SEQAN3_FEATURE_CPP20_FLAG_${SEQAN3_CPP20_FLAG}}")
seqan3_config_print ("C++ Standard-20 support: via ${SEQAN3_FEATURE_CPP20_FLAG_${SEQAN3_CPP20_FLAG}}")
else ()
seqan3_config_error ("SeqAn3 requires C++20, but your compiler does not support it.")
endif ()

# ----------------------------------------------------------------------------
# thread support (pthread, windows threads)
# ----------------------------------------------------------------------------
Expand Down Expand Up @@ -389,14 +348,18 @@ 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 "-DCOMPILE_DEFINITIONS:STRING=${CMAKE_CXX_FLAGS} ${SEQAN3_CXX_FLAGS}"
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_INCLUDE_PATH};${SEQAN3_INCLUDE_DIR};${SEQAN3_DEPENDENCY_INCLUDE_DIRS}"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_INCLUDE_PATH};${SEQAN3_INCLUDE_DIR};${SEQAN3_DEPENDENCY_INCLUDE_DIRS}"
COMPILE_DEFINITIONS ${SEQAN3_DEFINITIONS}
LINK_LIBRARIES ${SEQAN3_LIBRARIES}
CXX_STANDARD 23
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 @@ -436,11 +399,9 @@ set (SEQAN3_INCLUDE_DIRS ${SEQAN3_INCLUDE_DIR} ${SEQAN3_DEPENDENCY_INCLUDE_DIRS}
# ----------------------------------------------------------------------------

if (SEQAN3_FOUND AND NOT TARGET seqan3::seqan3)
separate_arguments (SEQAN3_CXX_FLAGS_LIST UNIX_COMMAND "${SEQAN3_CXX_FLAGS}")

add_library (seqan3_seqan3 INTERFACE)
target_compile_definitions (seqan3_seqan3 INTERFACE ${SEQAN3_DEFINITIONS})
target_compile_options (seqan3_seqan3 INTERFACE ${SEQAN3_CXX_FLAGS_LIST})
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 All @@ -467,7 +428,6 @@ if (SEQAN3_FIND_DEBUG)
message (" SEQAN3_INCLUDE_DIRS ${SEQAN3_INCLUDE_DIRS}")
message (" SEQAN3_LIBRARIES ${SEQAN3_LIBRARIES}")
message (" SEQAN3_DEFINITIONS ${SEQAN3_DEFINITIONS}")
message (" SEQAN3_CXX_FLAGS ${SEQAN3_CXX_FLAGS}")
message ("")
message (" SEQAN3_VERSION ${SEQAN3_VERSION}")
message (" SEQAN3_VERSION_MAJOR ${SEQAN3_VERSION_MAJOR}")
Expand Down
1 change: 1 addition & 0 deletions include/seqan3/argument_parser/validators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <algorithm>
#include <concepts>
#include <exception>
#include <filesystem>
#include <fstream>
#include <ranges>
Expand Down
61 changes: 22 additions & 39 deletions include/seqan3/core/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*
* \sa https://sourceforge.net/p/predef/wiki/Compilers
*/
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER)
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER) && !defined(__INTEL_LLVM_COMPILER)
# define SEQAN3_COMPILER_IS_GCC 1
#else
# define SEQAN3_COMPILER_IS_GCC 0
Expand All @@ -52,60 +52,43 @@
#endif // SEQAN3_DOXYGEN_ONLY(1)0

// ============================================================================
// Compiler support GCC
// Compiler support
// ============================================================================

#if SEQAN3_COMPILER_IS_GCC
# if (__GNUC__ < 11)
# error \
"SeqAn 3.1.x is the last version that supports GCC 7, 8, and 9. SeqAn 3.2.x is the latest version that support GCC 10. Please upgrade your compiler or use 3.1.x./3.2.x."
# endif // (__GNUC__ < 11)

# if (__GNUC__ == 11 && __GNUC_MINOR__ <= 3)
# pragma GCC warning "Be aware that GCC < 11.4 might have bugs that cause SeqAn3 fail to compile."
# endif // (__GNUC__ == 11 && __GNUC_MINOR__ <= 2)

# if (__GNUC__ == 12 && __GNUC_MINOR__ <= 2)
# pragma GCC warning "Be aware that GCC < 12.3 might have bugs that cause SeqAn3 fail to compile."
# endif // (__GNUC__ == 12 && __GNUC_MINOR__ <= 1)
#if SEQAN3_COMPILER_IS_GCC && (__GNUC__ < 12)
# error "At least GCC 12 is needed."
#endif

# if SEQAN3_DOXYGEN_ONLY(1) 0
//!\brief This disables the warning you would get if your compiler is newer than the latest supported version.
# define SEQAN3_DISABLE_NEWER_COMPILER_DIAGNOSTIC
# endif // SEQAN3_DOXYGEN_ONLY(1)0
// clang-format off
#if defined(__INTEL_LLVM_COMPILER) && (__INTEL_LLVM_COMPILER < 20240000)
# error "At least Intel OneAPI 2024 is needed."
#endif
// clang-format on

# ifndef SEQAN3_DISABLE_NEWER_COMPILER_DIAGNOSTIC
# if (__GNUC__ > 14)
# pragma message \
"Your compiler is newer than the latest supported compiler of this SeqAn version (gcc-13). It might be that SeqAn does not compile due to this. You can disable this warning by setting -DSEQAN3_DISABLE_NEWER_COMPILER_DIAGNOSTIC."
# endif // (__GNUC__ > 13)
# endif // SEQAN3_DISABLE_NEWER_COMPILER_DIAGNOSTIC
#if defined(__clang__) && defined(__clang_major__) && (__clang_major__ < 17)
# error "At least Clang 17 is needed."
#endif

// ============================================================================
// Compiler support Clang
// Standard library support
// ============================================================================

#elif defined(__clang__)
# if __clang_major__ < 17
# error "Only Clang >= 17 is supported."
# endif

// ============================================================================
// Compiler support other
// ============================================================================
#if defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION < 170000)
# error "At least libc++ 17 is required."
#endif

#elif !defined(SEQAN3_DISABLE_COMPILER_CHECK)
# error "Your compiler is not supported. You can disable this error by setting -DSEQAN3_DISABLE_COMPILER_CHECK."
#endif // SEQAN3_COMPILER_IS_GCC
#if defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 12)
# error "At least libstdc++ 12 is needed."
#endif

// ============================================================================
// C++ standard and features
// ============================================================================

// C++ standard [required]
#ifdef __cplusplus
# if (__cplusplus < 202002L)
# error "SeqAn3 requires C++20, make sure that you have set -std=c++20."
# if (__cplusplus < 202100)
# error "SeqAn3 requires C++23, make sure that you have set -std=c++23."
# endif
#else
# error "This is not a C++ compiler."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#pragma once

#include <algorithm>
#include <array>
#include <cassert>
#include <iterator>
#include <ranges>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ list (APPEND CMAKE_PREFIX_PATH "${SHARG_ROOT}/build_system")
cmake_minimum_required (VERSION 3.20...3.31)
project (seqan3_tutorial CXX)

set (CMAKE_CXX_STANDARD 23)

# add seqan3 to search path
list (APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../seqan3/cmake")
# add the Sharg Parser to search path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ project (seqan3_app CXX)
include (../find-package-diagnostics.cmake)
# ---

set (CMAKE_CXX_STANDARD 23)

# require seqan3 with a version between >=3.0.0 and <4.0.0
find_package (seqan3 3.0 REQUIRED)
find_package (sharg 1.0 REQUIRED)
Expand Down
12 changes: 12 additions & 0 deletions test/seqan3-test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
# SeqAn3. To build tests, run cmake on one of the sub-folders in this directory
# which contain a CMakeLists.txt.

if (NOT DEFINED CMAKE_CXX_STANDARD)
set (CMAKE_CXX_STANDARD 23)
endif ()

if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
endif ()

if (NOT DEFINED CMAKE_CXX_EXTENSIONS)
set (CMAKE_CXX_EXTENSIONS OFF)
endif ()

# require SeqAn3 package
find_package (SeqAn3 REQUIRED HINTS ${CMAKE_CURRENT_LIST_DIR}/../cmake)

Expand Down

0 comments on commit 254ccb2

Please sign in to comment.