-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
297 lines (260 loc) · 7.91 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
cmake_minimum_required(VERSION 3.11)
project(LabSoundGraphToy VERSION 0.1.0 LANGUAGES C CXX)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
add_subdirectory(third/LabSound)
if (WIN32)
set (PLATFORM_DEFS
WIN32_LEAN_AND_MEAN
NOMINMAX
_CRT_SECURE_NO_WARNINGS
)
endif()
set(PLAYGROUND_SRC
src/main.cpp
src/lab_imgui_ext.cpp
src/lab_imgui_ext.hpp
src/lab_noodle.cpp
src/lab_noodle.h
src/legit_profiler.hpp
src/meshula_lab.hpp
src/IconsFontaudio.h
src/ImguiFontCousineRegular.cpp
src/LabSoundInterface.cpp
src/LabSoundInterface.h
src/MidiNode.cpp
src/MidiNode.hpp
src/OSCMsg.hpp
src/OSCNode.hpp
src/OSCNode.cpp
src/queue_spsc.hpp
)
if(APPLE)
set(ST_GFX_DEFS
IMGUI_IMPL_API=
SOKOL_METAL
)
else()
set(ST_GFX_DEFS
IMGUI_IMPL_API=
SOKOL_GLCORE33
)
endif()
#-------------------------------------------------------------------------------
# LabMidi
#-------------------------------------------------------------------------------
add_subdirectory("third/LabMidi")
#-------------------------------------------------------------------------------
# TinyOSC
#-------------------------------------------------------------------------------
add_subdirectory("third/tinyosc")
#-------------------------------------------------------------------------------
# rapidjson
#-------------------------------------------------------------------------------
set(RAPIDJSON_INCL third/rapidjson/include)
#-------------------------------------------------------------------------------
# imgui
#-------------------------------------------------------------------------------
if (WIN32)
set(IMGUI_EXTRA third/ImGui.natvis)
endif()
set(IMGUI_SRC
third/imgui/imgui.cpp
third/imgui/imgui.h
third/imgui/imgui_demo.cpp
third/imgui/imgui_draw.cpp
third/imgui/imgui_internal.h
third/imgui/imgui_tables.cpp
third/imgui/imgui_widgets.cpp
${IMGUI_EXTRA}
)
add_library(imgui STATIC ${IMGUI_SRC})
target_include_directories(imgui SYSTEM
PUBLIC third/imgui)
target_compile_definitions(imgui PRIVATE
${ST_GFX_DEFS}
IMGUI_DEFINE_MATH_OPERATORS
${PLATFORM_DEFS}
)
#-------------------------------------------------------------------------------
# sokol
#-------------------------------------------------------------------------------
set(SOKOL_SRC
src/sokol.cpp)
set(SOKOL_HEADERS
third/sokol/sokol_app.h
third/sokol/sokol_args.h
third/sokol/sokol_audio.h
third/sokol/sokol_fetch.h
third/sokol/sokol_gfx.h
third/sokol/sokol_time.h
third/sokol/util/sokol_fontstash.h
third/sokol/util/sokol_gfx_imgui.h
third/sokol/util/sokol_gl.h
third/sokol/util/sokol_imgui.h
)
add_library(sokol STATIC ${SOKOL_SRC} ${SOKOL_HEADERS})
target_include_directories(sokol SYSTEM
PUBLIC third/sokol third/sokol/util src)
target_link_libraries(sokol imgui)
add_dependencies(sokol imgui)
target_compile_definitions(sokol PRIVATE
${ST_GFX_DEFS}
IMGUI_DEFINE_MATH_OPERATORS
${PLATFORM_DEFS}
USE_DBG_UI
)
if(APPLE)
set_source_files_properties(src/sokol.cpp PROPERTIES COMPILE_FLAGS "-x objective-c++ -fobjc-arc")
endif()
install(
TARGETS sokol
EXPORT sokolTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
PUBLIC_HEADER DESTINATION include/sokol
)
#-------------------------------------------------------------------------------
# LabSoundGraphToy
#-------------------------------------------------------------------------------
set(PLAYGROUND_SHADERS
# simple_cube instancing billboard_instances
)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated_src)
foreach(SHADER ${PLAYGROUND_SHADERS})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated_src/${SHADER}_glsl.h
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/third/sokol-tools-bin/bin/win32/sokol-shdc.exe --input ${CMAKE_CURRENT_SOURCE_DIR}/src/${SHADER}.glsl --output ${CMAKE_CURRENT_BINARY_DIR}/generated_src/${SHADER}_glsl.h --slang glsl330:hlsl5:metal_macos
COMMENT "Running sokol-shdc for ${SHADER}.glsl"
)
list(APPEND PLAYGROUND_SHADERS_SRC ${CMAKE_CURRENT_BINARY_DIR}/generated_src/${SHADER}_glsl.h)
endforeach()
add_custom_target(ProcessPlaygroundShaderFiles ALL DEPENDS ${PLAYGROUND_SHADERS_SRC})
if(APPLE)
set(NFD src/nfd.h src/nfd.mm)
else()
set(NFD src/nfd.h src/nfd.cc)
endif()
add_executable(LabSoundGraphToy
${NFD}
${PLAYGROUND_SRC}
${ST_GFX_SRC}
${PLAYGROUND_SHADERS_SRC}
)
add_dependencies(LabSoundGraphToy ProcessPlaygroundShaderFiles)
set_target_properties(LabSoundGraphToy PROPERTIES
RUNTIME_OUTPUT_DIRECTORY bin)
target_compile_definitions(LabSoundGraphToy PRIVATE
${ST_GFX_DEFS}
IMGUI_DEFINE_MATH_OPERATORS
${PLATFORM_DEFS}
SOKOL_WIN32_FORCE_MAIN
)
target_include_directories(LabSoundGraphToy SYSTEM
PRIVATE third/imgui
PRIVATE third/LabSound/include
PRIVATE ${RAPIDJSON_INCL}
PRIVATE third/entt/single_include)
target_include_directories(LabSoundGraphToy
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/generated_src
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
PRIVATE third/imgui/examples)
set_property(TARGET LabSoundGraphToy PROPERTY CXX_STANDARD 17)
set_property(TARGET LabSoundGraphToy PROPERTY CXX_STANDARD_REQUIRED ON)
if (WIN32)
set(PLATFORM_LIBS ws2_32 Iphlpapi.lib opengl32.lib)
elseif (APPLE)
# if(CMAKE_OSX_SYSROOT MATCHES ".*iphoneos.*")
# set(DARWIN_LIBS
# "-framework AudioToolbox"
# "-framework Accelerate"
# "-framework CoreAudio")
# else()
set(PLATFORM_LIBS
"-framework AudioToolbox"
"-framework AudioUnit"
"-framework Accelerate"
"-framework Cocoa"
"-framework CoreAudio"
"-framework Metal"
"-framework MetalKit"
"-framework QuartzCore"
)
# endif()
endif()
# In order to use the LabSound Registry, and LabSound as a static library,
# whole archive needs to be specified in order not to deadstrip the static
# initializers.
# Unfortunately, the developers of cmake have yet to agree that a
# whole archive flag is in order, and so this terrible contraption is
# necessary.
#
if(MSVC)
target_link_libraries(LabSoundGraphToy
${PLATFORM_LIBS}
imgui
libnyquist
samplerate
Lab::Midi
Tiny::OSC
sokol
-WHOLEARCHIVE:$<TARGET_FILE:Lab::Sound>
)
elseif(CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(LabSoundGraphToy
${PLATFORM_LIBS}
imgui
libnyquist
samplerate
Lab::Midi
Tiny::OSC
sokol
-Wl,--whole-archive $<TARGET_FILE:Lab::Sound> -Wl,--no-whole-archive
)
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
target_link_libraries(LabSoundGraphToy
${PLATFORM_LIBS}
imgui
libnyquist
samplerate
Lab::Midi
Tiny::OSC
sokol
Lab::Sound
)
else()
target_link_libraries(LabSoundGraphToy
${PLATFORM_LIBS}
imgui
libnyquist
samplerate
Lab::Sound
Lab::Midi
Tiny::OSC
sokol
)
endif()
#-------------------------------------------------------------------------------
# Installer
#-------------------------------------------------------------------------------
install(
TARGETS LabSoundGraphToy
BUNDLE DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(
FILES
resources/fontaudio.ttf
resources/preview.png
DESTINATION bin/LabSoundGraphToy_rsrc/)
install(
FILES
resources/fontaudio.ttf
resources/preview.png
DESTINATION ${CMAKE_BINARY_DIR}/bin/Debug/LabSoundGraphToy_rsrc/)
install(
FILES
resources/fontaudio.ttf
resources/preview.png
DESTINATION ${CMAKE_BINARY_DIR}/bin/Release/LabSoundGraphToy_rsrc/)