-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
99 lines (87 loc) · 3.1 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
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
cmake_minimum_required(VERSION 3.20)
project(layec-test-runner)
## ============================================================================
## Tests
## ============================================================================
# Allow arbitrary characters in test names.
cmake_policy(SET CMP0110 NEW)
if (BUILD_TESTING)
include(ExternalProject)
include(CTest)
## Set fchk properties here.
if (DEFINED FCHK_GIT_TAG)
message(
FATAL_ERROR
"You've defined FCHK_GIT_TAG as a user-specified option, but you must alter the CMakeLists.txt to change this variable"
)
endif()
set(FCHK_GIT_TAG master)
## First, check if fchk has already been downloaded.
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/fchk/CMakeLists.txt")
message(STATUS "Downloading fchk")
## Delete old fchk directory.
if (EXISTS "${PROJECT_SOURCE_DIR}/fchk")
file(REMOVE_RECURSE "${PROJECT_SOURCE_DIR}/fchk")
endif()
## Clone the repo.
execute_process(
COMMAND git clone https://github.com/Sirraide/fchk
--branch "${FCHK_GIT_TAG}"
--depth 1
--recursive
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
COMMAND_ERROR_IS_FATAL ANY
ECHO_OUTPUT_VARIABLE
ECHO_ERROR_VARIABLE
)
endif()
## Next, update it to the right tag.
message(STATUS "Updating fchk")
execute_process(
COMMAND git fetch --tags
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/fchk"
COMMAND_ERROR_IS_FATAL ANY
ECHO_OUTPUT_VARIABLE
ECHO_ERROR_VARIABLE
)
execute_process(
COMMAND git fetch --depth 1 origin "${FCHK_GIT_TAG}"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/fchk"
COMMAND_ERROR_IS_FATAL ANY
ECHO_OUTPUT_VARIABLE
ECHO_ERROR_VARIABLE
)
execute_process(
COMMAND git reset --hard "${FCHK_GIT_TAG}"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/fchk"
COMMAND_ERROR_IS_FATAL ANY
ECHO_OUTPUT_VARIABLE
ECHO_ERROR_VARIABLE
)
## We only need to download fchk to be able to configure this,
## so add a target for the tests to build it when we run the tests.
add_custom_target(fchk ALL
COMMAND ${CMAKE_COMMAND}
-S "${PROJECT_SOURCE_DIR}/fchk"
-B "${PROJECT_SOURCE_DIR}/fchk/out"
-G "${CMAKE_GENERATOR}"
COMMAND ${CMAKE_COMMAND} --build "${PROJECT_SOURCE_DIR}/fchk/out"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/fchk"
BYPRODUCTS "${PROJECT_SOURCE_DIR}/fchk/out"
VERBATIM
USES_TERMINAL
)
## Now that that’s done, we can set up the tests.
set(FCHK_EXE_PATH "${PROJECT_SOURCE_DIR}/fchk/out/fchk")
include("${PROJECT_SOURCE_DIR}/fchk/cmake/FCHKDiscoverTests.cmake")
## Add more tests below if need be.
FCHKAddAllTestsInDir(
IN "test/laye"
PATTERN "*.laye"
PREFIX "//"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
ARGS -l . -D "layec=./out/layec0" -P re -P nocap
RECURSIVE
DEPENDS fchk
)
endif()