Skip to content

Commit

Permalink
[INFRA] Bump to C++23
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Aug 28, 2024
1 parent 0cab5ec commit 99b45b9
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
compiler: ["clang-18", "clang-17", "gcc-14", "gcc-13", "gcc-12", "gcc-11", "intel"]
compiler: ["clang-18", "clang-17", "gcc-14", "gcc-13", "gcc-12", "intel"]
container:
image: ghcr.io/seqan/${{ matrix.compiler }}
volumes:
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 @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
compiler: ["clang-18", "clang-17", "gcc-14", "gcc-13", "gcc-12", "gcc-11"]
compiler: ["clang-18", "clang-17", "gcc-14", "gcc-13", "gcc-12"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/ci_misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ jobs:
use_include_dependencies: "OFF"
cxx_flags: "-stdlib=libc++"

- name: "Snippet gcc11"
compiler: "gcc-11"
- name: "Snippet gcc12"
compiler: "gcc-12"
build: snippet
build_type: Release
use_include_dependencies: "OFF"
Expand All @@ -53,8 +53,8 @@ jobs:
use_include_dependencies: "OFF"
cxx_flags: "-stdlib=libc++"

- name: "Performance gcc11"
compiler: "gcc-11"
- name: "Performance gcc12"
compiler: "gcc-12"
build: performance
build_type: Release
use_include_dependencies: "OFF"
Expand All @@ -72,8 +72,8 @@ jobs:
build_type: Release
use_include_dependencies: "OFF"

- name: "Header gcc11"
compiler: "gcc-11"
- name: "Header gcc12"
compiler: "gcc-12"
build: header
build_type: Release
use_include_dependencies: "OFF"
Expand All @@ -85,7 +85,7 @@ jobs:
use_include_dependencies: "ON"

- name: "Tutorial"
compiler: "gcc-11"
compiler: "gcc-12"
build: tutorial
build_type: Debug
use_include_dependencies: "OFF"
Expand Down
4 changes: 2 additions & 2 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

set (CPM_DOWNLOAD_VERSION 0.38.6)
set (CPM_HASH_SUM "11c3fa5f1ba14f15d31c2fb63dbc8628ee133d81c8d764caad9a8db9e0bacb07")
set (CPM_DOWNLOAD_VERSION 0.40.2)
set (CPM_HASH_SUM "c8cdc32c03816538ce22781ed72964dc864b2a34a310d3b7104812a5ca2d835d")

if (CPM_SOURCE_CACHE)
set (CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
Expand Down
35 changes: 17 additions & 18 deletions cmake/configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,43 +79,42 @@ include ("${HIBF_SOURCE_DIR}/test/cmake/hibf_require_ccache.cmake")
hibf_require_ccache ()

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

set (CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})

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

set (HIBF_FEATURE_CPP20_FLAG_BUILTIN "")
set (HIBF_FEATURE_CPP20_FLAG_STD20 "-std=c++20")
set (HIBF_FEATURE_CPP20_FLAG_STD2a "-std=c++2a")
set (HIBF_FEATURE_CPP23_FLAG_BUILTIN "")
set (HIBF_FEATURE_CPP23_FLAG_STD23 "-std=c++23")

set (HIBF_CPP20_FLAG "")
set (HIBF_CPP23_FLAG "")

foreach (_FLAG BUILTIN STD20 STD2a)
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_SAVE} ${HIBF_FEATURE_CPP20_FLAG_${_FLAG}}")
foreach (_FLAG BUILTIN STD23)
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_SAVE} ${HIBF_FEATURE_CPP23_FLAG_${_FLAG}}")

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

if (CPP20_FLAG_${_FLAG})
set (HIBF_CPP20_FLAG ${_FLAG})
if (CPP23_FLAG_${_FLAG})
set (HIBF_CPP23_FLAG ${_FLAG})
break ()
endif ()
endforeach ()

set (CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})

if (HIBF_CPP20_FLAG STREQUAL "BUILTIN")
hibf_config_print ("C++ Standard-20 support: builtin")
elseif (HIBF_CPP20_FLAG)
set (HIBF_CXX_FLAGS "${HIBF_CXX_FLAGS} ${HIBF_FEATURE_CPP20_FLAG_${HIBF_CPP20_FLAG}}")
hibf_config_print ("C++ Standard-20 support: via ${HIBF_FEATURE_CPP20_FLAG_${HIBF_CPP20_FLAG}}")
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}}")
hibf_config_print ("C++ Standard-23 support: via ${HIBF_FEATURE_CPP23_FLAG_${HIBF_CPP23_FLAG}}")
else ()
hibf_config_error ("HIBF requires C++20, but your compiler does not support it.")
hibf_config_error ("HIBF requires C++23, but your compiler does not support it.")
endif ()

# ----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion cmake/package-lock.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CPMDeclarePackage (benchmark
# googletest
set (HIBF_GOOGLETEST_VERSION 1.14.0)
CPMDeclarePackage (googletest
NAME GTest
NAME googletest
VERSION ${HIBF_GOOGLETEST_VERSION}
GITHUB_REPOSITORY google/googletest
SYSTEM TRUE
Expand Down
15 changes: 5 additions & 10 deletions include/hibf/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,9 @@
// ============================================================================

#if HIBF_COMPILER_IS_GCC
# if (__GNUC__ < 11)
# error "At least GCC 11 is needed."
# endif // (__GNUC__ < 11)

# if (__GNUC__ == 11 && __GNUC_MINOR__ <= 3)
# pragma warning "Be aware that GCC < 11.4 might have bugs that cause compile failure."
# endif // (__GNUC__ == 11 && __GNUC_MINOR__ <= 3)
# if (__GNUC__ < 12)
# error "At least GCC 12 is needed."
# endif // (__GNUC__ < 12)

# if (__GNUC__ == 12 && __GNUC_MINOR__ <= 2)
# pragma warning "Be aware that GCC < 12.3 might have bugs that cause compile failure."
Expand Down Expand Up @@ -100,10 +96,9 @@
#endif

// C++ standard [required]
// Note: gcc10 -std=c++20 still defines __cplusplus=201709
#ifdef __cplusplus
# if (__cplusplus < 201709)
# error "C++20 is required, make sure that you have set -std=c++20."
# if (__cplusplus < 202100)
# error "C++23 is required, make sure that you have set -std=c++23."
# endif
#else
# error "This is not a C++ compiler."
Expand Down
2 changes: 1 addition & 1 deletion util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ list (APPEND CMAKE_PREFIX_PATH "${sharg_SOURCE_DIR}/build_system")
find_package (sharg 1.0 REQUIRED)

add_executable (fpr_correction_check fpr_correction_check.cpp)
target_link_libraries (fpr_correction_check seqan::hibf sharg::sharg)
target_link_libraries (fpr_correction_check sharg::sharg seqan::hibf)

0 comments on commit 99b45b9

Please sign in to comment.