-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
160 lines (116 loc) · 5.19 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
cmake_minimum_required(VERSION 3.5.1)
project(tile_editor)
option(BUILD_TESTS "Build test code" ON)
option(BUILD_DEBUG "Build a debug release" ON)
option(BUILD_APPIMAGE "Build for appimage" OFF)
option(BUILD_REGULAR "Regular build" OFF)
option(WITH_C++FILESYSTEM "If true, std::filesystem::lexically_normal() will be used in the file browser. Else, an approximation with realpath will be tried" TRUE)
#bin type
if(${BUILD_APPIMAGE})
if(${BUILD_REGULAR})
message(FATAL_ERROR "Only one build type (AppImage or regular) can be defined")
endif()
set(BUILD_VERSION "AppImage")
elseif(${BUILD_REGULAR})
set(BUILD_VERSION "bin")
else()
message(FATAL_ERROR "A build type (AppImage or regular) must be defined")
endif()
#release status
if(${BUILD_DEBUG})
set(CMAKE_BUILD_TYPE Debug)
set(BUILD_VERSION "${BUILD_VERSION}.debug")
else()
set(CMAKE_BUILD_TYPE Release)
endif()
#application version
set(MAJOR_VERSION 1)
set(MINOR_VERSION 1)
set(PATCH_VERSION 6)
set(BUILD_VERSION "\"${BUILD_VERSION}\"") #add some quotes to pacify the macro preprocessor
if(${CMAKE_VERSION} VERSION_LESS "3.22.0")
add_definitions(-DMAJOR_VERSION=${MAJOR_VERSION})
add_definitions(-DMINOR_VERSION=${MINOR_VERSION})
add_definitions(-DPATCH_VERSION=${PATCH_VERSION})
add_definitions(-DBUILD_VERSION=${BUILD_VERSION})
else()
add_compile_definitions(MAJOR_VERSION=${MAJOR_VERSION})
add_compile_definitions(MINOR_VERSION=${MINOR_VERSION})
add_compile_definitions(PATCH_VERSION=${PATCH_VERSION})
add_compile_definitions(BUILD_VERSION=${BUILD_VERSION})
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
message("will build ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-${BUILD_VERSION}")
#-Werror
add_compile_options(-Wall -Wextra -Wundef -Wcast-align -Wwrite-strings -Wlogical-op -Wmissing-declarations -Wredundant-decls -Wshadow -Woverloaded-virtual -Wno-deprecated -ansi -pedantic -fno-rtti)
include_directories("${CMAKE_CURRENT_LIST_DIR}/include/tile_editor")
include_directories("${CMAKE_CURRENT_LIST_DIR}/include/dfw_impl")
include_directories("${CMAKE_CURRENT_LIST_DIR}/include/input")
include_directories("${CMAKE_CURRENT_LIST_DIR}/include/controller")
include_directories("${CMAKE_CURRENT_LIST_DIR}/include")
add_subdirectory("${PROJECT_SOURCE_DIR}/src")
#bin type
if(${BUILD_APPIMAGE})
if(${CMAKE_VERSION} VERSION_LESS "3.22.0")
add_definitions(-DAS_APPIMAGE=1)
else()
add_compile_definitions(AS_APPIMAGE=1)
endif()
elseif(${BUILD_REGULAR})
if(${CMAKE_VERSION} VERSION_LESS "3.22.0")
add_definitions(-DAS_REGULAR=1)
else()
add_compile_definitions(AS_REGULAR=1)
endif()
endif()
#add the framework dependencies according to release status
add_library(lm SHARED IMPORTED)
add_library(tools SHARED IMPORTED)
add_library(ldtools SHARED IMPORTED)
add_library(dansdl2 SHARED IMPORTED)
add_library(dfw SHARED IMPORTED)
set_target_properties(lm PROPERTIES IMPORTED_LOCATION /usr/local/lib/liblm.so)
set_target_properties(tools PROPERTIES IMPORTED_LOCATION /usr/local/lib/libtools.so)
if(${BUILD_DEBUG})
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
add_definitions(-DLIBDANSDL2_DEBUG)
else()
add_compile_definitions(LIBDANSDL2_DEBUG)
endif()
set_target_properties(dansdl2 PROPERTIES IMPORTED_LOCATION /usr/local/lib/libdansdl2_debug.so)
set_target_properties(ldtools PROPERTIES IMPORTED_LOCATION /usr/local/lib/libldtools_debug.so)
set_target_properties(dfw PROPERTIES IMPORTED_LOCATION /usr/local/lib/libdfw_debug.so)
else()
set_target_properties(dansdl2 PROPERTIES IMPORTED_LOCATION /usr/local/lib/libdansdl2.so)
set_target_properties(ldtools PROPERTIES IMPORTED_LOCATION /usr/local/lib/libldtools.so)
set_target_properties(dfw PROPERTIES IMPORTED_LOCATION /usr/local/lib/libdfw.so)
endif()
#extra flag...
if(${WITH_C++FILESYSTEM})
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
add_definitions(-DWITH_FILESYSTEM)
else()
add_compile_definitions(WITH_FILESYSTEM)
endif()
endif()
#Virtual library so we don't have to build again and again for all tests...
add_library(applib STATIC ${SOURCE})
set_target_properties(applib PROPERTIES OUTPUT_NAME applib)
if(${BUILD_TESTS})
add_executable(config src/tests/config/main.cpp)
target_link_libraries(config applib tools ldtools dansdl2 dfw lm SDL2 SDL2_ttf SDL2_mixer SDL2_image GL stdc++fs)
add_custom_command(TARGET config POST_BUILD COMMAND cp -r ../src/tests/config/data ./)
add_executable(map src/tests/map/main.cpp)
target_link_libraries(map applib tools ldtools dansdl2 dfw lm SDL2 SDL2_ttf SDL2_mixer SDL2_image GL stdc++fs)
add_custom_command(TARGET map POST_BUILD COMMAND cp -r ../src/tests/map/data ./)
add_executable(message_manager src/tests/tools/message_manager.cpp)
target_link_libraries(message_manager applib tools ldtools dansdl2 dfw lm SDL2 SDL2_ttf SDL2_mixer SDL2_image GL stdc++fs)
endif()
#Configure the executable, we want it into the "build directory" and we want all resources copied
#to the build directory.
add_executable(tile_editor src/main.cpp)
set_target_properties(tile_editor PROPERTIES RUNTIME_OUTPUT_DIRECTORY build)
add_custom_command(TARGET tile_editor POST_BUILD COMMAND cp -r ../resources/* ./build)
target_link_libraries(tile_editor applib dfw tools dansdl2 ldtools lm SDL2 SDL2_ttf SDL2_mixer SDL2_image GL stdc++fs)