File: CMakeLists.txt

package info (click to toggle)
seqan3 3.2.0%2Bds-6%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 19,776 kB
  • sloc: cpp: 159,121; makefile: 1,290; sh: 414; ansic: 321; xml: 229; javascript: 98; perl: 29; python: 27; php: 25
file content (110 lines) | stat: -rw-r--r-- 5,643 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# -----------------------------------------------------------------------------------------------------
# Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
# Copyright (c) 2016-2022, 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/seqan3/blob/master/LICENSE.md
# -----------------------------------------------------------------------------------------------------

cmake_minimum_required (VERSION 3.10...3.22)
project (seqan3_test_snippet CXX)

include (../seqan3-test.cmake)
include (../cmake/diagnostics/list_unused_snippets.cmake)

option (SEQAN3_GENERATE_SNIPPETS "Whether seqan3 snippets should be generated and overwritten within the source tree."
        ON)

add_library (snippet_main snippet_main.cpp)
target_link_libraries (snippet_main PUBLIC seqan3::test gtest)

macro (seqan3_snippet test_name_prefix snippet snippet_base_path)
    seqan3_test_component (snippet_target_name "${snippet}" TARGET_NAME)
    seqan3_test_component (snippet_test_name "${snippet}" TEST_NAME)
    seqan3_test_component (snippet_target_path "${snippet}" TARGET_PATH)
    set (target "${snippet_target_name}_snippet")

    add_executable (${target} "${snippet_base_path}/${snippet}")
    target_link_libraries (${target} PUBLIC snippet_main)
    set_target_properties (${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
                                                "${CMAKE_CURRENT_BINARY_DIR}/${snippet_target_path}")
    collect_used_snippet (${target})

    set (snippet_test_target "${test_name_prefix}/${snippet_test_name}_snippet")
    add_test (NAME "${snippet_test_target}" COMMAND ${target})

    # disable version checker, as it interferes with comparing the snippet output
    set_tests_properties ("${snippet_test_target}" PROPERTIES ENVIRONMENT SEQAN3_NO_VERSION_CHECK=0)

    set (snippet_compare_test_target "${test_name_prefix}/${snippet_test_name}_snippet_cmp_output")

    add_test (NAME "${snippet_compare_test_target}"
              COMMAND ${CMAKE_COMMAND} -DTARGET_FILE=$<TARGET_FILE:${target}>
                      -DSOURCE_FILE=${snippet_base_path}/${snippet} #
                      -P "${CMAKE_SOURCE_DIR}/compare_snippet_output.cmake")

    # disable version checker, as it interferes with comparing the snippet output
    set_tests_properties ("${snippet_compare_test_target}" PROPERTIES ENVIRONMENT SEQAN3_NO_VERSION_CHECK=0)

    unset (snippet_target_name)
    unset (snippet_test_name)
    unset (snippet_target_path)
    unset (target)
endmacro ()

macro (seqan3_snippets test_name_prefix snippet_base_path)
    seqan3_test_files (snippet_files "${snippet_base_path}" "*.cpp")
    foreach (snippet ${snippet_files})
        seqan3_snippet ("${test_name_prefix}" "${snippet}" "${snippet_base_path}")
    endforeach ()
endmacro ()

seqan3_require_ccache ()
seqan3_require_test ()

seqan3_snippets ("snippet" "${CMAKE_CURRENT_SOURCE_DIR}")
seqan3_snippets ("doc/snippet" "${CMAKE_CURRENT_SOURCE_DIR}/../../doc")

# These are the tests that are known to have non-deterministic output.
set_tests_properties (
    "snippet/alignment/pairwise/parallel_align_pairwise_with_callback_snippet_cmp_output"
    "snippet/io/views/async_input_buffer_snippet_cmp_output"
    "snippet/release/3.0.2_user-callback-in-alignment-and-search_snippet_cmp_output"
    "snippet/utility/container/aligned_allocator_snippet_cmp_output"
    PROPERTIES SKIP_RETURN_CODE 1)

list_unused_snippets ("${CMAKE_CURRENT_SOURCE_DIR}")
list_unused_snippets ("${CMAKE_CURRENT_SOURCE_DIR}/../../doc")

if (SEQAN3_GENERATE_SNIPPETS)
    include (seqan3_generate_snippet)

    foreach (source_snippet IN
             ITEMS "test/snippet/alphabet/nucleotide/@target_alphabet@_implicit_conversion_from_@source_alphabet@.cpp.in"
                   "test/snippet/alphabet/nucleotide/@target_alphabet@_implicit_conversion_from_@source_alphabet@_inherit.cpp.in"
                   "test/snippet/alphabet/nucleotide/@target_alphabet@_implicit_conversion_from_@source_alphabet@_vector.cpp.in"
                   "test/snippet/alphabet/nucleotide/@target_alphabet@_implicit_conversion_from_@source_alphabet@_views.cpp.in"
                   "doc/fragments/@target_alphabet@_implicit_conversion_from_@source_alphabet@.md.in")
        seqan3_generate_snippet ("${source_snippet}" -Dtarget_alphabet=dna4 -Dsource_alphabet=rna4)
        seqan3_generate_snippet ("${source_snippet}" -Dtarget_alphabet=rna4 -Dsource_alphabet=dna4)
        seqan3_generate_snippet ("${source_snippet}" -Dtarget_alphabet=dna5 -Dsource_alphabet=rna5)
        seqan3_generate_snippet ("${source_snippet}" -Dtarget_alphabet=rna5 -Dsource_alphabet=dna5)
        seqan3_generate_snippet ("${source_snippet}" -Dtarget_alphabet=dna15 -Dsource_alphabet=rna15)
        seqan3_generate_snippet ("${source_snippet}" -Dtarget_alphabet=rna15 -Dsource_alphabet=dna15)
    endforeach ()

    foreach (target_alphabet IN
             ITEMS dna4
                   rna4
                   dna5
                   rna5
                   dna15
                   rna15
                   dna16sam
                   dna3bs)
        set (source_snippet "test/snippet/alphabet/nucleotide/@target_alphabet@_char_literal.cpp.in")
        seqan3_generate_snippet ("${source_snippet}" -Dtarget_alphabet=${target_alphabet})

        set (source_snippet "test/snippet/alphabet/nucleotide/@target_alphabet@_literal.cpp.in")
        seqan3_generate_snippet ("${source_snippet}" -Dtarget_alphabet=${target_alphabet})
    endforeach ()
endif ()