-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
247 lines (198 loc) · 6.41 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
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_STANDARD 17)
project(tectogen C CXX)
# Work around dmon incompaitibility with clang
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-Wno-c++11-narrowing)
endif()
add_compile_definitions(IMGUI_DEFINE_MATH_OPERATORS)
set(PROJ_DIR "${CMAKE_SOURCE_DIR}/src"
CACHE PATH "Root of the project sources")
set(EXTPATH_LIBSOUNDIO "${CMAKE_SOURCE_DIR}/ext/libsoundio"
CACHE PATH "Where to find libsoundio")
set(IMGUI_DIR "${CMAKE_SOURCE_DIR}/ext/imgui"
CACHE PATH "Where to find imgui, this directory contains imgui.cpp etc.")
set(IMNODES_DIR "${CMAKE_SOURCE_DIR}/ext/imnodes"
CACHE PATH "Where to find imnodes")
set(EXTPATH_PLATFORMFOLDERS "${CMAKE_SOURCE_DIR}/ext/PlatformFolders"
CACHE PATH "Where to find PlatformFolders")
option(USE_JET_LIVE "Use jet-live library for hot code reloading" OFF)
if(USE_JET_LIVE)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif()
set(EXTPATH_JET_LIVE ext/jet-live
CACHE PATH "Where to find jet-live, this directory contains its CMakeLists.txt")
set(EXTPATH_DMON "${CMAKE_SOURCE_DIR}/ext/dmon"
CACHE PATH "Where dmon.h resides")
set(EXTPATH_VISIT_STRUCT "${CMAKE_SOURCE_DIR}/ext/visit_struct/include"
CACHE PATH "visit_Struct")
set(CLASSES
app
logs
shader
shadermanager
console
audioconfigwindow
instreammanager
widgets
config
uicomponent
context
nodewindow
nodeprogrammanager
nodeprogramlibrary
nodegraph
nodeprograminstancewrapper
nodeprogrammetadata
asynctex
multibuffer
shaderprogram
displaypayload
shaderinvocation
video
profiler
shadernodeprogram
monitoringwindow
)
set(HEADER
jettools
ringbuffer
imconfig
nodeprogramapi
monitoring
)
foreach(class ${CLASSES})
list(APPEND SOURCES ${PROJ_DIR}/${class}.cpp)
list(APPEND HEADERS ${PROJ_DIR}/${class}.h)
endforeach()
foreach(header ${HEADER})
list(APPEND HEADERS ${PROJ_DIR}/${header}.h)
endforeach()
list(APPEND SOURCES
${PROJ_DIR}/main.cpp
)
list(APPEND HEADERS
${EXTPATH_DMON}/dmon.h
)
set(IMGUI_SOURCES
${IMGUI_DIR}/imgui.cpp
${IMGUI_DIR}/imgui_draw.cpp
${IMGUI_DIR}/imgui_tables.cpp
${IMGUI_DIR}/imgui_widgets.cpp
${IMNODES_DIR}/imnodes.cpp
)
set(IMGUI_HEADERS
${IMGUI_DIR}/imgui.h
${IMGUI_DIR}/imconfig.h
${IMGUI_DIR}/imgui_internal.h
${IMGUI_DIR}/backends/imgui_impl_glfw.h
${IMGUI_DIR}/backends/imgui_impl_opengl3.h
${IMGUI_DIR}/backends/imgui_impl_opengl2.h
${IMNODES_DIR}/imnodes.h
)
set(EXT_SOURCES
${EXT_SOURCES}
${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp
${IMGUI_DIR}/backends/imgui_impl_opengl2.cpp
${IMGUI_DIR}/backends/imgui_impl_glfw.cpp
)
set(BINARY_TARGET "${PROJECT_NAME}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
add_executable(${BINARY_TARGET} "")
target_sources(${BINARY_TARGET}
PRIVATE
${SOURCES}
${EXT_SOURCES}
${IMGUI_SOURCES}
${HEADERS}
${IMGUI_HEADERS}
)
set(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
)
IF(WIN32)
set(OpenGL_GL_PREFERENCE LEGACY) # not needed?
set(GLFW_LIBRARIES "libglfw3.a") # not needed?
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static") # not needed?
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0")
target_compile_definitions(${PROJECT_NAME} PRIVATE GLEW_STATIC)
target_compile_definitions(${PROJECT_NAME} PRIVATE SOUNDIO_STATIC_LIBRARY)
ENDIF()
## STANDARD ##
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
## MODULES ##
find_package(FFTW REQUIRED COMPONENTS SIMPLE) # signle precision fftw3f
find_package(glfw3 REQUIRED)
# TODO: libsoundio module?
if(USE_JET_LIVE)
include(${EXTPATH_JET_LIVE}/cmake/jet_live_setup.cmake) # setup needed compiler and linker flags, include this file in your root CMakeLists.txt
set(JET_LIVE_BUILD_EXAMPLE OFF)
set(JET_LIVE_SHARED ON) # if you want to
add_subdirectory(${EXTPATH_JET_LIVE})
target_link_libraries(${PROJECT_NAME} jet-live)
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_JET_LIVE)
message("Using JetLive")
endif()
set(BUILD_STATIC_LIBS ON CACHE BOOL "Build static libraries" FORCE)
set(BUILD_DYNAMIC_LIBS OFF CACHE BOOL "Build dynamic libraries")
set(BUILD_EXAMPLE_PROGRAMS OFF CACHE BOOL "Build example programs" FORCE)
set(BUILD_TESTS OFF CACHE BOOL "Build tests" FORCE)
add_subdirectory(${EXTPATH_LIBSOUNDIO})
add_subdirectory(${EXTPATH_PLATFORMFOLDERS})
# https://github.com/andrewrk/libsoundio/issues/276
set_property(DIRECTORY "${EXTPATH_LIBSOUNDIO}" APPEND PROPERTY COMPILE_DEFINITIONS "NDEBUG")
get_directory_property(LIBSOUNDIO_LIBS DIRECTORY ${EXTPATH_LIBSOUNDIO} DEFINITION LIBSOUNDIO_LIBS)
get_directory_property(SOUNDIO_STATIC_LIBNAME DIRECTORY ${EXTPATH_LIBSOUNDIO} DEFINITION SOUNDIO_STATIC_LIBNAME)
IF (WIN32)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
set_target_properties(${BINARY_TARGET} PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(${BINARY_TARGET} PROPERTIES LINK_SEARCH_END_STATIC 1)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
target_link_libraries(${BINARY_TARGET} -static-libgcc -static-libstdc++)
find_package(Threads REQUIRED)
#TODO: remove explicit references to static library files (above should suffice to link statically)
target_link_libraries(${BINARY_TARGET} PRIVATE
libsoundio_static ${LIBSOUNDIO_LIBS}
libglew32.a
${OPENGL_LIBRARIES}
glfw
${FFTW_LIBRARIES}
${LIBSOUNDIO_LIBS}
PRIVATE sago::platform_folders
${CMAKE_DL_LIBS}
)
ELSE ()
target_link_libraries(${BINARY_TARGET} PRIVATE
libsoundio_static
${GLEW_LIBRARIES}
${OPENGL_LIBRARIES}
glfw
${FFTW_LIBRARIES}
${LIBSOUNDIO_LIBS}
PRIVATE sago::platform_folders
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS}
)
ENDIF()
target_include_directories(${BINARY_TARGET} PRIVATE
${OPENGL_INCLUDE_DIRS}
${GLFW3_INCLUDE_DIRS}
${FFTW_INCLUDE_DIRS}
${GLEW_INCLUDE_DIRS}
PRIVATE ${IMGUI_DIR}
PRIVATE ${IMGUI_DIR}/backends
PRIVATE ${IMNODES_DIR}
PRIVATE ${PROJ_DIR}
${EXTPATH_LIBSOUNDIO}
${EXTPATH_PLATFORMFOLDERS}
PRIVATE ${EXTPATH_DMON}
PRIVATE ${EXTPATH_VISIT_STRUCT}
)
target_compile_definitions(${BINARY_TARGET} PRIVATE IMGUI_IMPL_LOADER_GLEW)
file(GLOB SHADER_FILES
"res/shaders/*"
)
file(COPY ${SHADER_FILES} DESTINATION ${CMAKE_BINARY_DIR}/share/tectogen/shaders)