-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.cmake
More file actions
54 lines (43 loc) · 1.74 KB
/
tests.cmake
File metadata and controls
54 lines (43 loc) · 1.74 KB
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
# Copyright (c) 2025 Tobias Erbsland - https://erbsland.dev
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.23)
if(ERBSLAND_RE_ENABLE_TESTS)
if(MSVC)
add_compile_options(/MP)
endif()
# Reuse the files from the regular library to build the test library with some extensions.
get_target_property(_sources erbsland-re SOURCES)
add_library(erbsland-re-for-test STATIC)
target_sources(erbsland-re-for-test PRIVATE ${_sources})
target_compile_definitions(erbsland-re-for-test PUBLIC
ERBSLAND_UNITTEST_BUILD=1)
# Set the main properties.
set_target_properties(erbsland-re-for-test PROPERTIES LINKER_LANGUAGE CXX)
target_compile_features(erbsland-re-for-test PUBLIC cxx_std_20)
if(MSVC)
target_compile_options(erbsland-re-for-test PUBLIC "/utf-8")
target_compile_options(erbsland-re-for-test PRIVATE /MP)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(MSVC)
target_compile_options(erbsland-re-for-test PRIVATE "/W4" "/WX")
else()
target_compile_options(erbsland-re-for-test PRIVATE "-Wall" "-Wextra" "-Werror")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(erbsland-re-for-test PRIVATE "-fno-omit-frame-pointer" "-mno-omit-leaf-frame-pointer")
endif ()
endif()
endif()
# Select the correct string type.
if (ERBSLAND_RE_U8STRING)
target_compile_definitions(erbsland-re-for-test PUBLIC ERBSLAND_RE_USE_U8STRING=1)
endif ()
# Add the test subdirectory.
add_subdirectory(test)
# Enable unit tests
enable_testing()
add_test(
NAME unittest
COMMAND $<TARGET_FILE:unittest> --no-color
)
endif()