-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathCMakeLists.txt
396 lines (344 loc) · 12.6 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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
cmake_minimum_required(VERSION 3.14)
project(RadialGM)
# Uncomment to give priority to the local CMake modules
# set(CMAKE_PREFIX_PATH "/usr/local/lib")
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)
# Check https://stackoverflow.com/q/33062728/14629018 for more information.
# if(MSVC)
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
# endif()
if (RGM_BUILD_STATIC)
set(LIB_TYPE STATIC CACHE STRING "Static Library type")
else()
set(LIB_TYPE SHARED CACHE STRING "Shared Library type")
endif()
# Set default build type
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Build type not set - defaulting to Debug")
set(
CMAKE_BUILD_TYPE "Debug"
CACHE
STRING
"Choose the type of build from: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(EXE "RadialGM-Debug" CACHE STRING "RGM Executable name")
add_definitions(-DRGM_DEBUG)
set(CMAKE_DEBUG_POSTFIX d)
else()
set(EXE "RadialGM" CACHE STRING "RGM Executable name")
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}/" "${CMAKE_CURRENT_SOURCE_DIR}/Dialogs" "${CMAKE_CURRENT_SOURCE_DIR}/Editors")
# Uncomment to be able to use local grpc_cpp_plugin
# set(GRPC_EXE "/usr/local/bin/grpc_cpp_plugin")
# Include ENIGMA things
set(ENIGMA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Submodules/enigma-dev CACHE PATH "ENIGMA directory")
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
Editors/VisualShaderEditor.cpp
main.cpp
Plugins/RGMPlugin.cpp
Dialogs/EventArgumentsDialog.cpp
Dialogs/TimelineChangeMoment.cpp
Dialogs/PreferencesDialog.cpp
Dialogs/KeyBindingPreferences.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
Editors/VisualShaderEditor.h
Plugins/RGMPlugin.h
MainWindow.h
Dialogs/EventArgumentsDialog.h
Dialogs/PreferencesDialog.h
Dialogs/PreferencesKeys.h
Dialogs/TimelineChangeMoment.h
Dialogs/KeyBindingPreferences.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
find_package(Protobuf CONFIG REQUIRED)
target_link_libraries(${EXE} PRIVATE protobuf::libprotobuf)
# 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
# Arrangement of these is important: shared depends on proto and emake depends on all of them
# We need to cache the library names first so we can build on top of them
add_subdirectory(Submodules/enigma-dev/shared/protos)
add_subdirectory(Submodules/enigma-dev/shared)
add_subdirectory(Submodules/enigma-dev/CommandLine/libEGM)
add_dependencies(${EXE} ${LIB_EGM})
target_link_libraries(${EXE} PRIVATE ${LIB_EGM} ${LIB_PROTO} ${SHARED_LIB})
# 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})
# nodeeditor
# FIXME: In order for BUILD_DEBUG_POSTFIX_D and USE_QT6 to be set correctly, you will need to configure the project twice: https://cmake.org/cmake/help/latest/policy/CMP0077.html
if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(BUILD_DEBUG_POSTFIX_D ON)
endif()
set(USE_QT6 OFF) # We use Qt5
add_subdirectory(Submodules/nodeeditor)
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)
add_dependencies(${EXE} ${CLI_TARGET})
endif()
add_custom_command(
TARGET ${EXE}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/Submodules/enigma-dev/CommandLine/emake/${CLI_TARGET}${CMAKE_EXECUTABLE_SUFFIX}
${CMAKE_BINARY_DIR}/Submodules/enigma-dev/CommandLine/libEGM/${CMAKE_SHARED_LIBRARY_PREFIX}${LIB_EGM}${CMAKE_DEBUG_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/Submodules/enigma-dev/CompilerSource/${CMAKE_SHARED_LIBRARY_PREFIX}${COMPILER_LIB}${CMAKE_DEBUG_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/Submodules/enigma-dev/shared/protos/${CMAKE_SHARED_LIBRARY_PREFIX}${LIB_PROTO}${CMAKE_DEBUG_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/Submodules/enigma-dev/shared/${CMAKE_SHARED_LIBRARY_PREFIX}${SHARED_LIB}${CMAKE_DEBUG_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_CURRENT_SOURCE_DIR}/Submodules/enigma-dev
COMMENT "Copying exes to ENIGMA's root directory"
)
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}${LIB_EGM}${CMAKE_SHARED_LIBRARY_SUFFIX}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_SHARED_LIBRARY_PREFIX}${LIB_PROTO}${CMAKE_SHARED_LIBRARY_SUFFIX}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_SHARED_LIBRARY_PREFIX}${SHARED_LIB}${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()