-
Notifications
You must be signed in to change notification settings - Fork 55
/
CMakeLists.txt
532 lines (494 loc) · 17 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
cmake_minimum_required(VERSION 3.16...3.28 FATAL_ERROR)
project(liblcf VERSION 0.8 LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/Modules)
include(ConfigureWindows)
include(MiscUtils)
# Compilation options
option(BUILD_SHARED_LIBS "Build shared library, disable for building the static library (default: ON)" ON)
option(LIBLCF_WITH_ICU "ICU encoding handling (when disabled only windows-1252 is supported, default: ON)" ON)
option(LIBLCF_WITH_XML "XML reading support (expat, default: ON)" ON)
option(LIBLCF_UPDATE_MIMEDB "Whether to run update-mime-database after install (default: ON)" ON)
option(LIBLCF_ENABLE_TOOLS "Whether to build the tools (default: ON)" ${LIBLCF_MAIN_PROJECT})
option(LIBLCF_ENABLE_TESTS "Whether to build the unit tests (default: ON)" ${LIBLCF_MAIN_PROJECT})
option(LIBLCF_ENABLE_BENCHMARKS "Whether to build the benchmarks (default: OFF)" OFF)
option(LIBLCF_ENABLE_INSTALL "Whether to add an install target (default: ON)" ${LIBLCF_MAIN_PROJECT})
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Override CMAKE_DEBUG_POSTFIX.")
# Dependencies provided by CMake Presets
list(APPEND CMAKE_PREFIX_PATH "${LIBLCF_PREFIX_PATH_APPEND}")
# C++17 is required
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
# lcf library files
set(LCF_SOURCES
src/dbarray.cpp
src/dbstring_struct.cpp
src/encoder.cpp
src/inireader.cpp
src/ldb_equipment.cpp
src/ldb_eventcommand.cpp
src/ldb_parameters.cpp
src/ldb_reader.cpp
src/lmt_reader.cpp
src/lmt_rect.cpp
src/lmt_treemap.cpp
src/lmu_movecommand.cpp
src/lmu_reader.cpp
src/log.h
src/lsd_reader.cpp
src/log_handler.cpp
src/reader_flags.cpp
src/reader_lcf.cpp
src/reader_struct.h
src/reader_struct_impl.h
src/reader_util.cpp
src/reader_xml.cpp
src/rpg_setup.cpp
src/rpg_terms.cpp
src/saveopt.cpp
src/writer_lcf.cpp
src/writer_xml.cpp
src/generated/fwd_struct_impl.h
src/generated/ldb_actor.cpp
src/generated/ldb_animation.cpp
src/generated/ldb_animationcelldata.cpp
src/generated/ldb_animationframe.cpp
src/generated/ldb_animationtiming.cpp
src/generated/ldb_attribute.cpp
src/generated/ldb_battlecommand.cpp
src/generated/ldb_battlecommands.cpp
src/generated/ldb_battleranimation.cpp
src/generated/ldb_battleranimationitemskill.cpp
src/generated/ldb_battleranimationpose.cpp
src/generated/ldb_battleranimationweapon.cpp
src/generated/ldb_chipset.cpp
src/generated/ldb_class.cpp
src/generated/ldb_commonevent.cpp
src/generated/ldb_database.cpp
src/generated/ldb_enemy.cpp
src/generated/ldb_enemyaction.cpp
src/generated/ldb_item.cpp
src/generated/ldb_learning.cpp
src/generated/ldb_music.cpp
src/generated/ldb_skill.cpp
src/generated/ldb_sound.cpp
src/generated/ldb_state.cpp
src/generated/ldb_switch.cpp
src/generated/ldb_system.cpp
src/generated/ldb_terms.cpp
src/generated/ldb_terrain.cpp
src/generated/ldb_terrain_flags.h
src/generated/ldb_testbattler.cpp
src/generated/ldb_troop.cpp
src/generated/ldb_troopmember.cpp
src/generated/ldb_trooppage.cpp
src/generated/ldb_trooppagecondition.cpp
src/generated/ldb_trooppagecondition_flags.h
src/generated/ldb_variable.cpp
src/generated/lmt_encounter.cpp
src/generated/lmt_mapinfo.cpp
src/generated/lmt_start.cpp
src/generated/lmu_event.cpp
src/generated/lmu_eventpage.cpp
src/generated/lmu_eventpagecondition.cpp
src/generated/lmu_eventpagecondition_flags.h
src/generated/lmu_map.cpp
src/generated/lmu_moveroute.cpp
src/generated/lsd_save.cpp
src/generated/lsd_saveactor.cpp
src/generated/lsd_savecommonevent.cpp
src/generated/lsd_saveeasyrpgdata.cpp
src/generated/lsd_saveeasyrpgtext.cpp
src/generated/lsd_saveeasyrpgtext_flags.h
src/generated/lsd_saveeasyrpgwindow.cpp
src/generated/lsd_saveeasyrpgwindow_flags.h
src/generated/lsd_saveeventexecframe.cpp
src/generated/lsd_saveeventexecstate.cpp
src/generated/lsd_saveinventory.cpp
src/generated/lsd_savemapevent.cpp
src/generated/lsd_savemapeventbase.cpp
src/generated/lsd_savemapinfo.cpp
src/generated/lsd_savepanorama.cpp
src/generated/lsd_savepartylocation.cpp
src/generated/lsd_savepicture.cpp
src/generated/lsd_savepicture_flags.h
src/generated/lsd_savescreen.cpp
src/generated/lsd_savesystem.cpp
src/generated/lsd_savetarget.cpp
src/generated/lsd_savetitle.cpp
src/generated/lsd_savevehiclelocation.cpp
src/generated/rpg_actor.cpp
src/generated/rpg_animation.cpp
src/generated/rpg_animationcelldata.cpp
src/generated/rpg_animationframe.cpp
src/generated/rpg_animationtiming.cpp
src/generated/rpg_attribute.cpp
src/generated/rpg_battlecommand.cpp
src/generated/rpg_battlecommands.cpp
src/generated/rpg_battleranimation.cpp
src/generated/rpg_battleranimationitemskill.cpp
src/generated/rpg_battleranimationpose.cpp
src/generated/rpg_battleranimationweapon.cpp
src/generated/rpg_chipset.cpp
src/generated/rpg_class.cpp
src/generated/rpg_commonevent.cpp
src/generated/rpg_database.cpp
src/generated/rpg_encounter.cpp
src/generated/rpg_enemy.cpp
src/generated/rpg_enemyaction.cpp
src/generated/rpg_enums.cpp
src/generated/rpg_equipment.cpp
src/generated/rpg_event.cpp
src/generated/rpg_eventcommand.cpp
src/generated/rpg_eventpage.cpp
src/generated/rpg_eventpagecondition.cpp
src/generated/rpg_item.cpp
src/generated/rpg_learning.cpp
src/generated/rpg_map.cpp
src/generated/rpg_mapinfo.cpp
src/generated/rpg_movecommand.cpp
src/generated/rpg_moveroute.cpp
src/generated/rpg_music.cpp
src/generated/rpg_parameters.cpp
src/generated/rpg_rect.cpp
src/generated/rpg_save.cpp
src/generated/rpg_saveactor.cpp
src/generated/rpg_savecommonevent.cpp
src/generated/rpg_saveeasyrpgdata.cpp
src/generated/rpg_saveeasyrpgtext.cpp
src/generated/rpg_saveeasyrpgwindow.cpp
src/generated/rpg_saveeventexecframe.cpp
src/generated/rpg_saveeventexecstate.cpp
src/generated/rpg_saveinventory.cpp
src/generated/rpg_savemapevent.cpp
src/generated/rpg_savemapeventbase.cpp
src/generated/rpg_savemapinfo.cpp
src/generated/rpg_savepanorama.cpp
src/generated/rpg_savepartylocation.cpp
src/generated/rpg_savepicture.cpp
src/generated/rpg_savescreen.cpp
src/generated/rpg_savesystem.cpp
src/generated/rpg_savetarget.cpp
src/generated/rpg_savetitle.cpp
src/generated/rpg_savevehiclelocation.cpp
src/generated/rpg_skill.cpp
src/generated/rpg_sound.cpp
src/generated/rpg_start.cpp
src/generated/rpg_state.cpp
src/generated/rpg_switch.cpp
src/generated/rpg_system.cpp
src/generated/rpg_terms.cpp
src/generated/rpg_terrain.cpp
src/generated/rpg_testbattler.cpp
src/generated/rpg_treemap.cpp
src/generated/rpg_troop.cpp
src/generated/rpg_troopmember.cpp
src/generated/rpg_trooppage.cpp
src/generated/rpg_trooppagecondition.cpp
src/generated/rpg_variable.cpp
)
set(LCF_HEADERS
src/lcf/context.h
src/lcf/dbarray.h
src/lcf/dbarrayalloc.h
src/lcf/dbbitarray.h
src/lcf/dbstring.h
src/lcf/encoder.h
src/lcf/enum_tags.h
src/lcf/flag_set.h
src/lcf/inireader.h
src/lcf/ldb/reader.h
src/lcf/lmt/reader.h
src/lcf/lmu/reader.h
src/lcf/lsd/reader.h
src/lcf/log_handler.h
src/lcf/reader_lcf.h
src/lcf/reader_util.h
src/lcf/reader_xml.h
src/lcf/saveopt.h
src/lcf/scope_guard.h
src/lcf/span.h
src/lcf/string_view.h
src/lcf/writer_lcf.h
src/lcf/writer_xml.h
src/generated/lcf/ldb/chunks.h
src/generated/lcf/lmt/chunks.h
src/generated/lcf/lmu/chunks.h
src/generated/lcf/lsd/chunks.h
src/generated/lcf/rpg/actor.h
src/generated/lcf/rpg/animation.h
src/generated/lcf/rpg/animationcelldata.h
src/generated/lcf/rpg/animationframe.h
src/generated/lcf/rpg/animationtiming.h
src/generated/lcf/rpg/attribute.h
src/generated/lcf/rpg/battlecommand.h
src/generated/lcf/rpg/battlecommands.h
src/generated/lcf/rpg/battleranimation.h
src/generated/lcf/rpg/battleranimationitemskill.h
src/generated/lcf/rpg/battleranimationpose.h
src/generated/lcf/rpg/battleranimationweapon.h
src/generated/lcf/rpg/chipset.h
src/generated/lcf/rpg/class.h
src/generated/lcf/rpg/commonevent.h
src/generated/lcf/rpg/database.h
src/generated/lcf/rpg/encounter.h
src/generated/lcf/rpg/enemy.h
src/generated/lcf/rpg/enemyaction.h
src/generated/lcf/rpg/equipment.h
src/generated/lcf/rpg/event.h
src/generated/lcf/rpg/eventcommand.h
src/generated/lcf/rpg/eventpage.h
src/generated/lcf/rpg/eventpagecondition.h
src/generated/lcf/rpg/fwd.h
src/generated/lcf/rpg/item.h
src/generated/lcf/rpg/learning.h
src/generated/lcf/rpg/map.h
src/generated/lcf/rpg/mapinfo.h
src/generated/lcf/rpg/movecommand.h
src/generated/lcf/rpg/moveroute.h
src/generated/lcf/rpg/music.h
src/generated/lcf/rpg/parameters.h
src/generated/lcf/rpg/rect.h
src/generated/lcf/rpg/save.h
src/generated/lcf/rpg/saveactor.h
src/generated/lcf/rpg/savecommonevent.h
src/generated/lcf/rpg/saveeasyrpgdata.h
src/generated/lcf/rpg/saveeasyrpgtext.h
src/generated/lcf/rpg/saveeasyrpgwindow.h
src/generated/lcf/rpg/saveeventexecframe.h
src/generated/lcf/rpg/saveeventexecstate.h
src/generated/lcf/rpg/saveinventory.h
src/generated/lcf/rpg/savemapevent.h
src/generated/lcf/rpg/savemapeventbase.h
src/generated/lcf/rpg/savemapinfo.h
src/generated/lcf/rpg/savepanorama.h
src/generated/lcf/rpg/savepartylocation.h
src/generated/lcf/rpg/savepicture.h
src/generated/lcf/rpg/savescreen.h
src/generated/lcf/rpg/savesystem.h
src/generated/lcf/rpg/savetarget.h
src/generated/lcf/rpg/savetitle.h
src/generated/lcf/rpg/savevehiclelocation.h
src/generated/lcf/rpg/skill.h
src/generated/lcf/rpg/sound.h
src/generated/lcf/rpg/start.h
src/generated/lcf/rpg/state.h
src/generated/lcf/rpg/switch.h
src/generated/lcf/rpg/system.h
src/generated/lcf/rpg/terms.h
src/generated/lcf/rpg/terrain.h
src/generated/lcf/rpg/testbattler.h
src/generated/lcf/rpg/treemap.h
src/generated/lcf/rpg/troop.h
src/generated/lcf/rpg/troopmember.h
src/generated/lcf/rpg/trooppage.h
src/generated/lcf/rpg/trooppagecondition.h
src/generated/lcf/rpg/variable.h
src/lcf/third_party/span.h
src/lcf/third_party/string_view.h
)
add_library(lcf ${LCF_SOURCES} ${LCF_HEADERS})
# IDE source grouping
foreach(SG LDB LMT LMU LSD RPG THIRD_PARTY)
string(TOLOWER ${SG} LSG)
source_group("Source Files\\generated\\${SG}" REGULAR_EXPRESSION "generated/${LSG}_.*\\.cpp")
source_group("Header Files\\generated\\${SG}" REGULAR_EXPRESSION "generated/lcf/${LSG}/.*\\.h")
source_group("Source Files\\${SG}" REGULAR_EXPRESSION "${LSG}_.*\\.cpp")
source_group("Header Files\\${SG}" REGULAR_EXPRESSION "/${LSG}/.*\\.h")
endforeach()
# includes
include(GNUInstallDirs)
target_include_directories(
lcf PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/generated>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
# Optimize floating point math functions into intrinsics and don't check or set errno (i.e. sqrt(-1))
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(lcf PRIVATE "-fno-math-errno")
endif()
# endianess checking
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.20)
if (CMAKE_CXX_BYTE_ORDER STREQUAL "BIG_ENDIAN")
target_compile_definitions(lcf PRIVATE WORDS_BIGENDIAN=1)
endif()
else()
include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)
if(WORDS_BIGENDIAN)
target_compile_definitions(lcf PRIVATE WORDS_BIGENDIAN=1)
endif()
endif()
# Add optional library name postfix
set_property(TARGET lcf PROPERTY DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
# Export symbols for DLL
set_property(TARGET lcf PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Name of the exported library
set_property(TARGET lcf PROPERTY EXPORT_NAME liblcf)
# inih
find_package(inih REQUIRED)
target_link_libraries(lcf inih::inih)
# icu
set(LCF_SUPPORT_ICU 0)
if(LIBLCF_WITH_ICU)
find_package(ICU COMPONENTS i18n uc data)
if(ICU_FOUND)
target_link_libraries(lcf ICU::i18n ICU::uc ICU::data)
list(APPEND LIBLCF_DEPS "icu-i18n")
set(LCF_SUPPORT_ICU 1)
else()
if(NOT WIN32)
message(FATAL_ERROR "ICU not found. Use LCF_SUPPORT_ICU=0 to disable ICU support (not recommended).")
endif()
message(STATUS "ICU not found. Using the system library.")
message(STATUS "This build will only work on Windows 10 Version 1903 (May 2019) and newer!")
target_link_libraries(lcf icu)
set(LCF_SUPPORT_ICU 2)
list(APPEND LIBLCF_DEPS "icu")
endif()
endif()
# expat
set(LCF_SUPPORT_XML 0)
if(LIBLCF_WITH_XML)
find_package(expat CONFIG)
if(expat_FOUND)
target_link_libraries(lcf expat::expat)
else()
# Fallback to old expat detection
find_package(EXPAT REQUIRED)
target_link_libraries(lcf EXPAT::EXPAT)
endif()
list(APPEND LIBLCF_DEPS "expat")
set(LCF_SUPPORT_XML 1)
endif()
# mime types
if(LIBLCF_UPDATE_MIMEDB AND NOT CMAKE_CROSSCOMPILING)
find_program(UPDATE_MIME_DATABASE update-mime-database)
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/builds/config.h.in" "src/lcf/config.h" @ONLY)
target_sources(lcf PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src/lcf/config.h)
# .so version
set_property(TARGET lcf PROPERTY SOVERSION 0)
# installation
if(LIBLCF_ENABLE_INSTALL)
# pkg-config file generation
set(LCF_LIBDIR ${CMAKE_INSTALL_LIBDIR})
if(IS_ABSOLUTE ${LCF_LIBDIR})
file(RELATIVE_PATH LCF_LIBDIR ${CMAKE_INSTALL_PREFIX} ${LCF_LIBDIR})
endif()
set(LCF_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
if(IS_ABSOLUTE ${LCF_INCLUDEDIR})
file(RELATIVE_PATH LCF_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${LCF_INCLUDEDIR})
endif()
set(PACKAGE_TARNAME ${PROJECT_NAME})
set(PACKAGE_VERSION ${PROJECT_VERSION})
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\${prefix}")
set(libdir "\${exec_prefix}/${LCF_LIBDIR}")
set(includedir "\${prefix}/${LCF_INCLUDEDIR}")
string(REPLACE ";" " " AX_PACKAGE_REQUIRES_PRIVATE "${LIBLCF_DEPS}")
configure_file(builds/${PROJECT_NAME}.pc.in builds/${PROJECT_NAME}.pc @ONLY)
# Cmake-config file generation
install(
TARGETS lcf
EXPORT lcf-export
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
set(LCF_INSTALL_HEADERS ${LCF_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/src/lcf/config.h)
foreach(S ldb lmt lmu lsd rpg third_party)
set(SUBDIR_HEADERS ${LCF_INSTALL_HEADERS})
list(FILTER SUBDIR_HEADERS INCLUDE REGEX "/${S}/")
install(FILES ${SUBDIR_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lcf/${S})
list(REMOVE_ITEM LCF_INSTALL_HEADERS ${SUBDIR_HEADERS})
endforeach()
install(FILES ${LCF_INSTALL_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lcf)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/builds/${PROJECT_NAME}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
install(
EXPORT lcf-export FILE liblcf-targets.cmake
NAMESPACE liblcf:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/liblcf
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/liblcf-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/liblcf-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/liblcf
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/liblcf-config-version.cmake
COMPATIBILITY ExactVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/liblcf-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/liblcf-config-version.cmake
${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/Modules/Findinih.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/liblcf
)
# mime types
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime/${PROJECT_NAME}.xml
DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages
)
if(LIBLCF_UPDATE_MIMEDB AND UPDATE_MIME_DATABASE)
install(CODE
"execute_process(COMMAND ${UPDATE_MIME_DATABASE}
\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/mime)"
)
endif()
endif()
# tests
if(LIBLCF_ENABLE_TESTS)
file(GLOB TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tests/*.cpp)
add_executable(test_runner_lcf EXCLUDE_FROM_ALL ${TEST_FILES})
target_compile_definitions(test_runner_lcf PRIVATE DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING=1)
set_target_properties(test_runner_lcf PROPERTIES OUTPUT_NAME "test_runner")
target_link_libraries(test_runner_lcf lcf)
add_custom_target(check_lcf COMMAND test_runner_lcf)
if(NOT TARGET check)
add_custom_target(check)
endif()
add_dependencies(check_lcf test_runner_lcf)
add_dependencies(check check_lcf)
endif()
# benchmarks
if(LIBLCF_ENABLE_BENCHMARKS)
file(GLOB BENCH_FILES ${CMAKE_CURRENT_SOURCE_DIR}/bench/*.cpp)
foreach(i ${BENCH_FILES})
get_filename_component(name "${i}" NAME_WE)
add_executable(bench_${name} ${i})
target_link_libraries(bench_${name} lcf)
endforeach()
endif()
# tools
if(LIBLCF_ENABLE_TOOLS)
add_custom_target(tools)
add_dependencies(tools lcf)
list(APPEND TOOLS lcfstrings)
if(LIBLCF_WITH_XML)
list(APPEND TOOLS lcf2xml)
endif()
foreach(tool ${TOOLS})
add_executable(${tool} tools/${tool}.cpp)
target_link_libraries(${tool} lcf)
add_dependencies(tools ${tool})
if(LIBLCF_ENABLE_INSTALL)
install(TARGETS ${tool} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endforeach()
endif()
# Doxygen documentation
find_package(Doxygen)
if(DOXYGEN_FOUND)
add_custom_target(liblcf_doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/builds/Doxyfile
DEPENDS lcf
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/builds
COMMENT "Generating API documentation with Doxygen" VERBATIM)
else()
message(STATUS "This means no API documentation is generated.")
endif()