-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
346 lines (285 loc) · 13.5 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
cmake_minimum_required(VERSION 3.20)
set(PROJECT LogToGraph)
enable_language(C CXX)
project(${PROJECT} CXX)
option(USE_BUILDING_AS_SHARED "Enable shared building" ON)
option(USE_BUILDING_OF_TESTS "Enable the build of tests" OFF)
## for group smake targets in the dir CmakeTargets
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CmakeTargets")
## show the dependency graph of cmake
## set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
## some defines for debug mode (before 3rdparty.cmake)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(FINAL_BIN_DIR ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_PDB_OUTPUT_DIRECTORY_DEBUG "${FINAL_BIN_DIR}/debug")
set(CMAKE_PDB_OUTPUT_DIRECTORY_RELEASE "${FINAL_BIN_DIR}/release")
set(CMAKE_PDB_OUTPUT_DIRECTORY_MINSIZEREL "${FINAL_BIN_DIR}/minsizerel")
set(CMAKE_PDB_OUTPUT_DIRECTORY_RELWITHDEBINFO "${FINAL_BIN_DIR}/reldeb")
set(CMAKE_INSTALL_PREFIX .)
set(CMAKE_INSTALL_BINDIR .)
set(USE_SHARED_LIBS ${USE_BUILDING_AS_SHARED} CACHE BOOL "" FORCE)
if ("${CMAKE_EXE_LINKER_FLAGS}" STREQUAL "/machine:x64")
set(ARCH x64)
else()
set(ARCH x32)
endif()
# some times for unknown reason, the lib file is not generated so no symbols are exported.
# this option force all shared lib to export theirs symbols
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ${USE_SHARED_LIBS} CACHE BOOL "" FORCE)
if ("${CMAKE_EXE_LINKER_FLAGS}" STREQUAL "/machine:x64")
set(ARCH x64)
else()
set(ARCH x32)
endif()
if(NOT CMAKE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX _debug)
endif()
if(NOT CMAKE_RELEASE_POSTFIX)
set(CMAKE_RELEASE_POSTFIX) ## to config in file
endif()
if(NOT CMAKE_MINSIZEREL_POSTFIX)
set(CMAKE_MINSIZEREL_POSTFIX _minsizerel)
endif()
if(NOT CMAKE_RELWITHDEBINFO_POSTFIX)
set(CMAKE_RELWITHDEBINFO_POSTFIX _reldeb)
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zo")
add_definitions(-D_USE_MATH_DEFINES)
add_definitions(-DMSVC)
add_definitions(-DNOMINMAX)
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wunused-parameter -Wno-unknown-pragmas")
endif ()
if(WIN32)
add_definitions(-DWIN32)
endif()
add_definitions(-DUSE_STD_FILESYSTEM)
add_definitions(-DIMGUI_ENABLE_FREETYPE)
add_definitions(-DIMGUI_DEFINE_MATH_OPERATORS)
add_definitions(-DUSE_DECORATIONS_FOR_RESIZE_CHILD_WINDOWS)
add_definitions(-DILAYOUT_PANE_INCLUDE="${CMAKE_SOURCE_DIR}/apis/ILayoutPane.h")
add_definitions(-DIMGUI_INCLUDE="${CMAKE_SOURCE_DIR}/3rdparty/ImGuiPack/ImGuiPack.h")
add_definitions(-DIMGUI_USER_CONFIG="${CMAKE_SOURCE_DIR}/src/headers/CustomImGuiConfig.h")
add_definitions(-DCUSTOM_IMWIDGETS_CONFIG="${CMAKE_SOURCE_DIR}/src/headers/CustomImWidgetsConfig.h")
add_definitions(-DCUSTOM_IN_APP_GPU_PROFILER_CONFIG="${CMAKE_SOURCE_DIR}/src/headers/CustomInAppGpuProfiler.h")
add_definitions(-DCUSTOM_IMGUIFILEDIALOG_CONFIG="${CMAKE_SOURCE_DIR}/src/headers/CustomImGuiFileDialogConfig.h")
add_definitions(-DCUSTOM_LOG_TO_GRAPH_BACKEND_CONFIG="${CMAKE_SOURCE_DIR}/src/headers/CustomStrockerBackendConfig.h")
add_definitions(-DCUSTOM_THEME_HELPER_CONFIG_HEADER="${CMAKE_SOURCE_DIR}/src/headers/CustomImGuiThemeHelperConfigHeader.h")
include(cmake/3rdparty.cmake)
###########################################################
##### PLUGINS PREFIX ######################################
###########################################################
### each plugins must start by this
set(PLUGIN_NAME_PREFIX "Plugin")
add_definitions(-DPLUGIN_NAME_PREFIX="${PLUGIN_NAME_PREFIX}")
###########################################################
##### SEARCH FOR PLUGINS ##################################
###########################################################
set(LOADED_LOG_TO_GRAPH_PLUGINS) ### must be filletered by each plugins in CMakeLists.txt with plugin name
set(PLUGINS_DIRECTORY ${CMAKE_SOURCE_DIR}/plugins)
file(GLOB SUBDIRS RELATIVE ${PLUGINS_DIRECTORY} ${PLUGINS_DIRECTORY}/*)
FOREACH(SUBDIR ${SUBDIRS})
if(IS_DIRECTORY ${PLUGINS_DIRECTORY}/${SUBDIR})
if (EXISTS ${PLUGINS_DIRECTORY}/${SUBDIR}/CMakeLists.txt)
add_subdirectory(${PLUGINS_DIRECTORY}/${SUBDIR})
endif()
endif()
ENDFOREACH()
###########################################################
###########################################################
###########################################################
add_definitions(${GLFW_DEFINITIONS})
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# Plugin Apis for have it the visual studio tree of the App
file(GLOB_RECURSE APIS_SOURCES ${CMAKE_SOURCE_DIR}/apis/*.*)
source_group(TREE ${CMAKE_SOURCE_DIR}/apis PREFIX PluginApis FILES ${APIS_SOURCES})
# Main sources
file(GLOB MAIN_SOURCES ${CMAKE_SOURCE_DIR}/main.cpp)
source_group(main FILES ${MAIN_SOURCES})
# App Sources
file(GLOB_RECURSE SRC_SOURCES ${CMAKE_SOURCE_DIR}/src/*.*)
source_group(TREE ${CMAKE_SOURCE_DIR}/src PREFIX src FILES ${SRC_SOURCES})
# cmake Sources for have it the visual studio tree of the App
file(GLOB_RECURSE PROJECT_CMAKE_FILES
${CMAKE_SOURCE_DIR}/cmake/*.cmake)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/cmake PREFIX cmake FILES ${PROJECT_CMAKE_FILES})
file(GLOB IMGUI_IMPL_SOURCES
${CMAKE_SOURCE_DIR}/3rdparty/ImGuiPack/3rdparty/imgui_docking/backends/imgui_impl_glfw.cpp
${CMAKE_SOURCE_DIR}/3rdparty/ImGuiPack/3rdparty/imgui_docking/backends/imgui_impl_glfw.h
${CMAKE_SOURCE_DIR}/3rdparty/ImGuiPack/3rdparty/imgui_docking/backends/imgui_impl_opengl3.cpp
${CMAKE_SOURCE_DIR}/3rdparty/ImGuiPack/3rdparty/imgui_docking/backends/imgui_impl_opengl3.h
${CMAKE_SOURCE_DIR}/3rdparty/ImGuiPack/3rdparty/imgui_docking/misc/freetype/imgui_freetype.cpp
${CMAKE_SOURCE_DIR}/3rdparty/ImGuiPack/3rdparty/imgui_docking/misc/freetype/imgui_freetype.h)
source_group(src\\ImGuiImpl FILES ${IMGUI_IMPL_SOURCES})
if (MSVC)
set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_SOURCE_DIR}/res/appicon.rc")
endif()
add_executable(${PROJECT}
${SRC_SOURCES}
${MAIN_SOURCES}
${APIS_SOURCES}
${EZ_LIBS_SOURCES}
${IMGUI_IMPL_SOURCES}
${PROJECT_CMAKE_FILES}
${APP_ICON_RESOURCE_WINDOWS}
)
if (USE_SHARED_LIBS)
target_compile_definitions(${PROJECT} PRIVATE BUILD_IMGUI_PACK_SHARED_LIBS)
target_compile_definitions(${PROJECT} PRIVATE BUILD_IN_APP_GPU_PROFILER_SHARED_LIBS)
target_compile_definitions(${PROJECT} PRIVATE BUILD_LOG_TO_GRAPH_BRIDGE_SHARED_LIBS)
endif()
set_target_properties(${PROJECT} PROPERTIES OUTPUT_NAME "${PROJECT}_${CMAKE_SYSTEM_NAME}_${ARCH}")
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}")
install(TARGETS ${PROJECT} DESTINATION ${CMAKE_INSTALL_PREFIX})
include_directories(
${LOG_TO_GRAPH_BRIDGE_INCLUDE_DIRS}
${IN_APP_GPU_PROFILER_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/3rdparty
${IMGUIPACK_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/src
${SQLITE3_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}
${PLOG_INCLUDE_DIR}
${GLFW_INCLUDE_DIR}
${GLAD_INCLUDE_DIR}
)
target_link_libraries(${PROJECT}
${IN_APP_GPU_PROFILER_LIBRARIES}
${IMGUIPACK_LIBRARIES}
${SQLITE3_LIBRARIES}
${OPENGL_LIBRARIES}
${GLFW_LIBRARIES}
${GLAD_LIBRARIES}
)
# define for let Strocker detext what is the config of a plugin
target_compile_definitions(${PROJECT} PRIVATE -DPLUGIN_RUNTIME_CONFIG=$<$<CONFIG:Debug>:"_Debug">$<$<CONFIG:Release>:"_Release">$<$<CONFIG:MinSizeRel>:"_MinSizeRel">$<$<CONFIG:RelWithDebInfo>:"_RelWithDebInfo">)
target_compile_definitions(${PROJECT} PRIVATE -DPROJECT_EXT=".ltg")
target_compile_definitions(${PROJECT} PRIVATE -DPROJECT_EXT_DOT_LESS="ltg")
if (WIN32)
target_compile_definitions(${PROJECT} PRIVATE -DGLFW_EXPOSE_NATIVE_WIN32)
endif()
set_target_properties(${PROJECT} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG "${FINAL_BIN_DIR}")
set_target_properties(${PROJECT} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE "${FINAL_BIN_DIR}")
set_target_properties(${PROJECT} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${FINAL_BIN_DIR}")
set_target_properties(${PROJECT} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${FINAL_BIN_DIR}")
########################################################
############## FORCE BUILD OF PLUGINS ##################
########################################################
FOREACH(PLUGIN ${LOADED_LOG_TO_GRAPH_PLUGINS})
add_dependencies(${PROJECT} ${PLUGIN})
ENDFOREACH()
########################################################
################# BUILD INCREMENT TOOL #################
########################################################
## only for Debug
add_subdirectory(3rdparty/BuildInc)
## set_target_properties(BuildInc PROPERTIES FOLDER Tools)
add_custom_command(
TARGET ${PROJECT} PRE_BUILD
COMMAND BuildInc -prefix=${PROJECT} $<$<CONFIG:Debug>:${CMAKE_SOURCE_DIR}/src/headers/${PROJECT}Build.h>
DEPENDS ${PROJECT})
########################################################
##### TESTS ############################################
########################################################
if(USE_BUILDING_OF_TESTS)
enable_testing()
endif()
#############################################################
### BUILD CONFIG NAME #######################################
#############################################################
### will store the build config name in a file
### only during the building
add_custom_command(
TARGET ${PROJECT} PRE_BUILD
COMMAND echo "$<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release>$<$<CONFIG:MinSizeRel>:MinSizeRel>$<$<CONFIG:RelWithDebInfo>:RelWithDebInfo>" > ${CMAKE_BINARY_DIR}/current_build_type
DEPENDS ${PROJECT}
)
### outside of the building we read the last file content
### for get the current building config name
if (EXISTS ${CMAKE_BINARY_DIR}/current_build_type)
file(READ ${CMAKE_BINARY_DIR}/current_build_type CURRENT_BUILD_TYPE)
string(STRIP ${CURRENT_BUILD_TYPE} CURRENT_BUILD_TYPE) ### removing end line wrote by echo command
set(PROJECT_BUILD_CONFIG_NAME ${CURRENT_BUILD_TYPE} CACHE STRING "" FORCE)
message(STATUS "CURRENT BUILD CONFIG is : ${PROJECT_BUILD_CONFIG_NAME}")
endif()
#############################################################
### VERSION #################################################
#############################################################
file(READ ${CMAKE_SOURCE_DIR}/src/headers/${PROJECT}Build.h BuildIdFile)
string(REGEX MATCH "#define ${PROJECT}_BuildNumber ([0-9]*)" _ ${BuildIdFile})
set(BuildNumber ${CMAKE_MATCH_1})
string(REGEX MATCH "#define ${PROJECT}_MinorNumber ([0-9]*)" _ ${BuildIdFile})
set(MinorNumber ${CMAKE_MATCH_1})
string(REGEX MATCH "#define ${PROJECT}_MajorNumber ([0-9]*)" _ ${BuildIdFile})
set(MajorNumber ${CMAKE_MATCH_1})
set(${PROJECT}_Version "v${MajorNumber}_${MinorNumber}_${BuildNumber}")
message(STATUS "${PROJECT} Version to install : ${${PROJECT}_Version}")
add_custom_command(
TARGET ${PROJECT} PRE_BUILD
COMMAND echo "${PROJECT}_${CMAKE_SYSTEM_NAME}_${PROJECT_BUILD_CONFIG_NAME}_${ARCH}_v${MajorNumber}.${MinorNumber}.${BuildNumber}" > ${CMAKE_SOURCE_DIR}/VERSION
DEPENDS ${PROJECT}
)
#############################################################
### INSTALL #################################################
#############################################################
install(TARGETS ${PROJECT} RUNTIME DESTINATION . COMPONENT APP_BINARY)
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION . COMPONENT APP_FILES)
install(FILES ${CMAKE_SOURCE_DIR}/VERSION DESTINATION . COMPONENT APP_FILES OPTIONAL)
install(FILES ${CMAKE_SOURCE_DIR}/CHANGELOG DESTINATION . COMPONENT APP_FILES OPTIONAL)
#############################################################
### PACKAGE #################################################
## https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/Component-Install-With-CPack
#############################################################
set(PROJECT_PACKAGE_NAME "${PROJECT}_${CMAKE_SYSTEM_NAME}_${PROJECT_BUILD_CONFIG_NAME}_${ARCH}_v${MajorNumber}.${MinorNumber}.${BuildNumber}")
set(PROJECT_SHORTCUT_NAME "${PROJECT}_v${MajorNumber}.${MinorNumber}.${BuildNumber}")
set(PROJECT_SHORTCUT_TARGET "${PROJECT}_${CMAKE_SYSTEM_NAME}_${PROJECT_BUILD_CONFIG_NAME}_${ARCH}")
set(ORGANIZATION_NAME "FunParadigm")
if (USE_PACKAGE_TO_NSIS_OR_ZIP)
set(CPACK_GENERATOR "NSIS")
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_NSIS_DISPLAY_NAME ${PROJECT_SHORTCUT_NAME})
set(CPACK_NSIS_PACKAGE_NAME ${PROJECT_SHORTCUT_NAME})
if (WIN32)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${ORGANIZATION_NAME}\\\\${PROJECT_PACKAGE_NAME}")
set(CPACK_NSIS_CREATE_ICONS_EXTRA
"CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\${PROJECT_SHORTCUT_NAME}.lnk' '$INSTDIR\\\\${PROJECT_SHORTCUT_TARGET}.exe'"
)
set(CPACK_NSIS_DELETE_ICONS_EXTRA
"Delete '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\${PROJECT_SHORTCUT_NAME}.lnk'"
)
endif()
else()
set(CPACK_GENERATOR "ZIP")
endif()
set(CPACK_MONOLITHIC_INSTALL 1)
set(CPACK_THREADS 8)
if (UNIX)
set(CPACK_SET_DESTDIR ON)
endif()
set(CPACK_PACKAGE_VENDOR ${ORGANIZATION_NAME})
set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
set(CPACK_PACKAGE_VERSION_MAJOR "${MajorNumber}")
set(CPACK_PACKAGE_VERSION_MINOR "${MinorNumber}")
set(CPACK_PACKAGE_VERSION_PATCH "${BuildNumber}")
set(CPACK_PACKAGE_NAME "${PROJECT_PACKAGE_NAME}")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_PACKAGE_NAME}")
set(CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "${PROJECT}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_PACKAGE_NAME}")
SET(CPACK_OUTPUT_FILE_PREFIX "${FINAL_BIN_DIR}/packages")
set(CPACK_PACKAGE_VERSION "${MajorNumber}.${MinorNumber}.${BuildNumber}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${${PROJECT}_PACKAGE_NAME} - Nodes based mesh composer")
if (EXISTS ${CMAKE_SOURCE_DIR}/LICENSE)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
endif()
if (EXISTS ${CMAKE_SOURCE_DIR}/VERSION)
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/VERSION")
endif()
include(CPack)