-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
212 lines (180 loc) · 6.17 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
cmake_minimum_required(VERSION 3.5)
cmake_policy(SET CMP0091 NEW) ## for CMAKE_MSVC_RUNTIME_LIBRARY
cmake_policy(SET CMP0079 NEW) # for have linking between libs
set(PROJECT SoGLSL)
enable_language(C CXX)
project(${PROJECT} CXX)
option(USE_SDL "Enale SDL instead of GLFW" OFF)
option(USE_PROFILER_TRACY "Enale Tracy Profiler" OFF)
option(USE_NETWORK "Enable NETWORK (Shader Inport, Versions, Changelog)" ON)
option(USE_STD_FILESYSTEM "Enable std::fielsystem use for path and ImGuiFileDialog" ON)
option(USE_VR "Enable VR Backend via OpenXR" ON)
## for group smake targets in the dir cmakeTargets
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "cmakeTargets")
if (USE_STD_FILESYSTEM)
add_definitions(-DUSE_STD_FILESYSTEM)
set(CMAKE_CXX_STANDARD 17)
else()
set(CMAKE_CXX_STANDARD 14)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
## some defines for debug mode (before 3rdparty.cmake)
if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") ## MT in release or MTd in debug
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG /Zi")
else()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -g")
endif()
if(USE_VR)
add_definitions(-DUSE_VR)
endif()
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
add_definitions(-DIMGUI_DEFINE_MATH_OPERATORS)
add_definitions(-DIMGUI_IMPL_OPENGL_LOADER_GLAD)
set(3RDPARTY_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
set(LLVM_USE_CRT_DEBUG MTd CACHE STRING "" FORCE)
set(LLVM_USE_CRT_MINSIZEREL MT CACHE STRING "" FORCE)
set(LLVM_USE_CRT_RELEASE MT CACHE STRING "" FORCE)
set(LLVM_USE_CRT_RELWITHDEBINFO MT CACHE STRING "" FORCE)
set(USE_MSVC_RUNTIME_LIBRARY_DLL OFF CACHE BOOL "" FORCE)
include(cmake/3rdparty.cmake)
## some defines for debug mode
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
add_definitions(-DPROJECT_PATH="${CMAKE_CURRENT_SOURCE_DIR}")
if(UNIX)
if(APPLE)
add_definitions(-DAPPLE)
else()
add_definitions(-DLINUX)
endif()
add_definitions(-DUNIX)
elseif(WIN32)
add_definitions(-DWIN32)
if(MINGW)
add_definitions(-DMINGW32)
endif()
set(DIRENT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dirent/include)
include_directories(${DIRENT_INCLUDE_DIR})
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_USE_MATH_DEFINES)
add_definitions(-DMSVC)
add_definitions(-DNOMINMAX) ## for avoid issue regarding std::max and std::min
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -Wall -Wextra -Wpedantic -Wdeprecated-declarations -Wno-unknown-pragmas -Wno-unused-variable -Wno-unused-parameter")
endif ()
#needed by the class ExportBuffer
if (BUILD_X32)
set(ARCH x32)
add_definitions(-DVERSION_X32)
message("${PROJECT} Build X32")
else()
set(ARCH x64)
add_definitions(-DVERSION_X64)
message("${PROJECT} Build X64")
endif()
file(GLOB PROJECT_MAIN ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
source_group(main FILES ${PROJECT_MAIN})
file(GLOB_RECURSE PROJECT_SRC_RECURSE
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/*.h
${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src PREFIX src FILES ${PROJECT_SRC_RECURSE})
file(GLOB IMGUI_MISC_SRC
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/ImGuiPack/imgui_docking/misc/cpp/imgui_stdlib.cpp
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/ImGuiPack/imgui_docking/misc/cpp/imgui_stdlib.h)
source_group(src/Imgui_Misc FILES ${IMGUI_MISC_SRC})
file(GLOB_RECURSE CMAKE_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/*.cmake)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/cmake PREFIX cmake FILES ${CMAKE_RECURSE})
add_library(${PROJECT} STATIC
${CMAKE_RECURSE}
${IMGUI_MISC_SRC}
${PROJECT_SRC_RECURSE}
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(${PROJECT} PRIVATE -Wno-unused-function) # its a lib, so a unused fucntion for an app can be used for an other app
endif()
if (USE_IMPLOT)
target_compile_definitions(${PROJECT} PUBLIC USE_IMPLOT)
endif()
if (USE_IM_COOL_BAR)
target_compile_definitions(${PROJECT} PUBLIC USE_IM_COOL_BAR)
endif()
if (USE_IM_GRADIENT_HDR)
target_compile_definitions(${PROJECT} PUBLIC USE_IM_GRADIENT_HDR)
endif()
if (USE_IMGUI_FILE_DIALOG)
target_compile_definitions(${PROJECT} PUBLIC USE_IMGUI_FILE_DIALOG)
endif()
if (USE_IM_GUIZMO)
target_compile_definitions(${PROJECT} PUBLIC USE_IM_GUIZMO)
endif()
if (USE_IM_TOOLS)
target_compile_definitions(${PROJECT} PUBLIC USE_IM_TOOLS)
endif()
if (USE_IMGUI_NODE_EDITOR)
target_compile_definitions(${PROJECT} PUBLIC USE_IMGUI_NODE_EDITOR)
endif()
if (USE_IMGUI_MARKDOW)
target_compile_definitions(${PROJECT} PUBLIC USE_IMGUI_MARKDOW)
endif()
if (USE_IMGUI_COLOR_TEXT_EDIT)
target_compile_definitions(${PROJECT} PUBLIC USE_IMGUI_COLOR_TEXT_EDIT)
endif()
set(SOGSL_INCLUDE_DIRS
${STB_INCLUDE_DIR}
${SDL_INCLUDE_DIR}
${GLM_INCLUDE_DIR}
${GLFW_INCLUDE_DIR}
${GLAD_INCLUDE_DIR}
${CURL_INCLUDE_DIR}
${EFSW_INCLUDE_DIR}
${PLOG_INCLUDE_DIR}
${TRACY_INCLUDE_DIR}
${IAGP_INCLUDE_DIRS}
${RTMIDI_INCLUDE_DIR}
${ASSIMP_INCLUDE_DIR}
${GLSLANG_INCLUDE_DIR}
${OPENGL_INCLUDE_DIRS}
${OPENXR_INCLUDE_DIRS}
${KISSFFT_INCLUDE_DIR}
${PICOJSON_INCLUDE_DIR}
${ALPHANUM_INCLUDE_DIR}
${TINYXML2_INCLUDE_DIR}
${MINIAUDIO_INCLUDE_DIR}
${IMGUIPACK_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/src
${IN_APP_GPU_PROFILER_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/tracy/public
)
set(SOGSL_INCLUDE_DIRS ${SOGSL_INCLUDE_DIRS} PARENT_SCOPE) ## set this var in the parent scope
set(SOGLSL_LIBRARIES SoGLSL PARENT_SCOPE) ## set this var in the parent scope
include_directories(${SOGSL_INCLUDE_DIRS})
target_link_libraries(${PROJECT} PRIVATE
${SDL_LIBRARIES}
${GLM_LIBRARIES}
${GLAD_LIBRARIES}
${GLFW_LIBRARIES}
${EFSW_LIBRARIES}
${CURL_LIBRARIES}
${IAGP_LIBRARIES}
${TRACY_LIBRARIES}
${OPENGL_LIBRARIES}
${CTOOLS_LIBRARIES}
${RTMIDI_LIBRARIES}
${OPENXR_LIBRARIES}
${ASSIMP_LIBRARIES}
${KISSFFT_LIBRARIES}
${GLSLANG_LIBRARIES}
${TINYXML2_LIBRARIES}
${MINIAUDIO_LIBRARIES}
${IMGUIPACK_LIBRARIES}
${IN_APP_GPU_PROFILER_LIBRARIES}
)
set(CTOOLS_LIBRARIES ${CTOOLS_LIBRARIES} PARENT_SCOPE)