forked from enigma-dev/RadialGM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
354 lines (308 loc) · 10.4 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
cmake_minimum_required(VERSION 3.14)
project(RadialGM)
include(CMakeDependentOption)
option(RGM_BUILD_EMAKE "Build Emake and the compiler." ON)
# FIXME: MSVC dynamic linking requires US TO DLLEXPORT our funcs
# since we currently don't, I'm force disabling the option on MSVC
cmake_dependent_option(RGM_BUILD_STATIC "Build static libs." ON "MSVC" OFF)
if (RGM_BUILD_STATIC)
set(LIB_TYPE STATIC)
else()
set(LIB_TYPE SHARED)
endif()
if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(EXE "RadialGM-Debug")
add_definitions(-DRGM_DEBUG)
else()
set(EXE "RadialGM")
endif()
set(EXE_DESCRIPTION "ENIGMA IDE")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
SET(CMAKE_SKIP_BUILD_RPATH ON)
set(CMAKE_INSTALL_RPATH $ORIGIN)
# 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_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED 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("${CMAKE_BINARY_DIR}/Submodules/enigma-dev/shared/protos/" "${ENIGMA_DIR}/CommandLine/libEGM" "${ENIGMA_DIR}/shared")
# Populate a CMake variable with the sources
set(RGM_SOURCES
Models/RepeatedMessageModel.cpp
Models/TreeSortFilterProxyModel.cpp
Models/PrimitiveModel.cpp
Models/EventsListModel.cpp
Models/ModelMapper.cpp
Models/RepeatedModel.cpp
Models/MessageModel.cpp
Models/TreeModel.cpp
Models/EventTypesListModel.cpp
Models/ResourceModelMap.cpp
Models/ImmediateMapper.cpp
Models/ProtoModel.cpp
Models/EventTypesListSortFilterProxyModel.cpp
Models/RepeatedSortFilterProxyModel.cpp
Components/Utility.cpp
Components/RecentFiles.cpp
Components/QMenuView.cpp
Components/ArtManager.cpp
Editors/PathEditor.cpp
Editors/RoomEditor.cpp
Editors/ObjectEditor.cpp
Editors/FontEditor.cpp
Editors/SpriteEditor.cpp
Editors/BackgroundEditor.cpp
Editors/SettingsEditor.cpp
Editors/ShaderEditor.cpp
Editors/SoundEditor.cpp
Editors/IncludeEditor.cpp
Editors/InformationEditor.cpp
Editors/BaseEditor.cpp
Editors/ScriptEditor.cpp
Editors/CodeEditor.cpp
Editors/TimelineEditor.cpp
main.cpp
Plugins/RGMPlugin.cpp
Plugins/ServerPlugin.cpp
Dialogs/EventArgumentsDialog.cpp
Dialogs/TimelineChangeMoment.cpp
Dialogs/PreferencesDialog.cpp
Utils/ProtoManip.cpp
Utils/FieldPath.cpp
MainWindow.cpp
Widgets/BackgroundView.cpp
Widgets/ColorPicker.cpp
Widgets/AssetView.cpp
Widgets/PathView.cpp
Widgets/RoomView.cpp
Widgets/SpriteView.cpp
Widgets/CodeWidget.cpp
Widgets/SpriteSubimageListView.cpp
Widgets/StackedCodeWidget.cpp
Widgets/AssetScrollAreaBackground.cpp
)
set(RGM_HEADERS
Models/MessageModel.h
Models/ProtoModel.h
Models/TreeModel.h
Models/PrimitiveModel.h
Models/RepeatedMessageModel.h
Models/EventTypesListSortFilterProxyModel.h
Models/ResourceModelMap.h
Models/EventTypesListModel.h
Models/ImmediateMapper.h
Models/RepeatedModel.h
Models/EventsListModel.h
Models/ModelMapper.h
Models/RepeatedSortFilterProxyModel.h
Models/TreeSortFilterProxyModel.h
main.h
Components/RecentFiles.h
Components/QMenuView_p.h
Components/Utility.h
Components/QMenuView.h
Components/Logger.h
Components/ArtManager.h
Editors/ObjectEditor.h
Editors/PathEditor.h
Editors/ScriptEditor.h
Editors/CodeEditor.h
Editors/SoundEditor.h
Editors/IncludeEditor.h
Editors/InformationEditor.h
Editors/TimelineEditor.h
Editors/SettingsEditor.h
Editors/ShaderEditor.h
Editors/RoomEditor.h
Editors/BaseEditor.h
Editors/FontEditor.h
Editors/SpriteEditor.h
Editors/BackgroundEditor.h
Plugins/ServerPlugin.h
Plugins/RGMPlugin.h
MainWindow.h
Dialogs/EventArgumentsDialog.h
Dialogs/PreferencesDialog.h
Dialogs/PreferencesKeys.h
Dialogs/TimelineChangeMoment.h
Utils/SafeCasts.h
Utils/ProtoManip.h
Utils/FieldPath.h
Utils/QBoilerplate.h
Widgets/BackgroundView.h
Widgets/CodeWidget.h
Widgets/ResourceSelector.h
Widgets/ColorPicker.h
Widgets/AssetScrollArea.h
Widgets/SpriteView.h
Widgets/AssetView.h
Widgets/PathView.h
Widgets/StackedCodeWidget.h
Widgets/SpriteSubimageListView.h
Widgets/AssetScrollAreaBackground.h
Widgets/RoomView.h
)
set(RGM_UI
MainWindow.ui
Dialogs/TimelineChangeMoment.ui
Dialogs/PreferencesDialog.ui
Dialogs/AddImageDialog.ui
Editors/CodeEditor.ui
Editors/SoundEditor.ui
Editors/BackgroundEditor.ui
Editors/SpriteEditor.ui
Editors/PathEditor.ui
Editors/SettingsEditor.ui
Editors/RoomEditor.ui
Editors/FontEditor.ui
Editors/TimelineEditor.ui
Editors/ObjectEditor.ui
Editors/InformationEditor.ui
Editors/IncludeEditor.ui
)
set(RGM_RC
images.qrc
resources.rc
)
# Check for QScintilla
find_library(LIB_QSCINTILLA NAMES qscintilla2 qscintilla2_qt5 qscintilla2-qt5 qt5scintilla2 libqscintilla2_qt5.so libqscintilla2.so libqscintilla2.a qscintilla2.lib)
if (NOT LIB_QSCINTILLA)
set(EDITOR_SOURCES Widgets/CodeWidgetPlain.cpp)
else()
set(EDITOR_SOURCES Widgets/CodeWidgetScintilla.cpp)
endif()
set(RGM_SOURCES ${RGM_SOURCES} Plugins/ServerPlugin.cpp)
set(RGM_HEADERS ${RGM_HEADERS} Plugins/ServerPlugin.h)
# Tell CMake to create the RadialGM executable
add_executable(${EXE} WIN32 ${RGM_UI} ${RGM_HEADERS} ${RGM_SOURCES} ${EDITOR_SOURCES} ${RGM_RC})
# we do this even in release mode for "Editor Diagnostics"
target_compile_definitions(${EXE} PUBLIC QT_MESSAGELOGCONTEXT)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT WIN32)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
endif()
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})
message(STATUS " '${CompilerFlag}': ${${CompilerFlag}}")
endforeach()
if (LIB_QSCINTILLA)
message(STATUS "Found QScintilla: ${LIB_QSCINTILLA}")
add_definitions(-DQSCINTILLA_DLL)
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 gRPC
find_package(gRPC CONFIG REQUIRED)
target_link_libraries(${EXE} PRIVATE gRPC::gpr gRPC::grpc gRPC::grpc++)
# 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 Multimedia REQUIRED)
target_link_libraries(${EXE} PRIVATE Qt5::Core Qt5::Widgets Qt5::Gui Qt5::PrintSupport Qt5::Multimedia)
# LibProto
add_subdirectory(Submodules/enigma-dev/shared)
add_subdirectory(Submodules/enigma-dev/shared/protos)
add_subdirectory(Submodules/enigma-dev/CommandLine/libEGM)
add_dependencies(${EXE} "EGM")
target_link_libraries(${EXE} PRIVATE "EGM" "Protocols" "ENIGMAShared")
# 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)
if(MSVC)
# Default MSVC warnings are overkill. Set to Lvl 2
target_compile_options(${EXE} PRIVATE /W1)
endif()
if (RGM_BUILD_EMAKE)
add_subdirectory(Submodules/enigma-dev/CompilerSource)
add_subdirectory(Submodules/enigma-dev/CommandLine/emake)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(CLI_TARGET "emake-debug")
else()
set(CLI_TARGET "emake")
endif()
add_dependencies(${EXE} ${CLI_TARGET})
endif()
install(TARGETS ${EXE} RUNTIME DESTINATION .)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${EXE}.dir/Debug/${EXE}.pdb" DESTINATION . OPTIONAL)
set(RGM_APP "${CMAKE_INSTALL_PREFIX}/${EXE}${CMAKE_EXECUTABLE_SUFFIX}")
set(EMAKE_APP "${CMAKE_INSTALL_PREFIX}/${CLI_TARGET}${CMAKE_EXECUTABLE_SUFFIX}")
if (MSVC)
file(TO_CMAKE_PATH ${VCPKG_ROOT} VCPKG_ROOT)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(SEARCH_PATHS "${VCPKG_ROOT}/installed/x64-windows/debug/bin/")
else()
set(SEARCH_PATHS "${VCPKG_ROOT}/installed/x64-windows/bin/")
endif()
else()
set(LIBS "${CMAKE_INSTALL_PREFIX}/${CMAKE_SHARED_LIBRARY_PREFIX}EGM${CMAKE_SHARED_LIBRARY_SUFFIX}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_SHARED_LIBRARY_PREFIX}Protocols${CMAKE_SHARED_LIBRARY_SUFFIX}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_SHARED_LIBRARY_PREFIX}ENIGMAShared${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()
if (WIN32)
set(WINDEPLOY_ARGS "--no-translations --no-angle")
if (MSVC)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY TRUE)
set(WINDEPLOY_ARGS "${WINDEPLOY_ARGS} --pdb --no-compiler-runtime")
else()
set(WINDEPLOY_ARGS "${WINDEPLOY_ARGS} --no-compiler-runtime")
endif()
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
include(InstallRequiredSystemLibraries)
install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION .)
endif()
install(CODE "
include(BundleUtilities)
fixup_bundle(\"${RGM_APP}\" \"${LIBS}\" \"${SEARCH_PATHS}\")
fixup_bundle(\"${EMAKE_APP}\" \"${LIBS}\" \"${SEARCH_PATHS}\")
execute_process(COMMAND windeployqt.exe ${WINDEPLOY_ARGS} ${RGM_APP})
")
endif()