forked from JBenda/inkcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
142 lines (131 loc) · 4.65 KB
/
Copy pathCMakeLists.txt
File metadata and controls
142 lines (131 loc) · 4.65 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
if(INKCPP_NO_STL)
message(FATAL_ERROR "Can not build tests without STL support, please disable INKCPP_TEST")
endif()
add_executable(
inkcpp_test
catch.hpp
Main.cpp
Array.cpp
Pointer.cpp
Stack.cpp
Callstack.cpp
Restorable.cpp
Value.cpp
Globals.cpp
Lists.cpp
Tags.cpp
TagsAndBranching.cpp
NewLines.cpp
FallbackFunction.cpp
LabelCondition.cpp
Observer.cpp
InkyJson.cpp
SpaceAfterBracketChoice.cpp
ThirdTierChoiceAfterBrackets.cpp
NoEarlyTags.cpp
ExternalFunctionsExecuteProperly.cpp
ExternalFunctionTypes.cpp
LookaheadSafe.cpp
EmptyStringForDivert.cpp
MoveTo.cpp
ListMatching.cpp
Fixes.cpp
Migration.cpp
MultiRunner.cpp
)
target_link_libraries(inkcpp_test PUBLIC inkcpp inkcpp_compiler inkcpp_shared)
target_include_directories(inkcpp_test PRIVATE ../shared/private/)
# For https://en.cppreference.com/w/cpp/filesystem#Notes
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.1")
target_link_libraries(inkcpp_test PRIVATE stdc++fs)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0")
target_link_libraries(inkcpp_test PRIVATE stdc++fs)
endif()
endif()
add_test(NAME UnitTests COMMAND $<TARGET_FILE:inkcpp_test>)
if($ENV{INKLECATE})
set(INKLECATE_CMD $ENV{INKLECATE})
else()
set(INKLECATE_CMD "inklecate")
endif()
string(TOUPPER "${INKCPP_INKLECATE}" inkcpp_inklecate_upper)
if((inkcpp_inklecate_upper STREQUAL "ALL") OR (inkcpp_inklecate_upper STREQUAL "OS"))
if(UNIX AND NOT APPLE)
FetchContent_GetProperties(inklecate_linux)
if(inklecate_linux_POPULATED)
set(INKLECATE_CMD "${inklecate_linux_SOURCE_DIR}/inklecate")
else()
message(
FATAL_ERROR
"inklecate download is not provided, please check if the download failed.
You may set INKCPP_INKLECATE=NONE and provide inkcleate via your PATH or \
the INKLECATE enviroment variable.
You can also disable tests altogether by setting INKCPP_TEST=OFF")
endif(inklecate_linux_POPULATED)
elseif(APPLE)
if(inklecate_mac_POPULATED)
set(INKLECATE_CMD "${inklecate_mac_SOURCE_DIR}/inklecate")
else()
message(
FATAL_ERROR
"inklecate download is not provided, please check if the download failed.
You may set INKCPP_INKLECATE=NONE and provide inkcleate via your PATH or \
the INKLECATE enviroment variable.
You can also disable tests altogether by setting INKCPP_TEST=OFF")
endif(inklecate_mac_POPULATED)
elseif(
MSYS
OR MINGW
OR WIN32
OR CYGWIN)
if(inklecate_windows_POPULATED)
set(INKLECATE_CMD "${inklecate_windows_SOURCE_DIR}/inklecate")
else()
message(
FATAL_ERROR
"inklecate download is not provided, please check if the download failed.
You may set INKCPP_INKLECATE=NONE and provide inkcleate via your PATH or \
the INKLECATE enviroment variable.
You can also disable tests altogether by setting INKCPP_TEST=OFF")
endif(inklecate_windows_POPULATED)
else()
message(
FATAL_ERROR
"Current os could not be identified, therfore inklecate must be provided \
explicit for the tests to work
please set INKCPP_INKLECATE=NONE and provide inklecate via your PATH or \
the INKLECATE enviroment variables.
Alternatily disable tests by setting INKCPP_TEST=OFF.")
endif()
endif((inkcpp_inklecate_upper STREQUAL "ALL") OR (inkcpp_inklecate_upper STREQUAL "OS"))
set(INK_TEST_RESOURCE_DIR "${PROJECT_BINARY_DIR}/ink")
file(MAKE_DIRECTORY "${INK_TEST_RESOURCE_DIR}")
target_compile_definitions(inkcpp_test PRIVATE INK_TEST_RESOURCE_DIR="${INK_TEST_RESOURCE_DIR}/")
file(GLOB JSON_FILES "${CMAKE_CURRENT_SOURCE_DIR}/ink/*.json")
file(COPY ${JSON_FILES} DESTINATION ${INK_TEST_RESOURCE_DIR})
file(GLOB INK_FILES "${CMAKE_CURRENT_SOURCE_DIR}/ink/*.ink")
foreach(ink_file IN LISTS INK_FILES)
get_filename_component(INK_FILENAME ${ink_file} NAME_WE)
set(OUTPUT "${INK_TEST_RESOURCE_DIR}/${INK_FILENAME}.bin")
add_custom_command(
OUTPUT ${OUTPUT}
COMMAND $<TARGET_FILE:inkcpp_cl> -o "${OUTPUT}" --inklecate "${INKLECATE_CMD}" "${ink_file}"
DEPENDS ${ink_file} inkcpp_compiler
COMMENT "Compile test ink file '${INK_FILENAME}.ink' -> '${OUTPUT}'")
list(APPEND INK_OUT_FILES ${OUTPUT})
endforeach()
target_sources(inkcpp_test PRIVATE ${INK_OUT_FILES})
if(TARGET inkcpp_c)
file(GLOB TEST_FILES "${PROJECT_SOURCE_DIR}/inkcpp_c/tests/*.c")
foreach(test_file IN LISTS TEST_FILES)
get_filename_component(TEST_NAME ${test_file} NAME_WE)
add_executable(${TEST_NAME} ${test_file})
target_link_libraries(${TEST_NAME} PRIVATE inkcpp_c)
target_compile_definitions(${TEST_NAME}
PRIVATE INK_TEST_RESOURCE_DIR="${INK_TEST_RESOURCE_DIR}/")
add_test(NAME ${TEST_NAME} COMMAND $<TARGET_FILE:${TEST_NAME}>)
endforeach()
endif(TARGET inkcpp_c)