Skip to content

Commit 48edfcb

Browse files
authored
Merge pull request #266 from eseiler/infra/update
[INFRA] Update config, use cpp23
2 parents 52cbeea + 471b4ac commit 48edfcb

File tree

9 files changed

+100
-153
lines changed

9 files changed

+100
-153
lines changed

.github/workflows/ci_coverage.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,9 @@ jobs:
4343
uses: actions/checkout@v4
4444
with:
4545
fetch-depth: 0
46-
submodules: true
4746

48-
- name: Load ccache
49-
uses: actions/cache@v4
50-
with:
51-
path: /home/runner/.ccache
52-
key: ccache-${{ runner.os }}-${{ github.workflow }}-${{ matrix.compiler }}-${{ github.ref }}-${{ github.run_id }}
53-
restore-keys: |
54-
ccache-${{ runner.os }}-${{ github.workflow }}-${{ matrix.compiler }}-${{ github.ref }}
55-
ccache-${{ runner.os }}-${{ github.workflow }}-${{ matrix.compiler }}
47+
- name: Setup cache
48+
uses: seqan/actions/setup-actions-cache@main
5649

5750
- name: Increase ccache size
5851
run: echo "CCACHE_MAXSIZE=300M" >> "${GITHUB_ENV}"

.github/workflows/ci_linux.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,9 @@ jobs:
4444
steps:
4545
- name: Checkout
4646
uses: actions/checkout@v4
47-
with:
48-
submodules: true
4947

50-
- name: Load ccache
51-
uses: actions/cache@v4
52-
with:
53-
path: /home/runner/.ccache
54-
key: ccache-${{ runner.os }}-${{ github.workflow }}-${{ matrix.compiler }}-${{ github.ref }}-${{ github.run_id }}
55-
restore-keys: |
56-
ccache-${{ runner.os }}-${{ github.workflow }}-${{ matrix.compiler }}-${{ github.ref }}
57-
ccache-${{ runner.os }}-${{ github.workflow }}-${{ matrix.compiler }}
48+
- name: Setup cache
49+
uses: seqan/actions/setup-actions-cache@main
5850

5951
- name: Configure tests
6052
run: |

.github/workflows/ci_macos.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ jobs:
3737
steps:
3838
- name: Checkout
3939
uses: actions/checkout@v4
40-
with:
41-
submodules: true
4240

4341
- name: Setup toolchain
4442
uses: seqan/actions/setup-toolchain@main

.github/workflows/ci_misc.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,9 @@ jobs:
4545
steps:
4646
- name: Checkout
4747
uses: actions/checkout@v4
48-
with:
49-
submodules: true
5048

51-
- name: Load ccache
52-
uses: actions/cache@v4
53-
with:
54-
path: /home/runner/.ccache
55-
key: ccache-${{ runner.os }}-${{ github.workflow }}-${{ matrix.build }}-${{ matrix.compiler }}-${{ github.ref }}-${{ github.run_id }}
56-
restore-keys: |
57-
ccache-${{ runner.os }}-${{ github.workflow }}-${{ matrix.build }}-${{ matrix.compiler }}-${{ github.ref }}
58-
ccache-${{ runner.os }}-${{ github.workflow }}-${{ matrix.build }}-${{ matrix.compiler }}
49+
- name: Setup cache
50+
uses: seqan/actions/setup-actions-cache@main
5951

6052
- name: Configure tests
6153
run: |

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ VERSION
163163

164164
| | requirement | version | comment |
165165
|-------------------|-----------------------------------------------------------|----------|---------------------------------------------|
166-
|**compiler** | [GCC](https://gcc.gnu.org) |11 | |
166+
|**compiler** | [GCC](https://gcc.gnu.org) |12 | |
167167
|**compiler** | [Clang](https://clang.llvm.org/) | ≥ 17 | |
168168
|**build system** | [CMake](https://cmake.org) | ≥ 3.16 | optional, but recommended |
169169
|**optional libs** | [TDL](https://github.com/deNBI-cibi/tool_description_lib) | ≥ 1.0.0 | required for CWL and CTD export |

cmake/sharg-config.cmake

Lines changed: 32 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
# SHARG_INCLUDE_DIRS -- to be passed to include_directories ()
4141
# SHARG_LIBRARIES -- to be passed to target_link_libraries ()
4242
# SHARG_DEFINITIONS -- to be passed to add_definitions ()
43-
# SHARG_CXX_FLAGS -- to be added to CMAKE_CXX_FLAGS
4443
#
4544
# Additionally, the following [IMPORTED][IMPORTED] targets are defined:
4645
#
@@ -50,7 +49,6 @@
5049
# target_include_directories(target $SHARG_INCLUDE_DIRS),
5150
# target_link_libraries(target $SHARG_LIBRARIES),
5251
# target_compile_definitions(target $SHARG_DEFINITIONS) and
53-
# target_compile_options(target $SHARG_CXX_FLAGS)
5452
# for a target.
5553
#
5654
# [IMPORTED]: https://cmake.org/cmake/help/v3.10/prop_tgt/IMPORTED.html#prop_tgt:IMPORTED
@@ -154,46 +152,25 @@ set (CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS})
154152
option (SHARG_NO_TDL "Do not use TDL, even if present." OFF)
155153

156154
# ----------------------------------------------------------------------------
157-
# Require C++20
155+
# Check supported compilers
158156
# ----------------------------------------------------------------------------
159157

160-
set (SHARG_CXX_FLAGS "")
161-
162-
set (CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
163-
164-
set (CXXSTD_TEST_SOURCE
165-
"#if !defined (__cplusplus) || (__cplusplus < 202002)
166-
#error NOCXX20
167-
#endif
168-
int main() {}")
169-
170-
check_cxx_source_compiles ("${CXXSTD_TEST_SOURCE}" CXX20_BUILTIN)
171-
172-
if (CXX20_BUILTIN)
173-
sharg_config_print ("C++ Standard-20 support: builtin")
174-
else ()
175-
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_SAVE} -std=c++20")
176-
177-
check_cxx_source_compiles ("${CXXSTD_TEST_SOURCE}" CXX20_FLAG)
178-
179-
if (CXX20_FLAG)
180-
sharg_config_print ("C++ Standard-20 support: via -std=c++20")
181-
else ()
182-
sharg_config_error ("SHARG requires C++20, but your compiler does not support it.")
183-
endif ()
158+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12)
159+
message (FATAL_ERROR "GCC < 12 is not supported. The detected compiler version is ${CMAKE_CXX_COMPILER_VERSION}.")
160+
endif ()
184161

185-
list (APPEND SHARG_CXX_FLAGS "-std=c++20")
162+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
163+
message (FATAL_ERROR "Clang < 17 is not supported. The detected compiler version is ${CMAKE_CXX_COMPILER_VERSION}.")
186164
endif ()
187165

188166
# ----------------------------------------------------------------------------
189167
# thread support (pthread, windows threads)
190168
# ----------------------------------------------------------------------------
191-
set (SHARG_LIBRARIES "")
192169

193170
set (THREADS_PREFER_PTHREAD_FLAG TRUE)
194171
find_package (Threads QUIET)
195172

196-
if (Threads_FOUND)
173+
if (TARGET Threads::Threads)
197174
list (APPEND SHARG_LIBRARIES Threads::Threads)
198175
if ("${CMAKE_THREAD_LIBS_INIT}" STREQUAL "")
199176
sharg_config_print ("Thread support: builtin.")
@@ -207,7 +184,6 @@ endif ()
207184
# ----------------------------------------------------------------------------
208185
# tool description lib (tdl) dependency
209186
# ----------------------------------------------------------------------------
210-
set (SHARG_USE_TDL FALSE)
211187

212188
if (NOT SHARG_NO_TDL)
213189
if (NOT SHARG_HAS_CPM)
@@ -216,42 +192,34 @@ if (NOT SHARG_NO_TDL)
216192
CPMGetPackage (tdl)
217193
endif ()
218194

219-
if (TDL_FOUND OR tdl_ADDED)
195+
if (TARGET tdl::tdl)
220196
sharg_config_print ("Optional dependency: TDL found.")
221-
set (SHARG_USE_TDL TRUE)
197+
list (APPEND SHARG_DEFINITIONS "-DSHARG_HAS_TDL=1")
222198
list (APPEND SHARG_LIBRARIES tdl::tdl)
223199
else ()
224200
sharg_config_print ("Optional dependency: TDL not found.")
201+
list (APPEND SHARG_DEFINITIONS "-DSHARG_HAS_TDL=0")
225202
endif ()
226203
else ()
227204
sharg_config_print ("Optional dependency: TDL deactivated.")
228-
endif ()
229-
230-
if (SHARG_USE_TDL)
231-
set (SHARG_DEFINITIONS ${SHARG_DEFINITIONS} "-DSHARG_HAS_TDL=1")
232-
else ()
233-
set (SHARG_DEFINITIONS ${SHARG_DEFINITIONS} "-DSHARG_HAS_TDL=0")
205+
list (APPEND SHARG_DEFINITIONS "-DSHARG_HAS_TDL=0")
234206
endif ()
235207

236208
# ----------------------------------------------------------------------------
237209
# System dependencies
238210
# ----------------------------------------------------------------------------
239211

240212
# librt
241-
if ((${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
242-
OR (${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD")
243-
OR (${CMAKE_SYSTEM_NAME} STREQUAL "GNU"))
244-
list (APPEND SHARG_LIBRARIES rt)
213+
find_library (SHARG_RT_LIB rt)
214+
if (SHARG_RT_LIB)
215+
list (APPEND SHARG_LIBRARIES ${SHARG_RT_LIB})
245216
endif ()
246217

247218
# libexecinfo -- implicit
248-
check_include_file_cxx (execinfo.h _SHARG_HAVE_EXECINFO)
249-
mark_as_advanced (_SHARG_HAVE_EXECINFO)
250-
if (_SHARG_HAVE_EXECINFO)
219+
find_package (Backtrace QUIET)
220+
if (TARGET Backtrace::Backtrace)
221+
list (APPEND SHARG_LIBRARIES Backtrace::Backtrace)
251222
sharg_config_print ("Optional dependency: libexecinfo found.")
252-
if ((${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") OR (${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD"))
253-
list (APPEND SHARG_LIBRARIES execinfo elf)
254-
endif ()
255223
else ()
256224
sharg_config_print ("Optional dependency: libexecinfo not found.")
257225
endif ()
@@ -260,22 +228,22 @@ endif ()
260228
# Perform compilability test of platform.hpp (tests some requirements)
261229
# ----------------------------------------------------------------------------
262230

263-
set (CXXSTD_TEST_SOURCE "#include <sharg/platform.hpp>
264-
int main() {}")
231+
# cmake-format: off
232+
# Note: With CMake >= 3.25, the file WRITE can be removed, the second and third line in try_compile can be replaced by
233+
# SOURCE_FROM_CONTENT "platform_test.cpp" "#include <sharg/platform.hpp>\nint main() {}"
234+
file (WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/platform_test.cpp"
235+
"#include <sharg/platform.hpp>\nint main() {}")
265236

266-
# using try_compile instead of check_cxx_source_compiles to capture output in case of failure
267-
file (WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx" "${CXXSTD_TEST_SOURCE}\n")
268-
269-
# Can't find tdl::tdl in try_compile, so we need to remove it from SHARG_LIBRARIES
270-
set (SHARG_TRY_COMPILE_LIBRARIES ${SHARG_LIBRARIES})
271-
list (REMOVE_ITEM SHARG_TRY_COMPILE_LIBRARIES tdl::tdl)
272-
try_compile (SHARG_PLATFORM_TEST ${CMAKE_BINARY_DIR}
273-
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
274-
CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${CMAKE_CXX_FLAGS} ${SHARG_CXX_FLAGS}"
275-
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_INCLUDE_PATH};${SHARG_INCLUDE_DIR}"
237+
try_compile (SHARG_PLATFORM_TEST
238+
${CMAKE_BINARY_DIR}
239+
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/platform_test.cpp
240+
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${SHARG_INCLUDE_DIR}"
276241
COMPILE_DEFINITIONS ${SHARG_DEFINITIONS}
277-
LINK_LIBRARIES ${SHARG_TRY_COMPILE_LIBRARIES}
242+
CXX_STANDARD 23
243+
CXX_STANDARD_REQUIRED ON
244+
CXX_EXTENSIONS OFF
278245
OUTPUT_VARIABLE SHARG_PLATFORM_TEST_OUTPUT)
246+
# cmake-format: on
279247

280248
if (SHARG_PLATFORM_TEST)
281249
sharg_config_print ("SHARG platform.hpp build: passed.")
@@ -310,14 +278,15 @@ if (CMAKE_FIND_PACKAGE_NAME)
310278
else ()
311279
set (SHARG_VERSION "${PACKAGE_VERSION}")
312280
endif ()
281+
313282
# ----------------------------------------------------------------------------
314283
# Export targets
315284
# ----------------------------------------------------------------------------
316285

317286
if (NOT TARGET sharg::sharg)
318287
add_library (sharg_sharg INTERFACE)
319288
target_compile_definitions (sharg_sharg INTERFACE ${SHARG_DEFINITIONS})
320-
target_compile_options (sharg_sharg INTERFACE ${SHARG_CXX_FLAGS})
289+
target_compile_features (sharg_sharg INTERFACE cxx_std_23)
321290
target_link_libraries (sharg_sharg INTERFACE ${SHARG_LIBRARIES})
322291
target_include_directories (sharg_sharg INTERFACE "${SHARG_INCLUDE_DIR}")
323292
add_library (sharg::sharg ALIAS sharg_sharg)
@@ -338,7 +307,6 @@ if (SHARG_FIND_DEBUG)
338307
message (" SHARG_INCLUDE_DIR ${SHARG_INCLUDE_DIR}")
339308
message (" SHARG_LIBRARIES ${SHARG_LIBRARIES}")
340309
message (" SHARG_DEFINITIONS ${SHARG_DEFINITIONS}")
341-
message (" SHARG_CXX_FLAGS ${SHARG_CXX_FLAGS}")
342310
message ("")
343311
message (" SHARG_VERSION ${SHARG_VERSION}")
344312
message (" SHARG_VERSION_MAJOR ${SHARG_VERSION_MAJOR}")

include/sharg/detail/type_name_as_string.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,16 @@ inline std::string const type_name_as_string = []()
5454
// We exclude status != 0, because this code can't be reached normally, only if there is a defect in the compiler
5555
// itself, since the type is directly given by the compiler. See https://github.com/seqan/seqan3/pull/2311.
5656
// LCOV_EXCL_START
57-
// clang-format off
5857
if (status != 0)
59-
return std::string{typeid(type).name()} +
60-
" (abi::__cxa_demangle error status (" + std::to_string(status) + "): " +
61-
(status == -1 ? "A memory allocation failure occurred." :
62-
(status == -2 ? "mangled_name is not a valid name under the C++ ABI mangling rules." :
63-
(status == -3 ? "One of the arguments is invalid." : "Unknown Error"))) + ")";
64-
// clang-format on
58+
{
59+
demangled_name =
60+
std::string{typeid(type).name()} + " (abi::__cxa_demangle error status (" + std::to_string(status) + "): "
61+
+ (status == -1 ? "A memory allocation failure occurred."
62+
: (status == -2 ? "mangled_name is not a valid name under the C++ ABI mangling rules."
63+
: (status == -3 ? "One of the arguments is invalid." : "Unknown Error")))
64+
+ ")";
65+
return demangled_name;
66+
}
6567
// LCOV_EXCL_STOP
6668

6769
demangled_name = std::string{std::addressof(*demangled_name_ptr)};

test/header/generate_header_source.cmake

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,61 +13,57 @@ option (HEADER_SUB_TEST "")
1313

1414
file (WRITE "${HEADER_TARGET_SOURCE}" "") # write empty file
1515

16+
# cmake-format: off
17+
1618
if (HEADER_SUB_TEST STREQUAL "no-self-include")
1719
# this test ensures that a header will not be included by itself later
1820
file (READ "${HEADER_FILE_ABSOLUTE}" header_content)
1921

2022
string (REPLACE "#pragma once" "" header_content "${header_content}")
2123

22-
file (APPEND "${HEADER_TARGET_SOURCE}" "${header_content}")
24+
file (APPEND "${HEADER_TARGET_SOURCE}"
25+
"// sharg-header-test-no-self-include-start\n"
26+
"${header_content}\n"
27+
"// sharg-header-test-no-self-include-end\n\n")
2328
else ()
2429
# this test ensures that a header guard is in place
2530
file (APPEND "${HEADER_TARGET_SOURCE}"
26-
"
27-
#include <${HEADER_FILE_INCLUDE}>
28-
#include <${HEADER_FILE_INCLUDE}>")
31+
"// sharg-header-test-header-guard-start\n"
32+
"#include <${HEADER_FILE_INCLUDE}>\n"
33+
"#include <${HEADER_FILE_INCLUDE}>\n"
34+
"// sharg-header-test-header-guard-end\n\n")
2935
endif ()
3036

3137
# these includes are required by some headers (note that they follow)
3238
file (APPEND "${HEADER_TARGET_SOURCE}"
33-
"
34-
#include <gtest/gtest.h>
35-
TEST(${HEADER_TEST_NAME_SAFE}) {}")
39+
"// sharg-header-test-dependencies-start\n"
40+
"#include <gtest/gtest.h>\n"
41+
"TEST(${HEADER_TEST_NAME_SAFE}) {}\n"
42+
"// sharg-header-test-dependencies-end\n\n")
3643

3744
# test that sharg headers include platform.hpp
3845
if ("${HEADER_COMPONENT}" MATCHES "sharg")
3946

4047
# exclude sharg/std/* and sharg/version.hpp from platform test
4148
if (NOT HEADER_FILE_INCLUDE MATCHES "sharg/(std/|version.hpp)")
4249
file (APPEND "${HEADER_TARGET_SOURCE}"
43-
"
44-
#ifndef SHARG_DOXYGEN_ONLY
45-
#error \"Your header '${HEADER_FILE_INCLUDE}' file is missing #include <sharg/platform.hpp>\"
46-
#endif")
50+
"// sharg-header-test-platform-start\n"
51+
"#ifndef SHARG_DOXYGEN_ONLY\n"
52+
"#error \"Your header '${HEADER_FILE_INCLUDE}' file is missing #include <sharg/platform.hpp>\"\n"
53+
"#endif\n"
54+
"// sharg-header-test-platform-end\n\n")
4755
endif ()
4856

4957
# sharg/std/* must not include platform.hpp (and therefore any other sharg header)
5058
# See https://github.com/seqan/product_backlog/issues/135
5159
if (HEADER_FILE_INCLUDE MATCHES "sharg/std/")
5260
file (APPEND "${HEADER_TARGET_SOURCE}"
53-
"
54-
#ifdef SHARG_DOXYGEN_ONLY
55-
#error \"The standard header '${HEADER_FILE_INCLUDE}' file MUST NOT include any other sharg header\"
56-
#endif")
61+
"// sharg-header-test-no-platform-start\n"
62+
"#ifdef SHARG_DOXYGEN_ONLY\n"
63+
"#error \"The standard header '${HEADER_FILE_INCLUDE}' file MUST NOT include any other sharg header\"\n"
64+
"#endif\n"
65+
"// sharg-header-test-no-platform-end\n\n")
5766
endif ()
58-
59-
# test whether sharg has the visibility bug on lower gcc versions
60-
# https://github.com/seqan/seqan3/issues/1317
61-
if (NOT HEADER_FILE_INCLUDE MATCHES "sharg/version.hpp")
62-
file (APPEND "${HEADER_TARGET_SOURCE}"
63-
"
64-
#include <sharg/platform.hpp>
65-
class A{ int i{5}; };
66-
67-
template <typename t>
68-
concept private_bug = requires(t a){a.i;};
69-
70-
static_assert(!private_bug<A>, \"See https://github.com/seqan/seqan3/issues/1317\");")
71-
endif ()
72-
7367
endif ()
68+
69+
# cmake-format: on

0 commit comments

Comments
 (0)