forked from groundswellaudio/swl-variant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
64 lines (43 loc) · 1.9 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.20)
project(swl.variant
VERSION 1.0.0
LANGUAGES CXX
HOMEPAGE_URL https://github.com/groundswellaudio/swl-variant)
add_library(swl-variant INTERFACE)
target_include_directories(swl-variant INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:./include>)
target_compile_features(swl-variant INTERFACE cxx_std_20)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
## tests that are supposed to not compile
## https://stackoverflow.com/questions/30155619/expected-build-failure-tests-in-cmake
math(EXPR test_idx 0)
file(GLOB_RECURSE test-sources CONFIGURE_DEPENDS tests/*.fail.cpp)
foreach (source IN LISTS test-sources)
get_filename_component(name "${source}" NAME_WE)
set(test "${PROJECT_NAME}-test-${name}-${test_idx}")
MATH(EXPR test_idx "${test_idx} + 1")
add_executable(${test} "${source}")
## avoid actually building the target
set_target_properties(${test} PROPERTIES
EXCLUDE_FROM_ALL TRUE
EXCLUDE_FROM_DEFAULT_BUILD TRUE)
target_link_libraries(${test} swl-variant)
target_include_directories(${test} PRIVATE ./tests)
add_test(NAME ${test}
COMMAND ${CMAKE_COMMAND} --build ./ --target ${test} --config $<CONFIGURATION>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_tests_properties(${test} PROPERTIES WILL_FAIL TRUE)
endforeach()
file(GLOB_RECURSE test-sources CONFIGURE_DEPENDS tests/*.pass.cpp)
foreach (source IN LISTS test-sources)
get_filename_component(name "${source}" NAME_WE)
set(test "${PROJECT_NAME}-test-${name}-${test_idx}")
MATH(EXPR test_idx "${test_idx} + 1")
add_executable(${test} "${source}")
target_link_libraries(${test} swl-variant)
target_include_directories(${test} PRIVATE ./tests)
add_test(NAME ${test} COMMAND ${test})
endforeach()
endif()