Skip to content

Commit 1266c15

Browse files
authored
Merge pull request #3337 from eseiler/infra/defines
[INFRA] Buildsystem
2 parents 1ed89ee + f413686 commit 1266c15

File tree

61 files changed

+474
-347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+474
-347
lines changed

.github/workflows/ci_coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ jobs:
8686
--exclude-unreachable-branches \
8787
--exclude-throw-branches \
8888
--exclude-noncode-lines \
89+
--merge-mode-functions separate \
8990
-j \
9091
--cobertura \
9192
--output ${GITHUB_WORKSPACE}/build/coverage_report.xml
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# SPDX-FileCopyrightText: 2006-2025, Knut Reinert & Freie Universität Berlin
2+
# SPDX-FileCopyrightText: 2016-2025, Knut Reinert & MPI für molekulare Genetik
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
name: No Optional Libraries
6+
7+
on:
8+
schedule:
9+
- cron: "0 10 * * SUN"
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: no-optional-libraries-actions
14+
cancel-in-progress: true
15+
16+
env:
17+
SEQAN3_NO_VERSION_CHECK: 1
18+
TZ: Europe/Berlin
19+
20+
defaults:
21+
run:
22+
shell: bash -Eeuxo pipefail {0}
23+
24+
jobs:
25+
build:
26+
name: ${{ matrix.build_type }} ${{ matrix.os }} (${{ matrix.zlib }}, ${{ matrix.bzip2 }}, ${{ matrix.cereal }})
27+
runs-on: ${{ matrix.os }}
28+
if: github.repository_owner == 'seqan' || github.event_name == 'workflow_dispatch'
29+
strategy:
30+
fail-fast: false
31+
# Either all optional dependencies are disabled (true, true, true)
32+
# Or only Bzip2 is disabled (false, true, false)
33+
matrix:
34+
os: [ubuntu-latest, macos-14]
35+
build_type: [Release, Debug]
36+
zlib: [true, false]
37+
include:
38+
- zlib: true
39+
bzip2: true
40+
cereal: true
41+
- zlib: false
42+
bzip2: true
43+
cereal: false
44+
- os: macos-14
45+
compiler: clang-19
46+
- os: ubuntu-latest
47+
compiler: gcc-14
48+
image: ghcr.io/seqan/gcc-14
49+
50+
container:
51+
# If an image is defined for a matrix entry, use it.
52+
# Otherwise, use the "empty"/'' image which means do not use a container at all.
53+
image: ${{ matrix.image || '' }}
54+
volumes:
55+
- /home/runner:/home/runner
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
60+
- name: Setup compiler
61+
if: contains(matrix.os, 'macos')
62+
uses: seqan/actions/setup-compiler@main
63+
with:
64+
compiler: ${{ matrix.compiler }}
65+
66+
- name: Configure tests
67+
run: |
68+
mkdir build && cd build
69+
cmake ../test/analyse -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
70+
-DCMAKE_DISABLE_FIND_PACKAGE_ZLIB=${{ matrix.zlib }} \
71+
-DCMAKE_DISABLE_FIND_PACKAGE_BZip2=${{ matrix.bzip2 }} \
72+
-DCMAKE_DISABLE_FIND_PACKAGE_cereal=${{ matrix.cereal }} \
73+
-DSEQAN3_BENCHMARK_MIN_TIME=0.01s
74+
make gtest_main benchmark_main
75+
76+
- name: Build tests
77+
working-directory: build
78+
run: make -k
79+
80+
- name: Run tests
81+
working-directory: build
82+
continue-on-error: true
83+
id: test
84+
run: ctest . -j --output-on-failure --no-tests=error
85+
86+
# Rerun failed tests with **one** thread. Some snippets touch the same file and fail in parallel.
87+
- name: Rerun failed tests
88+
if: steps.test.outcome == 'failure'
89+
working-directory: build
90+
run: ctest . -j1 --output-on-failure --no-tests=error --rerun-failed

cmake/cpack_install.cmake.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# Only if creating the source package (`make package_source`):
66
# Copy dependency include directories into package's staging folder
77
if (CPACK_SOURCE_INSTALLED_DIRECTORIES)
8-
file (COPY "@SEQAN3_CEREAL_INCLUDE_DIR@/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/include/seqan3/vendor")
98
configure_file ("@CPM_DOWNLOAD_LOCATION@" "${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake" COPYONLY)
109
if ("@use_ccache_ADDED@" STREQUAL "YES")
1110
configure_file ("@use_ccache_SOURCE_DIR@/ccache/CMakeLists.txt"

cmake/package-lock.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ CPMDeclarePackage (cereal
2121
NAME cereal
2222
VERSION ${SEQAN3_CEREAL_VERSION}
2323
GITHUB_REPOSITORY USCiLab/cereal
24-
DOWNLOAD_ONLY TRUE
25-
QUIET YES)
24+
SYSTEM TRUE
25+
OPTIONS "JUST_INSTALL_CEREAL ON" "CMAKE_MESSAGE_LOG_LEVEL WARNING")
2626
# benchmark
2727
set (SEQAN3_BENCHMARK_VERSION 1.9.1 CACHE STRING "" FORCE)
2828
CPMDeclarePackage (benchmark

cmake/seqan3-config.cmake

Lines changed: 51 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -134,32 +134,21 @@ else ()
134134
endif ()
135135

136136
# ----------------------------------------------------------------------------
137-
# Force-deactivate optional dependencies
137+
# Force-(de)activate optional dependencies
138138
# ----------------------------------------------------------------------------
139139

140-
# Cereal is auto-detected by default, i.e. used if found, not used if not found.
141-
# You can optionally set a hard requirement so a build fails without cereal,
142-
# or you can force-disable cereal even if present on the system.
143-
option (SEQAN3_CEREAL "Require cereal and fail if not present." OFF)
144-
option (SEQAN3_NO_CEREAL "Don't use cereal, even if present." OFF)
140+
# https://cmake.org/cmake/help/latest/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.html
141+
# https://cmake.org/cmake/help/latest/variable/CMAKE_REQUIRE_FIND_PACKAGE_PackageName.html
145142

146-
if (SEQAN3_CEREAL AND SEQAN3_NO_CEREAL)
147-
# this is always a user error, therefore we always error-out, even if SeqAn is not required
148-
message (FATAL_ERROR "You may not specify SEQAN3_CEREAL and SEQAN3_NO_CEREAL at the same time.\n\
149-
You can specify neither (use auto-detection), or specify either to force on/off.")
150-
return ()
151-
endif ()
152-
153-
if (SEQAN3_CEREAL)
154-
set (SEQAN3_DEFINITIONS ${SEQAN3_DEFINITIONS} "-DSEQAN3_WITH_CEREAL=1")
155-
elseif (SEQAN3_NO_CEREAL)
156-
set (SEQAN3_DEFINITIONS ${SEQAN3_DEFINITIONS} "-DSEQAN3_WITH_CEREAL=0")
157-
endif ()
143+
## Example for deactivating
144+
# cmake <path> -DCMAKE_DISABLE_FIND_PACKAGE_ZLIB=TRUE
145+
# -DCMAKE_DISABLE_FIND_PACKAGE_BZip2=TRUE
146+
# -DCMAKE_DISABLE_FIND_PACKAGE_cereal=TRUE
158147

159-
# These two are "opt-in", because detected by CMake
160-
# If you want to force-require these, just do find_package (zlib REQUIRED) before find_package (seqan3)
161-
option (SEQAN3_NO_ZLIB "Don't use ZLIB, even if present." OFF)
162-
option (SEQAN3_NO_BZIP2 "Don't use BZip2, even if present." OFF)
148+
## Example for requiring
149+
# cmake <path> -DCMAKE_REQUIRE_FIND_PACKAGE_ZLIB=TRUE
150+
# -DCMAKE_REQUIRE_FIND_PACKAGE_BZip2=TRUE
151+
# -DCMAKE_REQUIRE_FIND_PACKAGE_cereal=TRUE
163152

164153
# ----------------------------------------------------------------------------
165154
# Check supported compilers
@@ -180,8 +169,8 @@ endif ()
180169
set (THREADS_PREFER_PTHREAD_FLAG TRUE)
181170
find_package (Threads QUIET)
182171

183-
if (Threads_FOUND)
184-
set (SEQAN3_LIBRARIES ${SEQAN3_LIBRARIES} Threads::Threads)
172+
if (TARGET Threads::Threads)
173+
list (APPEND SEQAN3_LIBRARIES Threads::Threads)
185174
if ("${CMAKE_THREAD_LIBS_INIT}" STREQUAL "")
186175
seqan3_config_print ("Thread support: builtin.")
187176
else ()
@@ -192,114 +181,70 @@ else ()
192181
endif ()
193182

194183
# ----------------------------------------------------------------------------
195-
# Cereal dependency is optional, but may set as required
184+
# Cereal dependency
196185
# ----------------------------------------------------------------------------
197186

198-
if (NOT SEQAN3_NO_CEREAL)
199-
find_path (SEQAN3_CEREAL_INCLUDE_DIR
200-
NAMES cereal/version.hpp
201-
HINTS "${SEQAN3_INCLUDE_DIR}/seqan3/vendor")
187+
if (SEQAN3_HAS_CPM AND NOT CMAKE_DISABLE_FIND_PACKAGE_cereal)
188+
CPMGetPackage (cereal)
189+
else ()
190+
find_package (cereal CONFIG QUIET)
191+
endif ()
202192

203-
# 1) Check the vendor directory of SeqAn3. This directory exists for source packages and installed packages.
204-
if (SEQAN3_CEREAL_INCLUDE_DIR)
205-
if (SEQAN3_CEREAL)
206-
seqan3_config_print ("Required dependency: Cereal found.")
207-
else ()
208-
seqan3_config_print ("Optional dependency: Cereal found.")
209-
endif ()
210-
set (SEQAN3_DEPENDENCY_INCLUDE_DIRS ${SEQAN3_CEREAL_INCLUDE_DIR} ${SEQAN3_DEPENDENCY_INCLUDE_DIRS})
211-
# 2) Get package via CPM.
212-
elseif (SEQAN3_HAS_CPM)
213-
CPMGetPackage (cereal)
214-
215-
find_path (SEQAN3_CEREAL_INCLUDE_DIR
216-
NAMES cereal/version.hpp
217-
HINTS "${cereal_SOURCE_DIR}/include")
218-
219-
if (SEQAN3_CEREAL_INCLUDE_DIR)
220-
if (SEQAN3_CEREAL)
221-
seqan3_config_print ("Required dependency: Cereal found.")
222-
else ()
223-
seqan3_config_print ("Optional dependency: Cereal found.")
224-
endif ()
225-
set (SEQAN3_DEPENDENCY_INCLUDE_DIRS ${SEQAN3_CEREAL_INCLUDE_DIR} ${SEQAN3_DEPENDENCY_INCLUDE_DIRS})
226-
else ()
227-
if (SEQAN3_CEREAL)
228-
seqan3_config_error ("The (optional) cereal library was marked as required, but wasn't found.")
229-
else ()
230-
seqan3_config_print ("Optional dependency: Cereal not found.")
231-
endif ()
232-
endif ()
233-
else ()
234-
if (SEQAN3_CEREAL)
235-
seqan3_config_error ("The (optional) cereal library was marked as required, but wasn't found.")
236-
else ()
237-
seqan3_config_print ("Optional dependency: Cereal not found.")
238-
endif ()
239-
endif ()
193+
if (TARGET cereal::cereal)
194+
list (APPEND SEQAN3_LIBRARIES cereal::cereal)
195+
seqan3_config_print ("Optional dependency: Cereal found.")
196+
else ()
197+
set (SEQAN3_DEFINITIONS ${SEQAN3_DEFINITIONS} "-DSEQAN3_HAS_CEREAL=0")
198+
seqan3_config_print ("Optional dependency: Cereal not found.")
240199
endif ()
241200

242201
# ----------------------------------------------------------------------------
243202
# ZLIB dependency
244203
# ----------------------------------------------------------------------------
245204

246-
if (NOT SEQAN3_NO_ZLIB)
247-
find_package (ZLIB QUIET)
248-
endif ()
205+
find_package (ZLIB QUIET)
249206

250-
if (ZLIB_FOUND)
251-
set (SEQAN3_LIBRARIES ${SEQAN3_LIBRARIES} ${ZLIB_LIBRARIES})
252-
set (SEQAN3_DEPENDENCY_INCLUDE_DIRS ${SEQAN3_DEPENDENCY_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS})
253-
set (SEQAN3_DEFINITIONS ${SEQAN3_DEFINITIONS} "-DSEQAN3_HAS_ZLIB=1")
207+
if (TARGET ZLIB::ZLIB)
208+
list (APPEND SEQAN3_LIBRARIES ZLIB::ZLIB)
254209
seqan3_config_print ("Optional dependency: ZLIB-${ZLIB_VERSION_STRING} found.")
255210
else ()
211+
set (SEQAN3_DEFINITIONS ${SEQAN3_DEFINITIONS} "-DSEQAN3_HAS_ZLIB=0")
256212
seqan3_config_print ("Optional dependency: ZLIB not found.")
257213
endif ()
258214

259215
# ----------------------------------------------------------------------------
260216
# BZip2 dependency
261217
# ----------------------------------------------------------------------------
262218

263-
if (NOT SEQAN3_NO_BZIP2)
264-
find_package (BZip2 QUIET)
265-
endif ()
219+
find_package (BZip2 QUIET)
266220

267-
if (NOT ZLIB_FOUND AND BZIP2_FOUND)
268-
# NOTE (marehr): iostream_bzip2 uses the type `uInt`, which is defined by
269-
# `zlib`. Therefore, `bzip2` will cause a ton of errors without `zlib`.
270-
message (AUTHOR_WARNING "Disabling BZip2 [which was successfully found], "
271-
"because ZLIB was not found. BZip2 depends on ZLIB.")
272-
unset (BZIP2_FOUND)
273-
endif ()
274-
275-
if (BZIP2_FOUND)
276-
set (SEQAN3_LIBRARIES ${SEQAN3_LIBRARIES} ${BZIP2_LIBRARIES})
277-
set (SEQAN3_DEPENDENCY_INCLUDE_DIRS ${SEQAN3_DEPENDENCY_INCLUDE_DIRS} ${BZIP2_INCLUDE_DIRS})
278-
set (SEQAN3_DEFINITIONS ${SEQAN3_DEFINITIONS} "-DSEQAN3_HAS_BZIP2=1")
221+
if (TARGET ZLIB::ZLIB AND TARGET BZip2::BZip2)
222+
list (APPEND SEQAN3_LIBRARIES BZip2::BZip2)
279223
seqan3_config_print ("Optional dependency: BZip2-${BZIP2_VERSION_STRING} found.")
280224
else ()
225+
set (SEQAN3_DEFINITIONS ${SEQAN3_DEFINITIONS} "-DSEQAN3_HAS_BZIP2=0")
281226
seqan3_config_print ("Optional dependency: BZip2 not found.")
282227
endif ()
283228

229+
if (NOT TARGET ZLIB::ZLIB AND TARGET BZip2::BZip2)
230+
message (AUTHOR_WARNING "BZip2 was found but ZLIB was not found. BZip2 requires ZLIB.")
231+
endif ()
232+
284233
# ----------------------------------------------------------------------------
285234
# System dependencies
286235
# ----------------------------------------------------------------------------
287236

288237
# librt
289-
if ((${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
290-
OR (${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD")
291-
OR (${CMAKE_SYSTEM_NAME} STREQUAL "GNU"))
292-
set (SEQAN3_LIBRARIES ${SEQAN3_LIBRARIES} rt)
238+
find_library (SEQAN3_RT_LIB rt)
239+
if (SEQAN3_RT_LIB)
240+
list (APPEND SEQAN3_LIBRARIES ${SEQAN3_RT_LIB})
293241
endif ()
294242

295243
# libexecinfo -- implicit
296-
check_include_file_cxx (execinfo.h _SEQAN3_HAVE_EXECINFO)
297-
mark_as_advanced (_SEQAN3_HAVE_EXECINFO)
298-
if (_SEQAN3_HAVE_EXECINFO)
244+
find_package (Backtrace QUIET)
245+
if (TARGET Backtrace::Backtrace)
246+
list (APPEND SEQAN3_LIBRARIES Backtrace::Backtrace)
299247
seqan3_config_print ("Optional dependency: libexecinfo found.")
300-
if ((${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") OR (${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD"))
301-
set (SEQAN3_LIBRARIES ${SEQAN3_LIBRARIES} execinfo elf)
302-
endif ()
303248
else ()
304249
seqan3_config_print ("Optional dependency: libexecinfo not found.")
305250
endif ()
@@ -308,19 +253,17 @@ endif ()
308253
# Perform compilability test of platform.hpp (tests some requirements)
309254
# ----------------------------------------------------------------------------
310255

311-
set (CXXSTD_TEST_SOURCE "#include <seqan3/core/platform.hpp>
312-
int main() {}")
313-
314-
# using try_compile instead of check_cxx_source_compiles to capture output in case of failure
315-
file (WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx" "${CXXSTD_TEST_SOURCE}\n")
316-
317256
# cmake-format: off
257+
# Note: With CMake >= 3.25, the file WRITE can be removed, the second and third line in try_compile can be replaced by
258+
# SOURCE_FROM_CONTENT "platform_test.cpp" "#include <seqan3/core/platform.hpp>\nint main() {}"
259+
file (WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/platform_test.cpp"
260+
"#include <seqan3/core/platform.hpp>\nint main() {}")
261+
318262
try_compile (SEQAN3_PLATFORM_TEST
319263
${CMAKE_BINARY_DIR}
320-
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
321-
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_INCLUDE_PATH};${SEQAN3_INCLUDE_DIR};${SEQAN3_DEPENDENCY_INCLUDE_DIRS}"
264+
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/platform_test.cpp
265+
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${SEQAN3_INCLUDE_DIR}"
322266
COMPILE_DEFINITIONS ${SEQAN3_DEFINITIONS}
323-
LINK_LIBRARIES ${SEQAN3_LIBRARIES}
324267
CXX_STANDARD 23
325268
CXX_STANDARD_REQUIRED ON
326269
CXX_EXTENSIONS OFF
@@ -358,7 +301,7 @@ foreach (package_var
358301
endforeach ()
359302

360303
# propagate SEQAN3_INCLUDE_DIR into SEQAN3_INCLUDE_DIRS
361-
set (SEQAN3_INCLUDE_DIRS ${SEQAN3_INCLUDE_DIR} ${SEQAN3_DEPENDENCY_INCLUDE_DIRS})
304+
set (SEQAN3_INCLUDE_DIRS ${SEQAN3_INCLUDE_DIR})
362305

363306
# ----------------------------------------------------------------------------
364307
# Export targets
@@ -371,9 +314,6 @@ if (SEQAN3_FOUND AND NOT TARGET seqan3::seqan3)
371314
target_link_libraries (seqan3_seqan3 INTERFACE "${SEQAN3_LIBRARIES}")
372315
# include seqan3/include/ as -I, because seqan3 should never produce warnings.
373316
target_include_directories (seqan3_seqan3 INTERFACE "${SEQAN3_INCLUDE_DIR}")
374-
# include everything except seqan3/include/ as -isystem, i.e.
375-
# a system header which suppresses warnings of external libraries.
376-
target_include_directories (seqan3_seqan3 SYSTEM INTERFACE "${SEQAN3_DEPENDENCY_INCLUDE_DIRS}")
377317
add_library (seqan3::seqan3 ALIAS seqan3_seqan3)
378318
endif ()
379319

cmake/seqan3-install.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,3 @@ install (FILES "${SEQAN3_CLONE_DIR}/cmake/seqan3-config.cmake" "${SEQAN3_CLONE_D
2020

2121
# install seqan3 header files in /include/seqan3
2222
install (DIRECTORY "${SEQAN3_INCLUDE_DIR}/seqan3" TYPE INCLUDE)
23-
24-
install (DIRECTORY "${SEQAN3_CEREAL_INCLUDE_DIR}/cereal" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/seqan3/vendor")

doc/cookbook/compression_threads.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
33
// SPDX-License-Identifier: CC0-1.0
44

5-
#if defined(SEQAN3_HAS_ZLIB)
5+
#if SEQAN3_HAS_ZLIB
66
//![example]
77
# include <seqan3/io/all.hpp>
88

@@ -24,4 +24,4 @@ int main()
2424
return 0;
2525
}
2626
//![example]
27-
#endif // defined(SEQAN3_HAS_ZLIB)
27+
#endif // SEQAN3_HAS_ZLIB

doc/howto/write_an_alphabet/dna2_semialphabet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
//! [semialphabet]
66
#include <cassert>
7+
#include <iostream>
78

89
#include <seqan3/alphabet/concept.hpp> // alphabet concept checks
910

0 commit comments

Comments
 (0)