-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
113 lines (97 loc) · 3.18 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
cmake_minimum_required(VERSION 3.23.2)
project(rpg-ng VERSION 0.1.0 DESCRIPTION "A small and simple 2D RPG engine")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
# Set output directory
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
# Set options
option(RPGNG_TEST "Enable unit tests" OFF)
option(RPGNG_DOCS "Enable compiling documentation" OFF)
#option(RPGNG_STATIC "Build a static binary" ON)
# To enable debug builds, use -DCMAKE_BUILD_TYPE=Debug
#if(RPGNG_STATIC)
# set(Python_USE_STATIC_LIBS ON)
#endif()
# Find packages
find_package(Python REQUIRED COMPONENTS Development)
find_package(SDL2 CONFIG REQUIRED)
find_package(SDL2_image CONFIG REQUIRED)
if(WIN32)
find_package(jansson CONFIG REQUIRED)
else()
find_package(Jansson REQUIRED)
endif()
add_executable(rpgng)
target_sources(rpgng
PRIVATE
"src/config.c"
"src/entity.c"
"src/htable.c"
"src/log.c"
"src/main.c"
"src/script.c"
"src/window.c"
"src/component/component.c"
"src/component/dialogue.c"
"src/component/inventory.c"
"src/component/sprite.c"
"src/component/transform.c"
)
target_compile_definitions(rpgng PUBLIC
RPGNG_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
RPGNG_VERSION_MINOR=${PROJECT_VERSION_MINOR}
RPGNG_VERSION_PATCH=${PROJECT_VERSION_PATCH}
RPGNG_VERSION="${PROJECT_VERSION}"
)
# Set library version
#set_target_properties(rpgng PROPERTIES VERSION ${PROJECT_VERSION})
# Set link libraries
target_link_libraries(rpgng Python::Python)
target_link_libraries(rpgng SDL2::SDL2main)
target_link_libraries(rpgng jansson::jansson)
#if(RPGNG_STATIC)
# target_link_libraries(rpgng SDL2::SDL2-static)
# target_link_libraries(rpgng SDL2_image::SDL2_image-static)
#else()
target_link_libraries(rpgng SDL2::SDL2)
target_link_libraries(rpgng SDL2_image::SDL2_image)
#endif()
# Set compiler/language options
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_C_FLAGS_RELEASE "-O2")
if(WIN32)
set(CMAKE_C_FLAGS_DEBUG "-Od -Z7")
else()
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3 -pedantic-errors -fsanitize=address -fsanitize=undefined")
endif()
# If tests are enabled, make tests
#if(RPGNG_TEST)
# enable_testing()
#
# add_executable(map_tests test/map_tests.c test/Unity/src/unity.c)
#
# target_link_libraries(map_tests rpgng jansson::jansson)
#
# if(WIN32)
# target_link_libraries(map_tests rpgng cygwin1.dll)
# endif()
#
# set_target_properties(map_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY test/bin)
#
# add_test(NAME map_tests COMMAND test/bin/map_tests)
#
# # Add library output dir to PATH, because in Windows, the loader will have
# # no clue where to find anything
# if(WIN32)
# set_tests_properties(map_tests PROPERTIES ENVIRONMENT_MODIFICATION
# PATH=path_list_append:${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE})
# endif()
#endif()
# If documentation is enabled, compile docs
if(RPGNG_DOCS)
find_package(Doxygen REQUIRED doxygen dot)
add_custom_command(TARGET rpgng POST_BUILD COMMAND Doxygen::doxygen)
endif()