-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
199 lines (170 loc) · 4.88 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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
cmake_minimum_required(VERSION 3.13)
project(tig)
option(TIG_BUILD_TESTS "Build tests." ON)
option(TIG_BUILD_EXAMPLE "Build example." ON)
# ------------------------------------------------------------------------------
# DEPENDENCIES
# ------------------------------------------------------------------------------
add_subdirectory("third_party/fpattern" EXCLUDE_FROM_ALL)
add_subdirectory("third_party/zlib" EXCLUDE_FROM_ALL)
if(TIG_BUILD_TESTS)
add_subdirectory("third_party/googletest" EXCLUDE_FROM_ALL)
endif()
add_subdirectory("first_party/bink_compat" EXCLUDE_FROM_ALL)
add_subdirectory("first_party/mss_compat" EXCLUDE_FROM_ALL)
# ------------------------------------------------------------------------------
# PROJECT FILES
# ------------------------------------------------------------------------------
# Keep alphabetically sorted.
set(HDRS
"include/tig/art.h"
"include/tig/bmp_utils.h"
"include/tig/bmp.h"
"include/tig/bsearch.h"
"include/tig/button.h"
"include/tig/color.h"
"include/tig/core.h"
"include/tig/database.h"
"include/tig/debug.h"
"include/tig/draw.h"
"include/tig/dxinput.h"
"include/tig/file_cache.h"
"include/tig/file.h"
"include/tig/find_file.h"
"include/tig/font.h"
"include/tig/idxtable.h"
"include/tig/kb.h"
"include/tig/memory.h"
"include/tig/menu.h"
"include/tig/message.h"
"include/tig/mouse.h"
"include/tig/movie.h"
"include/tig/net_blacklist.h"
"include/tig/net_xfer.h"
"include/tig/net.h"
"include/tig/palette.h"
"include/tig/rect.h"
"include/tig/sound.h"
"include/tig/str_parse.h"
"include/tig/tig.h"
"include/tig/timer.h"
"include/tig/video.h"
"include/tig/window.h"
)
# Keep alphabetically sorted.
set(SRCS
"src/art.c"
"src/bmp_utils.c"
"src/bmp.c"
"src/bsearch.c"
"src/button.c"
"src/color.c"
"src/core.c"
"src/database.c"
"src/debug.c"
"src/draw.c"
"src/dxinput.c"
"src/file_cache.c"
"src/file.c"
"src/find_file.c"
"src/font.c"
"src/idxtable.c"
"src/kb.c"
"src/memory.c"
"src/menu.c"
"src/message.c"
"src/mouse.c"
"src/movie.c"
"src/net_blacklist.c"
"src/net_xfer.c"
"src/net.c"
"src/palette.c"
"src/rect.c"
"src/sound.c"
"src/str_parse.c"
"src/timer.c"
"src/video.c"
"src/window.c"
)
# ------------------------------------------------------------------------------
# COMMON LIBRARY
# ------------------------------------------------------------------------------
add_library(tig_common INTERFACE)
target_include_directories(tig_common INTERFACE
${ZLIB_INCLUDE_DIRS}
${BINK_COMPAT_INCLUDE_DIR}
${MSS_COMPAT_INCLUDE_DIR}
"${CMAKE_CURRENT_SOURCE_DIR}/include"
)
target_link_libraries(tig_common INTERFACE
fpattern::fpattern
${ZLIB_LIBRARIES}
${BINK_COMPAT_LIBRARY}
${MSS_COMPAT_LIBRARY}
)
if(WIN32)
target_compile_definitions(tig_common INTERFACE
_CRT_NONSTDC_NO_WARNINGS
_CRT_SECURE_NO_WARNINGS
_USE_32BIT_TIME_T
WIN32_LEAN_AND_MEAN
)
target_link_libraries(tig_common INTERFACE
ddraw
dxguid
winmm
)
endif()
# ------------------------------------------------------------------------------
# TIG
# ------------------------------------------------------------------------------
add_library(tig STATIC
${HDRS}
${SRCS}
)
# Derive settings from common library.
target_link_libraries(tig PUBLIC tig_common)
# Turn on strict mode (but only for the library itself, hence PRIVATE).
if(MSVC)
target_compile_options(tig PRIVATE /W4 /WX)
else()
target_compile_options(tig PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
# ------------------------------------------------------------------------------
# TIG TESTS
# ------------------------------------------------------------------------------
if(TIG_BUILD_TESTS)
enable_testing()
# Keep alphabetically sorted.
set(TSTS
"test/art_tests.cc"
"test/bmp_utils_tests.cc"
"test/bsearch_tests.cc"
"test/color_tests.cc"
"test/database_tests.cc"
"test/dxinput_tests.cc"
"test/idxtable_tests.cc"
"test/memory_tests.cc"
"test/palette_tests.cc"
"test/rect_tests.cc"
"test/str_parse_tests.cc"
"test/timer_tests.cc"
)
add_executable(tig_tests
${TSTS}
)
target_link_libraries(tig_tests PUBLIC tig)
# Let GoogleTest provide synthesized `main`.
target_link_libraries(tig_tests PUBLIC GTest::gtest_main)
include(GoogleTest)
gtest_discover_tests(tig_tests)
endif()
# ------------------------------------------------------------------------------
# EXAMPLE
# ------------------------------------------------------------------------------
if(TIG_BUILD_EXAMPLE)
add_executable(example WIN32
"example/main.c"
)
target_link_libraries(example PUBLIC tig)
endif()