forked from enigma-dev/RadialGM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
286 lines (251 loc) · 9.49 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
cmake_minimum_required(VERSION 3.11)
set(EXE "RadialGM")
set(EXE_VERSION "0.1")
set(EXE_DESCRIPTION "ENIGMA IDE")
project(RadialGM)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
# Create code from a list of Qt designer ui files
set(CMAKE_AUTOUIC ON)
# Create code from Qt rc files
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/Dialogs")
# Include ENIGMA things
set(ENIGMA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Submodules/enigma-dev)
include_directories("${ENIGMA_DIR}/shared/protos/codegen" "${ENIGMA_DIR}/CommandLine/libEGM")
# Populate a CMake variable with the sources
set(RGM_SOURCES
main.cpp
MainWindow.cpp
Dialogs/PreferencesDialog.cpp
Editors/BaseEditor.cpp
Editors/CodeEditor.cpp
Editors/BackgroundEditor.cpp
Editors/ObjectEditor.cpp
Editors/SoundEditor.cpp
Editors/ScriptEditor.cpp
Editors/FontEditor.cpp
Editors/PathEditor.cpp
Editors/TimelineEditor.cpp
Editors/RoomEditor.cpp
Editors/SpriteEditor.cpp
Editors/SettingsEditor.cpp
Models/TreeModel.cpp
Models/SpriteModel.cpp
Models/ProtoModel.cpp
Models/ModelMapper.cpp
Models/ImmediateMapper.cpp
Models/ResourceModelMap.cpp
Models/RepeatedProtoModel.cpp
Models/TreeSortFilterProxyModel.cpp
Components/ArtManager.cpp
Components/Utility.cpp
Components/RecentFiles.cpp
Components/QMenuView.cpp
Widgets/BackgroundView.cpp
Widgets/CodeWidget.cpp
Widgets/ColorPicker.cpp
Widgets/RoomView.cpp
Widgets/AssetView.cpp
Plugins/RGMPlugin.cpp
Plugins/ServerPlugin.cpp
)
if (MSVC)
set(RGM_SOURCES ${RGM_SOURCES} qtplugins.cpp)
endif()
set(RGM_HEADERS
main.h
MainWindow.h
Dialogs/PreferencesDialog.h
Dialogs/PreferencesKeys.h
Editors/CodeEditor.h
Editors/BaseEditor.h
Editors/BackgroundEditor.h
Editors/ObjectEditor.h
Editors/SoundEditor.h
Editors/ScriptEditor.h
Editors/FontEditor.h
Editors/PathEditor.h
Editors/TimelineEditor.h
Editors/RoomEditor.h
Editors/SpriteEditor.h
Editors/SettingsEditor.h
Models/TreeModel.h
Models/ProtoModel.h
Models/ModelMapper.h
Models/ImmediateMapper.h
Models/SpriteModel.h
Models/ResourceModelMap.h
Models/RepeatedProtoModel.h
Models/TreeSortFilterProxyModel.h
Components/ArtManager.h
Components/RecentFiles.h
Components/Utility.h
Components/QMenuView.h
Components/Logger.h
Widgets/BackgroundView.h
Widgets/CodeWidget.h
Widgets/ColorPicker.h
Widgets/RoomView.h
Widgets/AssetView.h
Plugins/RGMPlugin.h
Plugins/ServerPlugin.h
)
set(RGM_UI
MainWindow.ui
Dialogs/PreferencesDialog.ui
Dialogs/AddImageDialog.ui
Editors/CodeEditor.ui
Editors/BackgroundEditor.ui
Editors/ObjectEditor.ui
Editors/FontEditor.ui
Editors/PathEditor.ui
Editors/TimelineEditor.ui
Editors/RoomEditor.ui
Editors/SpriteEditor.ui
Editors/SettingsEditor.ui
)
set(RGM_RC
images.qrc
resources.rc
)
# Check for QScintilla
find_library(LIB_QSCINTILLA NAMES qscintilla2)
if (NOT LIB_QSCINTILLA)
set(EDITOR_SOURCES Widgets/CodeWidgetPlain.cpp)
else()
set(EDITOR_SOURCES Widgets/CodeWidgetScintilla.cpp)
endif()
# Tell CMake to create the RadialGM executable
if(WIN32)
add_executable(${EXE} WIN32 ${RGM_UI} ${RGM_HEADERS} ${RGM_SOURCES} ${EDITOR_SOURCES} ${RGM_RC})
else()
add_executable(${EXE} ${RGM_UI} ${RGM_HEADERS} ${RGM_SOURCES} ${EDITOR_SOURCES} ${RGM_RC})
endif(WIN32)
# we do this even in release mode for "Editor Diagnostics"
target_compile_definitions(${EXE} PUBLIC QT_MESSAGELOGCONTEXT)
message(STATUS "Initial build flags:")
set(CompilerFlags
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
)
foreach(CompilerFlag ${CompilerFlags})
if(MSVC)
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endif(MSVC)
message(STATUS " '${CompilerFlag}': ${${CompilerFlag}}")
endforeach()
if (LIB_QSCINTILLA)
target_link_libraries(${EXE} PRIVATE ${LIB_QSCINTILLA})
endif()
# Find PugiXML
find_library(LIB_PUGIXML NAMES pugixml)
target_link_libraries(${EXE} PRIVATE ${LIB_PUGIXML})
# Find RapidJSON
find_package(RapidJSON REQUIRED)
include_directories(${EXE} PRIVATE ${RAPIDJSON_INCLUDE_DIRS})
# Find yaml-cpp
find_package(yaml-cpp CONFIG REQUIRED)
target_link_libraries(${EXE} PRIVATE yaml-cpp)
# Find libEGM
# Debug
find_library(LIB_EGM_D NAMES EGMd PATHS ${ENIGMA_DIR})
# Release
find_library(LIB_EGM NAMES EGM PATHS ${ENIGMA_DIR})
target_link_libraries(${EXE} PRIVATE "$<IF:$<CONFIG:Debug>,${LIB_EGM_D},${LIB_EGM}>")
# Find libProtocols
# Debug
find_library(LIB_PROTO_D NAMES Protocolsd PATHS ${ENIGMA_DIR})
# Release
find_library(LIB_PROTO NAMES Protocols PATHS ${ENIGMA_DIR})
target_link_libraries(${EXE} PRIVATE "$<IF:$<CONFIG:Debug>,${LIB_PROTO_D},${LIB_PROTO}>")
# Find GRPC
find_library(LIB_GRPC_UNSECURE NAMES grpc++_unsecure)
find_library(LIB_GRPC NAMES grpc)
find_library(LIB_GPR NAMES gpr)
find_library(LIB_CARES NAMES cares)
find_library(LIB_ADDRESS_SORTING NAMES address_sorting)
target_link_libraries(${EXE} PRIVATE ${LIB_CARES} ${LIB_ADDRESS_SORTING} ${LIB_GPR} ${LIB_GRPC} ${LIB_GRPC_UNSECURE})
# Find Protobuf
include(FindProtobuf)
include_directories(${Protobuf_INCLUDE_DIRS})
target_link_libraries(${EXE} PRIVATE ${Protobuf_LIBRARIES})
# Find OpenSSL
find_package(OpenSSL REQUIRED)
target_link_libraries(${EXE} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
# Find Qt
find_package(Qt5 COMPONENTS Core Widgets Gui PrintSupport REQUIRED)
target_link_libraries(${EXE} PRIVATE Qt5::Core Qt5::Widgets Qt5::Gui Qt5::PrintSupport)
if(MSVC)
target_link_libraries(${EXE} PRIVATE Qt5::WinMain)
# === Debug
find_library(LIB_QT_PLATFORM_D NAMES Qt5PlatformCompositorSupportd)
find_library(LIB_QT_FONT_D NAMES Qt5FontDatabaseSupportd)
find_library(LIB_QT_UI_D NAMES Qt5WindowsUIAutomationSupportd)
find_library(LIB_QT_EVENT_D NAMES Qt5EventDispatcherSupportd)
find_library(LIB_QT_THEME_D NAMES Qt5ThemeSupportd)
find_library(LIB_QT_PRINT_D NAMES Qt5PrintSupportd)
find_library(LIB_QT_ICO_D NAMES qicod PATHS "${QT_DIR}/plugins/imageformats")
find_library(LIB_QT_GIF_D NAMES qgifd PATHS "${QT_DIR}/plugins/imageformats")
find_library(LIB_QT_JPEG_D NAMES qjpegd PATHS "${QT_DIR}/plugins/imageformats")
# Windows 10 SDK doesn't include a debug version of Uxtheme
find_library(LIB_WIN_UXTHEME_D NAMES Uxtheme)
find_library(LIB_QT_WINVISTASTYLE_D NAMES qwindowsvistastyled PATHS "${QT_DIR}/plugins/styles")
find_library(LIB_QT_WIN_D NAMES qwindowsd PATHS "${QT_DIR}/plugins/platforms")
# === Release
find_library(LIB_QT_PLATFORM NAMES Qt5PlatformCompositorSupport)
find_library(LIB_QT_FONT NAMES Qt5FontDatabaseSupport)
find_library(LIB_QT_UI NAMES Qt5WindowsUIAutomationSupport)
find_library(LIB_QT_EVENT NAMES Qt5EventDispatcherSupport)
find_library(LIB_QT_THEME NAMES Qt5ThemeSupport)
find_library(LIB_QT_PRINT NAMES Qt5PrintSupport)
# ICO is needed to set Win32 icon on the Window
# also all of these image plugins are very small about 100kb~ each
find_library(LIB_QT_ICO NAMES qico PATHS "${QT_DIR}/plugins/imageformats")
find_library(LIB_QT_GIF NAMES qgif PATHS "${QT_DIR}/plugins/imageformats")
find_library(LIB_QT_JPEG NAMES qjpeg PATHS "${QT_DIR}/plugins/imageformats")
find_library(LIB_WIN_UXTHEME NAMES Uxtheme)
find_library(LIB_QT_WINVISTASTYLE NAMES qwindowsvistastyle PATHS "${QT_DIR}/plugins/styles")
find_library(LIB_QT_WIN NAMES qwindows PATHS "${QT_DIR}/plugins/platforms")
target_link_libraries(${EXE} PRIVATE "$<IF:$<CONFIG:Debug>,${LIB_QT_PLATFORM_D},${LIB_QT_PLATFORM}>"
"$<IF:$<CONFIG:Debug>,${LIB_QT_FONT_D},${LIB_QT_FONT}>"
"$<IF:$<CONFIG:Debug>,${LIB_QT_UI_D},${LIB_QT_UI}>"
"$<IF:$<CONFIG:Debug>,${LIB_QT_EVENT_D},${LIB_QT_EVENT}>"
"$<IF:$<CONFIG:Debug>,${LIB_QT_THEME_D},${LIB_QT_THEME}>"
"$<IF:$<CONFIG:Debug>,${LIB_QT_PRINT_D},${LIB_QT_PRINT}>"
"$<IF:$<CONFIG:Debug>,${LIB_QT_ICO_D},${LIB_QT_ICO}>"
"$<IF:$<CONFIG:Debug>,${LIB_QT_GIF_D},${LIB_QT_GIF}>"
"$<IF:$<CONFIG:Debug>,${LIB_QT_JPEG_D},${LIB_QT_JPEG}>"
"$<IF:$<CONFIG:Debug>,${LIB_WIN_UXTHEME_D},${LIB_WIN_UXTHEME}>"
"$<IF:$<CONFIG:Debug>,${LIB_QT_WINVISTASTYLE_D},${LIB_QT_WINVISTASTYLE}>"
"$<IF:$<CONFIG:Debug>,${LIB_QT_WIN_D},${LIB_QT_WIN}>"
)
endif(MSVC)
# Find FreeType
find_package(Freetype REQUIRED)
include_directories(${FREETYPE_INCLUDE_DIRS})
target_link_libraries(${EXE} PRIVATE ${FREETYPE_LIBRARIES})
# Find JPEG
find_library(LIB_JPEG NAMES jpeg)
target_link_libraries(${EXE} PRIVATE ${LIB_JPEG})
# Find HarfBuzz
find_library(LIB_HARFBUZZ NAMES harfbuzz)
target_link_libraries(${EXE} PRIVATE ${LIB_HARFBUZZ})
# Find Pcre2
find_library(LIB_PCRE2 NAMES "pcre2-16")
target_link_libraries(${EXE} PRIVATE ${LIB_PCRE2})
# Find double-conversion
find_library(LIB_DOUBLE_CONVERSION NAMES double-conversion)
target_link_libraries(${EXE} PRIVATE ${LIB_DOUBLE_CONVERSION})
if(WIN32)
# Windows is a turd
target_link_libraries(${EXE} PRIVATE Ws2_32 Wtsapi32 Wldap32 Crypt32 Winmm Userenv Netapi32 version Dwmapi Imm32)
endif(WIN32)