From bd92252e608ce1cd37d5404f4fcbdd0ccbf1653c Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 22 Jan 2024 16:19:57 +0100 Subject: [PATCH] [INFRA] Rework CMake --- .clang-format | 187 +++++++++++++ .cmake-format.yaml | 336 +++++++++++++++++++++++ CMakeLists.txt | 26 +- cmake/CPM.cmake | 23 ++ cmake/CPMGetSystemPackage.cmake | 30 ++ cmake/ccache.cmake | 38 +++ cmake/package-lock.cmake | 56 ++++ doc/CMakeLists.txt | 3 +- src/main.cpp | 7 +- test/CMakeLists.txt | 93 ++++--- test/api/convert_fastq_test.cpp | 6 +- test/cli/cli_test.hpp | 22 +- test/cli/fastq_to_fasta_options_test.cpp | 25 +- test/cmake/app_datasources.cmake | 25 +- test/cmake/seqan_require_ccache.cmake | 55 ---- test/coverage/CMakeLists.txt | 32 +-- test/data/datasources.cmake | 6 +- test/header/CMakeLists.txt | 43 ++- 18 files changed, 813 insertions(+), 200 deletions(-) create mode 100644 .clang-format create mode 100644 .cmake-format.yaml create mode 100644 cmake/CPM.cmake create mode 100644 cmake/CPMGetSystemPackage.cmake create mode 100644 cmake/ccache.cmake create mode 100644 cmake/package-lock.cmake delete mode 100644 test/cmake/seqan_require_ccache.cmake diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..24d9fc8 --- /dev/null +++ b/.clang-format @@ -0,0 +1,187 @@ +# SPDX-FileCopyrightText: 2006-2023, Knut Reinert & Freie Universität Berlin +# SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik +# SPDX-License-Identifier: CC0-1.0 + +# Format all files in include folder, including std module, excluding contrib module +# find . -iname "*.[ch]pp" -not -path "./build/*" | xargs clang-format-15 --style=file -i +# Staged files: git diff --name-only HEAD --diff-filter=ACMRT | grep -E "(\.cpp|\.hpp)$" | xargs clang-format-15 --style=file -i +--- +Language: Cpp +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveMacros: None +AlignConsecutiveAssignments: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None +AlignEscapedNewlines: Right +AlignOperands: AlignAfterOperator +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortEnumsOnASingleLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +AttributeMacros: +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: Always + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: false + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: true + BeforeWhile: true + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeConceptDeclarations: true +BreakBeforeBraces: Custom +BreakBeforeInheritanceComma: false +BreakInheritanceList: AfterColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: AfterColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +QualifierAlignment: Custom +QualifierOrder: ['static', 'inline', 'constexpr', 'volatile', 'type', 'const'] +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: Always +ExperimentalAutoDetectBinPacking: false +PackConstructorInitializers: CurrentLine +BasedOnStyle: '' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +AllowAllConstructorInitializersOnNextLine: true +FixNamespaceComments: true +ForEachMacros: +IfMacros: +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '()' + Priority: 2 + - Regex: ' space characters (utf-8 0x20). + - In cases where the layout would require a fractional tab + - character, the behavior of the fractional indentation is + - governed by + use_tabchars: false + _help_fractional_tab_policy: + - If is True, then the value of this variable + - indicates how fractional indentions are handled during + - whitespace replacement. If set to 'use-space', fractional + - indentation is left as spaces (utf-8 0x20). If set to + - '`round-up` fractional indentation is replaced with a single' + - tab character (utf-8 0x09) effectively shifting the column + - to the next tabstop + fractional_tab_policy: use-space + _help_max_subgroups_hwrap: + - If an argument group contains more than this many sub-groups + - (parg or kwarg groups) then force it to a vertical layout. + max_subgroups_hwrap: 2 + _help_max_pargs_hwrap: + - If a positional argument group contains more than this many + - arguments, then force it to a vertical layout. + max_pargs_hwrap: 6 + _help_max_rows_cmdline: + - If a cmdline positional group consumes more than this many + - lines without nesting, then invalidate the layout (and nest) + max_rows_cmdline: 2 + _help_separate_ctrl_name_with_space: + - If true, separate flow control names from their parentheses + - with a space + separate_ctrl_name_with_space: true + _help_separate_fn_name_with_space: + - If true, separate function names from parentheses with a + - space + separate_fn_name_with_space: true + _help_dangle_parens: + - If a statement is wrapped to more than one line, than dangle + - the closing parenthesis on its own line. + dangle_parens: true + _help_dangle_align: + - If the trailing parenthesis must be 'dangled' on its on + - 'line, then align it to this reference: `prefix`: the start' + - 'of the statement, `prefix-indent`: the start of the' + - 'statement, plus one indentation level, `child`: align to' + - the column of the arguments + dangle_align: prefix + _help_min_prefix_chars: + - If the statement spelling length (including space and + - parenthesis) is smaller than this amount, then force reject + - nested layouts. + min_prefix_chars: 120 + _help_max_prefix_chars: + - If the statement spelling length (including space and + - parenthesis) is larger than the tab width by more than this + - amount, then force reject un-nested layouts. + max_prefix_chars: 120 + _help_max_lines_hwrap: + - If a candidate layout is wrapped horizontally but it exceeds + - this many lines, then reject the layout. + max_lines_hwrap: 2 + _help_line_ending: + - What style line endings to use in the output. + line_ending: unix + _help_command_case: + - Format command names consistently as 'lower' or 'upper' case + command_case: canonical + _help_keyword_case: + - Format keywords consistently as 'lower' or 'upper' case + keyword_case: upper + _help_always_wrap: + - A list of command names which should always be wrapped + always_wrap: [] + _help_enable_sort: + - If true, the argument lists which are known to be sortable + - will be sorted lexicographicall + enable_sort: true + _help_autosort: + - If true, the parsers may infer whether or not an argument + - list is sortable (without annotation). + autosort: true + _help_require_valid_layout: + - By default, if cmake-format cannot successfully fit + - everything into the desired linewidth it will apply the + - last, most agressive attempt that it made. If this flag is + - True, however, cmake-format will print error, exit with non- + - zero status code, and write-out nothing + require_valid_layout: false + _help_layout_passes: + - A dictionary mapping layout nodes to a list of wrap + - decisions. See the documentation for more information. + layout_passes: {} +_help_markup: Options affecting comment reflow and formatting. +markup: + _help_bullet_char: + - What character to use for bulleted lists + bullet_char: '*' + _help_enum_char: + - What character to use as punctuation after numerals in an + - enumerated list + enum_char: . + _help_first_comment_is_literal: + - If comment markup is enabled, don't reflow the first comment + - block in each listfile. Use this to preserve formatting of + - your copyright/license statements. + first_comment_is_literal: true + _help_literal_comment_pattern: + - If comment markup is enabled, don't reflow any comment block + - which matches this (regex) pattern. Default is `None` + - (disabled). + literal_comment_pattern: + _help_fence_pattern: + - Regular expression to match preformat fences in comments + - default= ``r'^\s*([`~]{3}[`~]*)(.*)$'`` + fence_pattern: ^\s*([`~]{3}[`~]*)(.*)$ + _help_ruler_pattern: + - Regular expression to match rulers in comments default= + - '``r''^\s*[^\w\s]{3}.*[^\w\s]{3}$''``' + ruler_pattern: ^\s*[^\w\s]{3}.*[^\w\s]{3}$ + _help_explicit_trailing_pattern: + - If a comment line matches starts with this pattern then it + - is explicitly a trailing comment for the preceeding + - argument. Default is '#<' + explicit_trailing_pattern: '#<' + _help_hashruler_min_length: + - If a comment line starts with at least this many consecutive + - hash characters, then don't lstrip() them off. This allows + - for lazy hash rulers where the first hash char is not + - separated by space + hashruler_min_length: 10 + _help_canonicalize_hashrulers: + - If true, then insert a space between the first hash char and + - remaining hash chars in a hash ruler, and normalize its + - length to fill the column + canonicalize_hashrulers: true + _help_enable_markup: + - enable comment markup parsing and reflow + enable_markup: false +_help_lint: Options affecting the linter +lint: + _help_disabled_codes: + - a list of lint codes to disable + disabled_codes: [] + _help_function_pattern: + - regular expression pattern describing valid function names + function_pattern: '[0-9a-z_]+' + _help_macro_pattern: + - regular expression pattern describing valid macro names + macro_pattern: '[0-9A-Z_]+' + _help_global_var_pattern: + - regular expression pattern describing valid names for + - variables with global (cache) scope + global_var_pattern: '[A-Z][0-9A-Z_]+' + _help_internal_var_pattern: + - regular expression pattern describing valid names for + - variables with global scope (but internal semantic) + internal_var_pattern: _[A-Z][0-9A-Z_]+ + _help_local_var_pattern: + - regular expression pattern describing valid names for + - variables with local scope + local_var_pattern: '[a-z][a-z0-9_]+' + _help_private_var_pattern: + - regular expression pattern describing valid names for + - privatedirectory variables + private_var_pattern: _[0-9a-z_]+ + _help_public_var_pattern: + - regular expression pattern describing valid names for public + - directory variables + public_var_pattern: '[A-Z][0-9A-Z_]+' + _help_argument_var_pattern: + - regular expression pattern describing valid names for + - function/macro arguments and loop variables. + argument_var_pattern: '[a-z][a-z0-9_]+' + _help_keyword_pattern: + - regular expression pattern describing valid names for + - keywords used in functions or macros + keyword_pattern: '[A-Z][0-9A-Z_]+' + _help_max_conditionals_custom_parser: + - In the heuristic for C0201, how many conditionals to match + - within a loop in before considering the loop a parser. + max_conditionals_custom_parser: 2 + _help_min_statement_spacing: + - Require at least this many newlines between statements + min_statement_spacing: 1 + _help_max_statement_spacing: + - Require no more than this many newlines between statements + max_statement_spacing: 2 + max_returns: 6 + max_branches: 12 + max_arguments: 5 + max_localvars: 15 + max_statements: 50 +_help_encode: Options affecting file encoding +encode: + _help_emit_byteorder_mark: + - If true, emit the unicode byte-order mark (BOM) at the start + - of the file + emit_byteorder_mark: false + _help_input_encoding: + - Specify the encoding of the input file. Defaults to utf-8 + input_encoding: utf-8 + _help_output_encoding: + - Specify the encoding of the output file. Defaults to utf-8. + - Note that cmake only claims to support utf-8 so be careful + - when using anything else + output_encoding: utf-8 +_help_misc: Miscellaneous configurations options. +misc: + _help_per_command: + - A dictionary containing any per-command configuration + - overrides. Currently only `command_case` is supported. + per_command: {} diff --git a/CMakeLists.txt b/CMakeLists.txt index 09135b8..24b589e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,10 @@ project (app-template VERSION 1.0.0) # Make Release default build type if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE Release CACHE STRING - "Choose the type of build, options are: Debug Release Coverage RelWithDebInfo MinSizeRel." - FORCE) + set (CMAKE_BUILD_TYPE + Release + CACHE STRING "Choose the type of build, options are: Debug Release Coverage RelWithDebInfo MinSizeRel." FORCE + ) endif () # Specify the directories where to store the built archives, libraries and executables @@ -24,19 +25,24 @@ string (ASCII 27 Esc) set (FontBold "${Esc}[1m") set (FontReset "${Esc}[m") -# Dependency: SeqAn3. -find_package (SeqAn3 QUIET REQUIRED HINTS lib/seqan3/build_system) -# Dependency: Sharg. -find_package (Sharg QUIET REQUIRED HINTS lib/sharg-parser/build_system) +list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") +set (CPM_INDENT " CMake Package Manager CPM: ") +include (CPM) +include (CPMGetSystemPackage) +CPMUsePackageLock (${CMAKE_CURRENT_LIST_DIR}/cmake/package-lock.cmake) + +# CPMGetSystemPackage (hibf) +CPMGetSystemPackage (sharg) +CPMGetSystemPackage (seqan3) # Allow to include CMake scripts from seqan3. -list (APPEND CMAKE_MODULE_PATH "${SEQAN3_CLONE_DIR}/test/cmake/") +list (APPEND CMAKE_MODULE_PATH "${seqan3_SOURCE_DIR}/test/cmake/") # Allow to include CMake scripts from the app-template. list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/test/cmake/") # Use ccache. -include (seqan_require_ccache) -seqan_require_ccache () +include (ccache) +require_ccache () # Add the application. add_subdirectory (src) diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake new file mode 100644 index 0000000..a26442d --- /dev/null +++ b/cmake/CPM.cmake @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: MIT +# +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors + +set (CPM_DOWNLOAD_VERSION 0.38.6) +set (CPM_HASH_SUM "11c3fa5f1ba14f15d31c2fb63dbc8628ee133d81c8d764caad9a8db9e0bacb07") + +if (CPM_SOURCE_CACHE) + set (CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +elseif (DEFINED ENV{CPM_SOURCE_CACHE}) + set (CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +else () + set (CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +endif () + +# Expand relative path. This is important if the provided path contains a tilde (~) +get_filename_component (CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE) + +file (DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + ${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM} +) + +include (${CPM_DOWNLOAD_LOCATION}) diff --git a/cmake/CPMGetSystemPackage.cmake b/cmake/CPMGetSystemPackage.cmake new file mode 100644 index 0000000..dc1860a --- /dev/null +++ b/cmake/CPMGetSystemPackage.cmake @@ -0,0 +1,30 @@ +# SPDX-FileCopyrightText: 2006-2023, Knut Reinert & Freie Universität Berlin +# SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik +# SPDX-License-Identifier: BSD-3-Clause + +# SYSTEM property is only implemented with CMake 3.25 +macro (CPMGetSystemPackage package) + CPMGetPackage (${package}) + + if (CMAKE_VERSION VERSION_LESS 3.25) + set (target_name "${package}") + if ("${package}" STREQUAL "seqan3") + set (target_name "seqan3_seqan3") + elseif ("${package}" STREQUAL "sharg") + set (target_name "sharg_sharg") + endif () + + if (${package}_ADDED) + set (interface_include "$") + set (include "$") + set_target_properties (${target_name} + PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES + "$<$:${interface_include}>;$<$:${include}>" + ) + unset (interface_include) + unset (include) + endif () + + unset (target_name) + endif () +endmacro () diff --git a/cmake/ccache.cmake b/cmake/ccache.cmake new file mode 100644 index 0000000..9a509fb --- /dev/null +++ b/cmake/ccache.cmake @@ -0,0 +1,38 @@ +# -------------------------------------------------------------------------------------------------- +# Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin +# Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik +# This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License +# shipped with this file and also available at: https://github.com/seqan/raptor/blob/main/LICENSE.md +# -------------------------------------------------------------------------------------------------- + +cmake_minimum_required (VERSION 3.21) + +include (FindPackageMessage) + +# Uses `ccache` to cache build results. +# +# See also +# * https://ccache.dev/ +# * https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.html +macro (require_ccache) + option (USE_CCACHE "Use ccache if available." ON) + set (FPROFILE_ABS_PATH "-fprofile-abs-path") + if (USE_CCACHE) + find_program (CCACHE_PROGRAM ccache) + + if (NOT CCACHE_PROGRAM) + find_package_message (CCACHE_PROGRAM " Ccache program: not available" "[${CCACHE_PROGRAM}]") + else () + find_package_message (CCACHE_PROGRAM " Ccache program: available" "[${CCACHE_PROGRAM}]") + set (FPROFILE_ABS_PATH "--ccache-skip -fprofile-abs-path") + + list (PREPEND CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") + list (PREPEND CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") + + list (PREPEND CMAKE_CXX_LINKER_LAUNCHER "${CCACHE_PROGRAM}") + list (PREPEND CMAKE_C_LINKER_LAUNCHER "${CCACHE_PROGRAM}") + endif () + + unset (CCACHE_PROGRAM) + endif () +endmacro () diff --git a/cmake/package-lock.cmake b/cmake/package-lock.cmake new file mode 100644 index 0000000..7058b42 --- /dev/null +++ b/cmake/package-lock.cmake @@ -0,0 +1,56 @@ +# SPDX-FileCopyrightText: 2006-2023, Knut Reinert & Freie Universität Berlin +# SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik +# SPDX-License-Identifier: CC0-1.0 + +# CPM Package Lock +# This file should be committed to version control + +# hibf +set (HIBF_VERSION 2075a68d10f571399b5ff885f0b4cb2c94845601) +CPMDeclarePackage (hibf + NAME hibf + GIT_TAG ${HIBF_VERSION} + VERSION 1.0.0 # Pretty-print only + GITHUB_REPOSITORY seqan/hibf + SYSTEM TRUE + OPTIONS "INSTALL_HIBF OFF" "CMAKE_MESSAGE_LOG_LEVEL WARNING" +) +# sharg +set (SHARG_VERSION 3e96d37387125bd876ace3fdd11a20039ed0d21c) +CPMDeclarePackage (sharg + NAME sharg + GIT_TAG ${SHARG_VERSION} + VERSION 1.1.2 # Pretty-print only + GITHUB_REPOSITORY seqan/sharg-parser + SYSTEM TRUE + OPTIONS "INSTALL_SHARG OFF" "INSTALL_TDL OFF" "CMAKE_MESSAGE_LOG_LEVEL WARNING" +) +# seqan3 +set (SEQAN3_VERSION ee718d0d3bbf07a894b5208d37ddf71ba5a5bf44) +CPMDeclarePackage (seqan3 + NAME seqan3 + GIT_TAG ${SEQAN3_VERSION} + VERSION 3.1.2 # Pretty-print only + GITHUB_REPOSITORY seqan/seqan3 + SYSTEM TRUE + OPTIONS "INSTALL_SEQAN3 OFF" "CMAKE_MESSAGE_LOG_LEVEL WARNING" +) +# benchmark +set (BENCHMARK_VERSION 1.8.2) +CPMDeclarePackage (benchmark + NAME benchmark + VERSION ${BENCHMARK_VERSION} + GITHUB_REPOSITORY google/benchmark + SYSTEM TRUE + OPTIONS "BENCHMARK_ENABLE_TESTING OFF" "BENCHMARK_ENABLE_WERROR OFF" + "CMAKE_MESSAGE_LOG_LEVEL WARNING" +) +# googletest +set (GOOGLETEST_VERSION 1.14.0) +CPMDeclarePackage (googletest + NAME GTest + VERSION ${GOOGLETEST_VERSION} + GITHUB_REPOSITORY google/googletest + SYSTEM TRUE + OPTIONS "BUILD_GMOCK OFF" "INSTALL_GTEST OFF" "CMAKE_MESSAGE_LOG_LEVEL WARNING" +) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 7493309..73229bc 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -19,7 +19,8 @@ if (${DOXYGEN_FOUND}) COMMAND ${DOXYGEN_EXECUTABLE} WORKING_DIRECTORY ${APP_TEMPLATE_DOXYGEN_OUTPUT_DIR} COMMENT "Generating (developer) API documentation with Doxygen." - VERBATIM) + VERBATIM + ) message (STATUS "${FontBold}You can run `make doc` to build api documentation.${FontReset}") else () message (STATUS "Doxygen not found.") diff --git a/src/main.cpp b/src/main.cpp index 3e10716..7ad56e3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,10 +29,9 @@ int main(int argc, char ** argv) .default_message = "Print to terminal (stdout)", .validator = sharg::output_file_validator{}}); // Example for a flag. - parser.add_flag(verbose, - sharg::config{.short_id = 'v', - .long_id = "verbose", - .description = "Give more detailed information."}); + parser.add_flag( + verbose, + sharg::config{.short_id = 'v', .long_id = "verbose", .description = "Give more detailed information."}); try { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c4915ca..1b763cf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,34 +1,14 @@ cmake_minimum_required (VERSION 3.16) +CPMGetSystemPackage (benchmark) +CPMGetSystemPackage (googletest) + # Set directories for test output files, input data and binaries. file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output) add_definitions (-DOUTPUTDIR=\"${CMAKE_CURRENT_BINARY_DIR}/output/\") add_definitions (-DDATADIR=\"${CMAKE_CURRENT_BINARY_DIR}/data/\") add_definitions (-DBINDIR=\"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/\") -# Define cmake configuration flags to configure and build external projects with the same flags as specified for -# this project. -# We also pass the C_COMPILER such that googletest is built with the corresponding GCC. -# Otherwise, it might happen that the app is built with, e.g., g++-11, but gtest with gcc-7, which might cause trouble. -set (SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS "") -list (APPEND SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}") -list (APPEND SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") -list (APPEND SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") -list (APPEND SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}") -list (APPEND SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE}") -set (SEQAN3_TEST_CLONE_DIR "${PROJECT_BINARY_DIR}/vendor/googletest") - -include (seqan3_require_test) -seqan3_require_test () - -# Build tests just before their execution, because they have not been built with "all" target. -# The trick is here to provide a cmake file as a directory property that executes the build command. -file (WRITE "${CMAKE_CURRENT_BINARY_DIR}/build_test_targets.cmake" - "execute_process (COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target api_test)\n" - "execute_process (COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target cli_test)\n" - "execute_process (COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target header_test)\n") -set_directory_properties (PROPERTIES TEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/build_test_targets.cmake") - # Test executables and libraries should not mix with the application files. unset (CMAKE_ARCHIVE_OUTPUT_DIRECTORY) unset (CMAKE_LIBRARY_OUTPUT_DIRECTORY) @@ -36,6 +16,30 @@ unset (CMAKE_RUNTIME_OUTPUT_DIRECTORY) include (seqan3_test_component) +add_library (${PROJECT_NAME}_test INTERFACE) +target_compile_options (${PROJECT_NAME}_test INTERFACE "-pedantic" "-Wall" "-Wextra" "-Werror") + +# GCC12 and above: Disable warning about std::hardware_destructive_interference_size not being ABI-stable. +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12) + target_compile_options (${PROJECT_NAME}_test INTERFACE "-Wno-interference-size") + endif () +endif () + +# GCC12 has some bogus warnings. They will not be fixed in googletest. +# https://github.com/google/googletest/issues/4232 +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13) + target_compile_options (${PROJECT_NAME}_test INTERFACE "-Wno-restrict") + endif () +endif () + +target_link_libraries (${PROJECT_NAME}_test INTERFACE "${PROJECT_NAME}_lib" "GTest::gtest_main" + "benchmark::benchmark_main" +) +target_include_directories (${PROJECT_NAME}_test INTERFACE "${seqan3_SOURCE_DIR}/test/include") +add_library (${PROJECT_NAME}::test ALIAS ${PROJECT_NAME}_test) + # A macro that adds an api or cli test. macro (add_app_test test_filename) # Extract the test target name. @@ -45,11 +49,7 @@ macro (add_app_test test_filename) # Create the test target. add_executable (${target} ${test_filename}) - target_link_libraries (${target} "${PROJECT_NAME}_lib" seqan3::seqan3 gtest gtest_main) - - # Make seqan3::test available for both cli and api tests. - target_include_directories (${target} PUBLIC "${SEQAN3_CLONE_DIR}/test/include") - target_include_directories (${target} PUBLIC "${SEQAN3_TEST_CLONE_DIR}/googletest/include/") + target_link_libraries (${target} ${PROJECT_NAME}::test) # Generate and set the test name. add_test (NAME "${test_name}" COMMAND ${target}) @@ -59,17 +59,30 @@ macro (add_app_test test_filename) unset (test_name) endmacro () -string (TOUPPER ${PROJECT_NAME} uppercase_project_name) -set (${uppercase_project_name}_HEADER_TEST_ONLY OFF CACHE BOOL "Only build header test.") - -if (${uppercase_project_name}_HEADER_TEST_ONLY) - add_subdirectory (header) -else () - # Fetch data and add the tests. - include (data/datasources.cmake) - add_subdirectory (api) - add_subdirectory (cli) - add_subdirectory (coverage) -endif () +# Build tests just before their execution, because they have not been built with "all" target. +# The trick is here to provide a cmake file as a directory property that executes the build command. +file (WRITE "${CMAKE_CURRENT_BINARY_DIR}/build_test_targets.cmake" + "execute_process (COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target api_test)\n" + "execute_process (COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target cli_test)\n" + "execute_process (COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${PROJECT_NAME}_header_test)\n" +) +set_directory_properties (PROPERTIES TEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/build_test_targets.cmake") +list (APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure") + +# Fetch data and add the tests. +include (data/datasources.cmake) +add_subdirectory (api) +add_subdirectory (cli) +add_subdirectory (header) +add_subdirectory (coverage) + +add_custom_target (unit_test + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target api_test cli_test + COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -R \"api/ \|cli/\" +) +add_custom_target (header_test + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${PROJECT_NAME}_header_test + COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -R \"header\" +) message (STATUS "${FontBold}You can run `make test` to build and run tests.${FontReset}") diff --git a/test/api/convert_fastq_test.cpp b/test/api/convert_fastq_test.cpp index 707f626..fbce26e 100644 --- a/test/api/convert_fastq_test.cpp +++ b/test/api/convert_fastq_test.cpp @@ -11,7 +11,7 @@ TEST(group1, out_empty) { std::string expected{">seq1\nACGTTTGATTCGCG\n>seq2\nTCGGGGGATTCGCG\n"}; testing::internal::CaptureStdout(); - convert_fastq(DATADIR"in.fastq", ""); + convert_fastq(DATADIR "in.fastq", ""); std::string std_cout = testing::internal::GetCapturedStdout(); EXPECT_RANGE_EQ(expected, std_cout); } @@ -19,7 +19,7 @@ TEST(group1, out_empty) TEST(group1, out_not_empty) { std::filesystem::path tmp_dir = std::filesystem::temp_directory_path(); // get the temp directory - convert_fastq(DATADIR"in.fastq", tmp_dir/"out.fasta"); // create out.fasta + convert_fastq(DATADIR "in.fastq", tmp_dir / "out.fasta"); // create out.fasta // Check if out.fasta is correct using seqan3::operator""_dna5; @@ -27,7 +27,7 @@ TEST(group1, out_not_empty) std::vector expected_ids{"seq1", "seq2"}; std::vector seqs{}; std::vector ids{}; - seqan3::sequence_file_input fin{tmp_dir/"out.fasta"}; + seqan3::sequence_file_input fin{tmp_dir / "out.fasta"}; for (auto & [seq, id, qual] : fin) { diff --git a/test/cli/cli_test.hpp b/test/cli/cli_test.hpp index da09190..97534ed 100644 --- a/test/cli/cli_test.hpp +++ b/test/cli/cli_test.hpp @@ -1,9 +1,9 @@ #include -#include // system calls -#include // test directory creation -#include // ostringstream -#include // strings +#include // system calls +#include // test directory creation +#include // ostringstream +#include // strings #pragma once @@ -11,12 +11,10 @@ struct cli_test : public ::testing::Test { private: - // Holds the original work directory where Gtest has been started. std::filesystem::path original_workdir{}; protected: - // Result struct for captured streams and exit code. struct cli_test_result { @@ -34,8 +32,8 @@ struct cli_test : public ::testing::Test // Assemble the command string and disable version check. std::ostringstream command{}; command << "SEQAN3_NO_VERSION_CHECK=1 " << BINDIR; - int a[] = {0, ((void)(command << command_items << ' '), 0) ... }; - (void) a; + int a[] = {0, ((void)(command << command_items << ' '), 0)...}; + (void)a; // Always capture the output streams. testing::internal::CaptureStdout(); @@ -59,9 +57,9 @@ struct cli_test : public ::testing::Test { // Assemble the directory name. ::testing::TestInfo const * const info = ::testing::UnitTest::GetInstance()->current_test_info(); - std::filesystem::path const test_dir{std::string{OUTPUTDIR} + - std::string{info->test_case_name()} + - std::string{"."} + + std::filesystem::path const test_dir{std::string{OUTPUTDIR} + // + std::string{info->test_case_name()} + // + std::string{"."} + // std::string{info->name()}}; try { @@ -81,7 +79,7 @@ struct cli_test : public ::testing::Test { try { - std::filesystem::current_path(original_workdir); // restore the original work dir + std::filesystem::current_path(original_workdir); // restore the original work dir } catch (std::exception const & exc) { diff --git a/test/cli/fastq_to_fasta_options_test.cpp b/test/cli/fastq_to_fasta_options_test.cpp index 1dba066..54d4c4b 100644 --- a/test/cli/fastq_to_fasta_options_test.cpp +++ b/test/cli/fastq_to_fasta_options_test.cpp @@ -1,6 +1,6 @@ -#include // range comparisons -#include // strings -#include // vectors +#include // range comparisons +#include // strings +#include // vectors #include #include @@ -13,17 +13,15 @@ #include "cli_test.hpp" // To prevent issues when running multiple CLI tests in parallel, give each CLI test unique names: -struct fastq_to_fasta : public cli_test {}; +struct fastq_to_fasta : public cli_test +{}; TEST_F(fastq_to_fasta, no_options) { cli_test_result result = execute_app("app-template"); - std::string expected - { - "Fastq-to-Fasta-Converter\n" - "========================\n" - " Try -h or --help for more information.\n" - }; + std::string expected{"Fastq-to-Fasta-Converter\n" + "========================\n" + " Try -h or --help for more information.\n"}; EXPECT_EQ(result.exit_code, 0); EXPECT_EQ(result.out, expected); EXPECT_EQ(result.err, std::string{}); @@ -32,11 +30,8 @@ TEST_F(fastq_to_fasta, no_options) TEST_F(fastq_to_fasta, fail_no_argument) { cli_test_result result = execute_app("app-template", "-v"); - std::string expected - { - "Parsing error. Not enough positional arguments provided (Need at least 1). " - "See -h/--help for more information.\n" - }; + std::string expected{"Parsing error. Not enough positional arguments provided (Need at least 1). " + "See -h/--help for more information.\n"}; EXPECT_NE(result.exit_code, 0); EXPECT_EQ(result.out, std::string{}); EXPECT_EQ(result.err, expected); diff --git a/test/cmake/app_datasources.cmake b/test/cmake/app_datasources.cmake index 76bb655..cb7b425 100644 --- a/test/cmake/app_datasources.cmake +++ b/test/cmake/app_datasources.cmake @@ -46,19 +46,18 @@ function (declare_datasource) # create data folder file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data) - ExternalProject_Add ( - "${datasource_name}" - URL "${ARG_URL}" - URL_HASH "${ARG_URL_HASH}" - DOWNLOAD_NAME "${ARG_FILE}" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_BINARY_DIR}/data/${ARG_FILE} - TEST_COMMAND "" - PREFIX "${CMAKE_CURRENT_BINARY_DIR}/_datasources" - DOWNLOAD_NO_EXTRACT TRUE # don't extract archive files like .tar.gz. - ${ARG_UNPARSED_ARGUMENTS} + ExternalProject_Add ("${datasource_name}" + URL "${ARG_URL}" + URL_HASH "${ARG_URL_HASH}" + DOWNLOAD_NAME "${ARG_FILE}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND ${CMAKE_COMMAND} -E create_symlink + ${CMAKE_CURRENT_BINARY_DIR}/data/${ARG_FILE} + TEST_COMMAND "" + PREFIX "${CMAKE_CURRENT_BINARY_DIR}/_datasources" + DOWNLOAD_NO_EXTRACT TRUE # don't extract archive files like .tar.gz. + ${ARG_UNPARSED_ARGUMENTS} ) endfunction () diff --git a/test/cmake/seqan_require_ccache.cmake b/test/cmake/seqan_require_ccache.cmake deleted file mode 100644 index 497a1d0..0000000 --- a/test/cmake/seqan_require_ccache.cmake +++ /dev/null @@ -1,55 +0,0 @@ -cmake_minimum_required (VERSION 3.16) - -include (FindPackageMessage) - -# Uses `ccache` to cache build results. -# -# See also -# * https://ccache.dev/ -# * https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.html -macro (seqan_require_ccache) - set (SEQAN_USE_CCACHE - ON - CACHE BOOL "Use ccache if available." - ) - set (SEQAN_FPROFILE_ABS_PATH "-fprofile-abs-path") - if (SEQAN_USE_CCACHE) - find_program (CCACHE_PROGRAM ccache) - find_package_message (CCACHE_PROGRAM_PRE "Finding program ccache" "[${CCACHE_PROGRAM}]") - - if (NOT CCACHE_PROGRAM) - find_package_message (CCACHE_PROGRAM "Finding program ccache - Failed" "[${CCACHE_PROGRAM}]") - else () - find_package_message (CCACHE_PROGRAM "Finding program ccache - Success" "[${CCACHE_PROGRAM}]") - set (SEQAN_FPROFILE_ABS_PATH "--ccache-skip -fprofile-abs-path") - # New option since cmake >= 3.4: - # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.html - if (NOT CMAKE_VERSION VERSION_LESS 3.15) # cmake >= 3.15 - list (PREPEND CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") - list (PREPEND CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") - else () - # prepend ccache to CMAKE_CXX_COMPILER_LAUNCHER - list (INSERT CMAKE_CXX_COMPILER_LAUNCHER 0 "${CCACHE_PROGRAM}") - list (INSERT CMAKE_C_COMPILER_LAUNCHER 0 "${CCACHE_PROGRAM}") - endif () - - # use ccache in external cmake projects - list (APPEND SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS - "-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}" - ) - list (APPEND SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS "-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}") - - if (NOT CMAKE_VERSION VERSION_LESS 3.21) # cmake >= 3.21 - list (PREPEND CMAKE_CXX_LINKER_LAUNCHER "${CCACHE_PROGRAM}") - list (PREPEND CMAKE_C_LINKER_LAUNCHER "${CCACHE_PROGRAM}") - list (APPEND SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS - "-DCMAKE_CXX_LINKER_LAUNCHER=${CMAKE_CXX_LINKER_LAUNCHER}" - ) - list (APPEND SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS "-DCMAKE_C_LINKER_LAUNCHER=${CMAKE_C_LINKER_LAUNCHER}") - else () - set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM}") - endif () - endif () - unset (CCACHE_PROGRAM) - endif () -endmacro () diff --git a/test/coverage/CMakeLists.txt b/test/coverage/CMakeLists.txt index 374571f..68fb071 100644 --- a/test/coverage/CMakeLists.txt +++ b/test/coverage/CMakeLists.txt @@ -3,24 +3,22 @@ cmake_minimum_required (VERSION 3.16) # Add a custom build type: Coverage set (CMAKE_CXX_FLAGS_COVERAGE - "${CMAKE_CXX_FLAGS_DEBUG} --coverage -fprofile-arcs -ftest-coverage" CACHE STRING - "Flags used by the C++ compiler during coverage builds." - FORCE) + "${CMAKE_CXX_FLAGS_DEBUG} --coverage -fprofile-arcs -ftest-coverage ${FPROFILE_ABS_PATH}" + CACHE STRING "Flags used by the C++ compiler during coverage builds." FORCE +) set (CMAKE_C_FLAGS_COVERAGE - "${CMAKE_C_FLAGS_DEBUG} --coverage -fprofile-arcs -ftest-coverage" CACHE STRING - "Flags used by the C compiler during coverage builds." - FORCE) + "${CMAKE_C_FLAGS_DEBUG} --coverage -fprofile-arcs -ftest-coverage ${FPROFILE_ABS_PATH}" + CACHE STRING "Flags used by the C compiler during coverage builds." FORCE +) set (CMAKE_EXE_LINKER_FLAGS_COVERAGE - "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Wl,-lgcov" CACHE STRING - "Flags used for linking binaries during coverage builds." - FORCE) + "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Wl,-lgcov" + CACHE STRING "Flags used for linking binaries during coverage builds." FORCE +) set (CMAKE_SHARED_LINKER_FLAGS_COVERAGE - "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,-lgcov" CACHE STRING - "Flags used by the shared libraries linker during coverage builds." - FORCE) + "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,-lgcov" + CACHE STRING "Flags used by the shared libraries linker during coverage builds." FORCE +) -mark_as_advanced ( - CMAKE_CXX_FLAGS_COVERAGE - CMAKE_C_FLAGS_COVERAGE - CMAKE_EXE_LINKER_FLAGS_COVERAGE - CMAKE_SHARED_LINKER_FLAGS_COVERAGE) +mark_as_advanced (CMAKE_CXX_FLAGS_COVERAGE CMAKE_C_FLAGS_COVERAGE CMAKE_EXE_LINKER_FLAGS_COVERAGE + CMAKE_SHARED_LINKER_FLAGS_COVERAGE +) diff --git a/test/data/datasources.cmake b/test/data/datasources.cmake index 2c47fda..adb2574 100644 --- a/test/data/datasources.cmake +++ b/test/data/datasources.cmake @@ -3,6 +3,6 @@ cmake_minimum_required (VERSION 3.16) include (cmake/app_datasources.cmake) # copies file to /data/in.fastq -declare_datasource (FILE in.fastq - URL ${CMAKE_SOURCE_DIR}/test/data/in.fastq - URL_HASH SHA256=6e30fc35f908a36fe0c68a7a35c47f51f9570da16622fb0c072a20e6a9ba5b3e) +declare_datasource (FILE in.fastq URL ${CMAKE_SOURCE_DIR}/test/data/in.fastq URL_HASH + SHA256=6e30fc35f908a36fe0c68a7a35c47f51f9570da16622fb0c072a20e6a9ba5b3e +) diff --git a/test/header/CMakeLists.txt b/test/header/CMakeLists.txt index 6319df8..9a463a4 100644 --- a/test/header/CMakeLists.txt +++ b/test/header/CMakeLists.txt @@ -4,58 +4,47 @@ include (seqan3_test_files) include (seqan3_test_component) add_library ("${PROJECT_NAME}_header_test_lib" INTERFACE) -target_link_libraries ("${PROJECT_NAME}_header_test_lib" INTERFACE "${PROJECT_NAME}_interface" gtest gtest_main) -target_include_directories ("${PROJECT_NAME}_header_test_lib" INTERFACE "${SEQAN3_TEST_CLONE_DIR}/googletest/include/") +target_link_libraries ("${PROJECT_NAME}_header_test_lib" INTERFACE "${PROJECT_NAME}_test") # SeqAn3 script adds an include for target_include_directories ("${PROJECT_NAME}_header_test_lib" INTERFACE ./dummy_include) -set (target "header_test") +set (target "${PROJECT_NAME}_header_test") set (header_base_path "${CMAKE_CURRENT_LIST_DIR}/../../include/") -file (GLOB_RECURSE header_files RELATIVE "${header_base_path}" "${header_base_path}/*.hpp") +file (GLOB_RECURSE header_files + RELATIVE "${header_base_path}" + "${header_base_path}/*.hpp" +) file (WRITE "${PROJECT_BINARY_DIR}/${target}.cpp" "") add_executable (${target} ${PROJECT_BINARY_DIR}/${target}.cpp) target_link_libraries (${target} ${PROJECT_NAME}_header_test_lib) -add_test (NAME "header/${target}" COMMAND ${target}) +add_test (NAME "${target}" COMMAND ${target}) foreach (header ${header_files}) seqan3_test_component (header_test_name "${header}" TEST_NAME) seqan3_test_component (header_target_name "${header}" TARGET_UNIQUE_NAME) foreach (header_sub_test "header-guard" "no-self-include") - set (header_target_source "${PROJECT_BINARY_DIR}/${target}_files/${header_test_name}.hpp-${header_sub_test}.cpp") + set (header_target_source + "${PROJECT_BINARY_DIR}/${target}_files/${header_test_name}.hpp-${header_sub_test}.cpp" + ) set (header_target "${target}--${header_target_name}-${header_sub_test}") - string (REPLACE "-" "__" header_test_name_safe "${target}, ${header_target}") # we use add_custom_command to detect changes to a header file, which will update the generated source file add_custom_command (OUTPUT "${header_target_source}" - COMMAND "${CMAKE_COMMAND}" - "-DHEADER_FILE_ABSOLUTE=${header_base_path}/${header}" - "-DHEADER_FILE_INCLUDE=${header}" - "-DHEADER_TARGET_SOURCE=${header_target_source}" + COMMAND "${CMAKE_COMMAND}" "-DHEADER_FILE_ABSOLUTE=${header_base_path}/${header}" + "-DHEADER_FILE_INCLUDE=${header}" "-DHEADER_TARGET_SOURCE=${header_target_source}" "-DHEADER_TEST_NAME_SAFE=${header_test_name_safe}" - "-DHEADER_COMPONENT=${PROJECT_NAME}" - "-DHEADER_SUB_TEST=${header_sub_test}" - "-P" + "-DHEADER_COMPONENT=${PROJECT_NAME}" "-DHEADER_SUB_TEST=${header_sub_test}" "-P" "${SEQAN3_CLONE_DIR}/test/header/generate_header_source.cmake" DEPENDS "${header_base_path}/${header}" - "${SEQAN3_CLONE_DIR}/test/header/generate_header_source.cmake") + "${SEQAN3_CLONE_DIR}/test/header/generate_header_source.cmake" + ) add_library (${header_target} OBJECT "${header_target_source}") - - # NOTE: a simple target_link_libraries (${header_target} ${PROJECT_NAME}_header_test_lib) - # is not possible for OBJECT libraries before cmake 3.12 - if (CMAKE_VERSION VERSION_LESS 3.12) - target_compile_options (${header_target} PRIVATE $) - target_compile_definitions (${header_target} PRIVATE $) - target_include_directories (${header_target} PRIVATE $) - add_dependencies (${header_target} "${PROJECT_NAME}_interface" gtest gtest_main) - else () - target_link_libraries (${header_target} ${PROJECT_NAME}_header_test_lib) - endif () - + target_link_libraries (${header_target} ${PROJECT_NAME}_header_test_lib) target_sources (${target} PRIVATE $) endforeach () endforeach ()