-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
99 lines (84 loc) · 2.82 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.12)
project(turn-based LANGUAGES CXX)
set(RENDERER console CACHE STRING "The rendering system to use")
set_property(CACHE RENDERER PROPERTY STRINGS console sfml)
# set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(RENDERER STREQUAL "sfml")
find_package(SFML 2.5 COMPONENTS graphics REQUIRED)
endif()
find_package(Lua 5.3 REQUIRED)
add_executable(${PROJECT_NAME})
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
target_include_directories(${PROJECT_NAME} PRIVATE src)
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE third_party/include)
target_sources(${PROJECT_NAME} PRIVATE
src/battle/action.h
src/battle/battlesystem.cpp
src/battle/battlesystem.h
src/battle/battleview.h
src/battle/config.cpp
src/battle/controller.h
src/battle/element.h
src/battle/entity.cpp
src/battle/entity.h
src/battle/messages.h
src/battle/npccontroller.cpp
src/battle/npccontroller.h
src/battle/playercontroller.cpp
src/battle/playercontroller.h
src/battle/skill.cpp
src/battle/skill.h
src/battle/skilldetails.h
src/battle/skillref.h
src/battle/stats.cpp
src/battle/stats.h
src/battle/statuseffect.cpp
src/battle/statuseffect.h
src/util/overload.h
src/util/random.h
)
if(RENDERER STREQUAL "console")
target_sources(${PROJECT_NAME} PRIVATE
src/conmain.cpp
)
else()
target_sources(${PROJECT_NAME} PRIVATE
src/main.cpp
src/game.cpp
src/game.h
)
endif()
if(MSVC)
string(REGEX REPLACE "/W[0-9]" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
target_compile_options(${PROJECT_NAME} PRIVATE /permissive-)
target_compile_options(${PROJECT_NAME} PRIVATE /diagnostics:caret)
target_compile_options(${PROJECT_NAME} PRIVATE /Zi)
else() # most likely Clang or GCC
target_compile_options(${PROJECT_NAME} PRIVATE
-Wall -Wextra -pedantic -Wnon-virtual-dtor
-Wsign-conversion -Wfloat-conversion) # TODO: add more warnings
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# these aren't GCC-supported warnings
target_compile_options(${PROJECT_NAME} PRIVATE
-Wassign-enum -Wfor-loop-analysis)
endif()
# TODO: replace with generator expressions?
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=undefined,address)
target_link_libraries(${PROJECT_NAME} asan ubsan)
endif()
endif()
if(RENDERER STREQUAL "sfml")
target_link_libraries(${PROJECT_NAME} sfml-graphics)
endif()
target_link_libraries(${PROJECT_NAME} lua)
# copy lua script files to the right place
add_custom_target(copy_data ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/data
$<TARGET_FILE_DIR:${PROJECT_NAME}>/data
)