Debian Codegraph @

android/app/jni/CMakeLists.txt

raw
1 cmake_minimum_required(VERSION 3.0...3.16)
2
3 if (APPLE)
4 set(MACOSX_DEPLOYMENT_TARGET 10.9)
5 endif()
6
7 project(furnace)
8
9 if (APPLE)
10 enable_language(OBJC)
11 enable_language(OBJCXX)
12 endif()
13
14 set(CMAKE_CXX_STANDARD 14)
15 set(CMAKE_CXX_EXTENSIONS OFF)
16
17 set(CMAKE_PROJECT_VERSION_MAJOR 0)
18 set(CMAKE_PROJECT_VERSION_MINOR 6)
19 set(CMAKE_PROJECT_VERSION_PATCH 8)
20
21 set(BUILD_GUI_DEFAULT ON)
22 set(USE_SDL2_DEFAULT ON)
23 set(USE_SNDFILE_DEFAULT ON)
24 set(SYSTEM_SDL2_DEFAULT OFF)
25
26 include(CheckIncludeFile)
27 include(TestBigEndian)
28
29 execute_process(COMMAND git status RESULT_VARIABLE DONT_HAVE_GIT WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
30 if (NOT DONT_HAVE_GIT)
31 message(STATUS "Git is available")
32 else()
33 message(WARNING "either Git is not available, or this Git repository has not been initialized.
34 if you have used the \"Source code\" option in the GitHub release page, you are doing it wrong! unless you manually initialize submodules, the build is guaranteed to FAIL spectacularly!
35 read the \"developer info\" section of README.md for more information.")
36 endif()
37
38 if (ANDROID)
39 set(USE_RTMIDI_DEFAULT OFF)
40 set(WITH_PORTAUDIO_DEFAULT OFF)
41 set(USE_BACKWARD_DEFAULT OFF)
42 find_library(TERMUX rt)
43 if (TERMUX)
44 message(STATUS "Termux detected")
45 endif()
46 else()
47 set(USE_RTMIDI_DEFAULT ON)
48 set(WITH_PORTAUDIO_DEFAULT ON)
49 if (WIN32 OR APPLE)
50 set(USE_BACKWARD_DEFAULT ON)
51 else()
52 CHECK_INCLUDE_FILE(execinfo.h EXECINFO_FOUND)
53 if (EXECINFO_FOUND)
54 set(USE_BACKWARD_DEFAULT ON)
55 else()
56 set(USE_BACKWARD_DEFAULT OFF)
57 endif()
58 endif()
59 endif()
60
61 find_package(PkgConfig)
62 if (PKG_CONFIG_FOUND AND NOT ANDROID)
63 pkg_check_modules(JACK jack)
64 set(WITH_JACK_DEFAULT ${JACK_FOUND})
65 else()
66 set(WITH_JACK_DEFAULT OFF)
67 endif()
68
69 set(WITH_RENDER_SDL_DEFAULT ON)
70 set(WITH_RENDER_OPENGL_DEFAULT ON)
71 if (WIN32)
72 set(WITH_RENDER_DX11_DEFAULT ON)
73 set(WITH_RENDER_DX9_DEFAULT ON)
74 else()
75 set(WITH_RENDER_DX11_DEFAULT OFF)
76 set(WITH_RENDER_DX9_DEFAULT OFF)
77 endif()
78 if (APPLE)
79 set(WITH_RENDER_METAL_DEFAULT ON)
80 else()
81 set(WITH_RENDER_METAL_DEFAULT OFF)
82 endif()
83
84 if (ANDROID)
85 set(USE_GLES_DEFAULT ON)
86 set(WITH_RENDER_OPENGL1_DEFAULT OFF)
87 else()
88 set(USE_GLES_DEFAULT OFF)
89 if (APPLE)
90 set(WITH_RENDER_OPENGL1_DEFAULT OFF)
91 else()
92 set(WITH_RENDER_OPENGL1_DEFAULT ON)
93 endif()
94 endif()
95
96 set(WITH_LOCALE_DEFAULT ON)
97
98 try_compile(HAVE_SETLOCALE ${CMAKE_BINARY_DIR}/check SOURCES ${CMAKE_SOURCE_DIR}/src/check/check_setlocale.c)
99 include(FindIntl)
100
101 if (HAVE_SETLOCALE AND Intl_FOUND AND NOT APPLE AND NOT WIN32)
102 set(USE_MOMO_DEFAULT OFF)
103 else()
104 set(USE_MOMO_DEFAULT ON)
105 endif()
106
107 option(BUILD_GUI "Build the tracker (disable to build only a headless player)" ${BUILD_GUI_DEFAULT})
108 option(WITH_LOCALE "Use libintl for language support" ${WITH_LOCALE_DEFAULT})
109 option(USE_RTMIDI "Build with MIDI support using RtMidi." ${USE_RTMIDI_DEFAULT})
110 option(USE_SDL2 "Build with SDL2. Required to build with GUI." ${USE_SDL2_DEFAULT})
111 option(USE_SNDFILE "Build with libsndfile. Required in order to work with audio files." ${USE_SNDFILE_DEFAULT})
112 option(USE_BACKWARD "Use backward-cpp to print a backtrace on crash/abort." ${USE_BACKWARD_DEFAULT})
113 option(USE_MOMO "Build a libintl implementation instead of using the system one." ${USE_MOMO_DEFAULT})
114 option(WITH_JACK "Whether to build with JACK support. Auto-detects if JACK is available" ${WITH_JACK_DEFAULT})
115 option(WITH_PORTAUDIO "Whether to build with PortAudio for audio output." ${WITH_PORTAUDIO_DEFAULT})
116 option(WITH_RENDER_SDL "Whether to build with the SDL_Renderer render backend." ${WITH_RENDER_SDL_DEFAULT})
117 option(WITH_RENDER_OPENGL "Whether to build with the OpenGL render backend." ${WITH_RENDER_OPENGL_DEFAULT})
118 option(WITH_RENDER_OPENGL1 "Whether to build with the OpenGL 1.1 render backend." ${WITH_RENDER_OPENGL1_DEFAULT})
119 option(WITH_RENDER_DX11 "Whether to build with the DirectX 11 render backend." ${WITH_RENDER_DX11_DEFAULT})
120 option(WITH_RENDER_DX9 "Whether to build with the DirectX 9 render backend." ${WITH_RENDER_DX9_DEFAULT})
121 option(WITH_RENDER_METAL "Whether to build with the Metal render backend." ${WITH_RENDER_METAL_DEFAULT})
122 option(USE_GLES "Use OpenGL ES for the OpenGL render backend." ${USE_GLES_DEFAULT})
123 option(USE_FREETYPE "Use FreeType for font rendering." ON)
124 option(SYSTEM_FFTW "Use a system-installed version of FFTW instead of the vendored one" OFF)
125 option(SYSTEM_FMT "Use a system-installed version of fmt instead of the vendored one" OFF)
126 option(SYSTEM_FREETYPE "Use a system-installed version of FreeType instead of the vendored one" OFF)
127 option(SYSTEM_LIBSNDFILE "Use a system-installed version of libsndfile instead of the vendored one" OFF)
128 option(SYSTEM_PORTAUDIO "Use a system-installed version of PortAudio instead of the vendored one" OFF)
129 option(SYSTEM_RTMIDI "Use a system-installed version of RtMidi instead of the vendored one" OFF)
130 option(SYSTEM_ZLIB "Use a system-installed version of zlib instead of the vendored one" OFF)
131 option(SYSTEM_SDL2 "Use a system-installed version of SDL2 instead of the vendored one" ${SYSTEM_SDL2_DEFAULT})
132 option(SUPPORT_XP "Build a Windows XP-compatible binary" OFF)
133 option(SUPPORT_VISTA "Build a Windows Vista-compatible binary" OFF)
134 option(WARNINGS_ARE_ERRORS "Whether warnings in furnace's C++ code should be treated as errors" OFF)
135 option(WITH_DEMOS "Install demo songs (NOTE: demo songs are NOT under GPL!)" OFF)
136 option(WITH_INSTRUMENTS "Install instruments" ON)
137 option(WITH_WAVETABLES "Install wavetables" ON)
138 option(SHOW_OPEN_ASSETS_MENU_ENTRY "Show option to open built-in assets directory (on supported platforms)" OFF)
139 option(CONSOLE_SUBSYSTEM "Build Furnace with Console subsystem on Windows" OFF)
140 option(FORCE_CODEVIEW "Force -gcodeview on MinGW GCC" OFF)
141 option(FLATPAK_WORKAROUNDS "Enable Flatpak-specific workaround for system file picker" OFF)
142 option(NO_INTRO "Disable intro animation entirely" OFF)
143 if (APPLE)
144 option(FORCE_APPLE_BIN "Force enable binary installation to /bin" OFF)
145 option(MAKE_BUNDLE "Make a bundle" OFF)
146 else()
147 # not Apple - not needed
148 set(FORCE_APPLE_BIN OFF)
149 set(MAKE_BUNDLE OFF)
150 endif()
151
152 set(DEPENDENCIES_INCLUDE_DIRS extern/IconFontCppHeaders extern/blip_buf src/icon)
153
154 if (ANDROID AND NOT TERMUX)
155 set(DEPENDENCIES_DEFINES "IS_MOBILE")
156 else()
157 set(DEPENDENCIES_DEFINES "")
158 endif()
159
160 TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
161
162 if (IS_BIG_ENDIAN)
163 list(APPEND DEPENDENCIES_DEFINES "TA_BIG_ENDIAN")
164 endif()
165
166 if (FLATPAK_WORKAROUNDS)
167 list(APPEND DEPENDENCIES_DEFINES "FLATPAK_WORKAROUNDS")
168 endif()
169
170 set(DEPENDENCIES_COMPILE_OPTIONS "")
171 set(DEPENDENCIES_LIBRARIES "")
172 set(DEPENDENCIES_LIBRARY_DIRS "")
173 set(DEPENDENCIES_LINK_OPTIONS "")
174 set(DEPENDENCIES_LEGACY_LDFLAGS "")
175
176 if (BUILD_GUI AND WITH_RENDER_SDL)
177 set(SYSTEM_SDL_MIN_VER 2.0.18)
178 else()
179 set(SYSTEM_SDL_MIN_VER 2.0.0)
180 endif()
181
182 #list(APPEND DEPENDENCIES_INCLUDE_DIRS "extern/SAASound/include")
183 list(APPEND DEPENDENCIES_INCLUDE_DIRS "extern/vgsound_emu-modified")
184
185 find_package(Threads REQUIRED)
186 list(APPEND DEPENDENCIES_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
187
188
189 if (WIN32)
190 # support Windows XP
191 if (SUPPORT_XP)
192 list(APPEND DEPENDENCIES_DEFINES "_WIN32_WINNT=0x0500")
193 list(APPEND DEPENDENCIES_DEFINES "SUPPORT_XP")
194 else()
195 # support Windows Vista
196 if (SUPPORT_VISTA)
197 list(APPEND DEPENDENCIES_DEFINES "_WIN32_WINNT=0x0600")
198 endif()
199 endif()
200 endif()
201
202 if (SYSTEM_FFTW)
203 find_package(PkgConfig REQUIRED)
204 pkg_check_modules(FFTW REQUIRED fftw3>=3.3)
205 list(APPEND DEPENDENCIES_INCLUDE_DIRS ${FFTW_INCLUDE_DIRS})
206 list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${FFTW_CFLAGS_OTHER})
207 list(APPEND DEPENDENCIES_LIBRARIES ${FFTW_LIBRARIES})
208 list(APPEND DEPENDENCIES_LIBRARY_DIRS ${FFTW_LIBRARY_DIRS})
209 list(APPEND DEPENDENCIES_LINK_OPTIONS ${FFTW_LDFLAGS_OTHER})
210 list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${FFTW_LDFLAGS})
211 message(STATUS "Using system-installed FFTW")
212 else()
213 if (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
214 set(WITH_OUR_MALLOC ON CACHE BOOL "aaa" FORCE)
215 endif()
216 set(BUILD_TESTS OFF CACHE BOOL "come on" FORCE)
217 add_subdirectory(extern/fftw EXCLUDE_FROM_ALL)
218 list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/fftw/api)
219 list(APPEND DEPENDENCIES_LIBRARIES fftw3)
220 message(STATUS "Using vendored FFTW")
221 endif()
222
223 if (SYSTEM_FMT)
224 if (PKG_CONFIG_FOUND)
225 pkg_check_modules(FMT fmt>=7.1.0)
226 if (FMT_FOUND)
227 list(APPEND DEPENDENCIES_INCLUDE_DIRS ${FMT_INCLUDE_DIRS})
228 list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${FMT_CFLAGS_OTHER})
229 list(APPEND DEPENDENCIES_LIBRARIES ${FMT_LIBRARIES})
230 list(APPEND DEPENDENCIES_LIBRARY_DIRS ${FMT_LIBRARY_DIRS})
231 list(APPEND DEPENDENCIES_LINK_OPTIONS ${FMT_LDFLAGS_OTHER})
232 list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${FMT_LDFLAGS})
233 endif()
234 endif()
235 if (NOT FMT_FOUND)
236 find_package(fmt REQUIRED)
237 list(APPEND DEPENDENCIES_LIBRARIES fmt::fmt)
238 endif()
239 message(STATUS "Using system-installed fmt")
240 else()
241 add_subdirectory(extern/fmt EXCLUDE_FROM_ALL)
242 list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/fmt/include)
243 list(APPEND DEPENDENCIES_LIBRARIES fmt)
244 message(STATUS "Using vendored fmt")
245 endif()
246
247 if (BUILD_GUI AND USE_FREETYPE)
248 # TODO: FIX FIX FIX FIX FIX
249 if (SYSTEM_FREETYPE)
250 if (PKG_CONFIG_FOUND)
251 pkg_check_modules(FREETYPE freetype2>=2.0.0)
252 if (FREETYPE_FOUND)
253 list(APPEND DEPENDENCIES_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS})
254 list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${FREETYPE_CFLAGS_OTHER})
255 list(APPEND DEPENDENCIES_LIBRARIES ${FREETYPE_LIBRARIES})
256 list(APPEND DEPENDENCIES_LIBRARY_DIRS ${FREETYPE_LIBRARY_DIRS})
257 list(APPEND DEPENDENCIES_LINK_OPTIONS ${FREETYPE_LDFLAGS_OTHER})
258 list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${FREETYPE_LDFLAGS})
259 endif()
260 endif()
261 if (NOT FREETYPE_FOUND)
262 find_package(freetype REQUIRED)
263 list(APPEND DEPENDENCIES_LIBRARIES freetype::freetype)
264 endif()
265 message(STATUS "Using system-installed FreeType")
266 else()
267 set(FT_DISABLE_BROTLI ON CACHE BOOL "one" FORCE)
268 set(FT_DISABLE_BZIP2 ON CACHE BOOL "two" FORCE)
269 set(FT_DISABLE_HARFBUZZ ON CACHE BOOL "three" FORCE)
270 set(FT_DISABLE_PNG ON CACHE BOOL "four" FORCE)
271 set(FT_DISABLE_ZLIB ON CACHE BOOL "five" FORCE)
272 add_subdirectory(extern/freetype EXCLUDE_FROM_ALL)
273 list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/freetype/include)
274 list(APPEND DEPENDENCIES_LIBRARIES freetype)
275 message(STATUS "Using vendored FreeType")
276 endif()
277 list(APPEND DEPENDENCIES_DEFINES HAVE_FREETYPE)
278 endif()
279
280 if (USE_SNDFILE)
281 list(APPEND DEPENDENCIES_DEFINES HAVE_SNDFILE)
282 if (SYSTEM_LIBSNDFILE)
283 find_package(PkgConfig REQUIRED)
284 pkg_check_modules(LIBSNDFILE REQUIRED sndfile)
285 list(APPEND DEPENDENCIES_INCLUDE_DIRS ${LIBSNDFILE_INCLUDE_DIRS})
286 list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${LIBSNDFILE_CFLAGS_OTHER})
287 list(APPEND DEPENDENCIES_LIBRARIES ${LIBSNDFILE_LIBRARIES})
288 list(APPEND DEPENDENCIES_LIBRARY_DIRS ${LIBSNDFILE_LIBRARY_DIRS})
289 list(APPEND DEPENDENCIES_LINK_OPTIONS ${LIBSNDFILE_LDFLAGS_OTHER})
290 list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${LIBSNDFILE_LDFLAGS})
291 message(STATUS "Using system-installed libsndfile")
292 else()
293 set(BUILD_TESTING OFF CACHE BOOL "aaaaaa" FORCE)
294 set(BUILD_PROGRAMS OFF CACHE BOOL "aaa" FORCE)
295 set(BUILD_EXAMPLES OFF CACHE BOOL "a" FORCE)
296 set(ENABLE_EXTERNAL_LIBS OFF CACHE BOOL "come on" FORCE)
297 set(ENABLE_MPEG OFF CACHE BOOL "come on" FORCE)
298 add_subdirectory(extern/libsndfile-modified EXCLUDE_FROM_ALL)
299 list(APPEND DEPENDENCIES_LIBRARIES sndfile)
300 message(STATUS "Using vendored libsndfile")
301 endif()
302 else()
303 message(STATUS "Not using libsndfile")
304 endif()
305
306 if (WITH_PORTAUDIO)
307 if (SYSTEM_PORTAUDIO)
308 find_package(PkgConfig REQUIRED)
309 pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0)
310 list(APPEND DEPENDENCIES_INCLUDE_DIRS ${PORTAUDIO_INCLUDE_DIRS})
311 list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${PORTAUDIO_CFLAGS_OTHER})
312 list(APPEND DEPENDENCIES_LIBRARIES ${PORTAUDIO_LIBRARIES})
313 list(APPEND DEPENDENCIES_LIBRARY_DIRS ${PORTAUDIO_LIBRARY_DIRS})
314 list(APPEND DEPENDENCIES_LINK_OPTIONS ${PORTAUDIO_LDFLAGS_OTHER})
315 list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${PORTAUDIO_LDFLAGS})
316 message(STATUS "Using system-installed PortAudio")
317 else()
318 set(PA_BUILD_SHARED_LIBS OFF CACHE BOOL "Build dynamic library" FORCE)
319 # don't - Furnace has its own implementation
320 set(PA_USE_JACK OFF CACHE BOOL "Enable support for JACK Audio Connection Kit" FORCE)
321 add_subdirectory(extern/portaudio-modified EXCLUDE_FROM_ALL)
322 list(APPEND DEPENDENCIES_LIBRARIES PortAudio)
323 message(STATUS "Using vendored PortAudio")
324 endif()
325 endif()
326
327 if (USE_RTMIDI)
328 if (SYSTEM_RTMIDI)
329 find_package(PkgConfig REQUIRED)
330 pkg_check_modules(RTMIDI REQUIRED rtmidi)
331 list(APPEND DEPENDENCIES_INCLUDE_DIRS ${RTMIDI_INCLUDE_DIRS})
332 list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${RTMIDI_CFLAGS_OTHER})
333 list(APPEND DEPENDENCIES_LIBRARIES ${RTMIDI_LIBRARIES})
334 list(APPEND DEPENDENCIES_LIBRARY_DIRS ${RTMIDI_LIBRARY_DIRS})
335 list(APPEND DEPENDENCIES_LINK_OPTIONS ${RTMIDI_LDFLAGS_OTHER})
336 list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${RTMIDI_LDFLAGS})
337 message(STATUS "Using system-installed RtMidi")
338 else()
339 add_subdirectory(extern/rtmidi EXCLUDE_FROM_ALL)
340 list(APPEND DEPENDENCIES_LIBRARIES rtmidi)
341 message(STATUS "Using vendored RtMidi")
342 endif()
343 endif()
344
345 if (SYSTEM_ZLIB)
346 find_package(PkgConfig REQUIRED)
347 pkg_check_modules(ZLIB REQUIRED zlib)
348 list(APPEND DEPENDENCIES_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
349 list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${ZLIB_CFLAGS_OTHER})
350 list(APPEND DEPENDENCIES_LIBRARIES ${ZLIB_LIBRARIES})
351 list(APPEND DEPENDENCIES_LIBRARY_DIRS ${ZLIB_LIBRARY_DIRS})
352 list(APPEND DEPENDENCIES_LINK_OPTIONS ${ZLIB_LDFLAGS_OTHER})
353 list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${ZLIB_LDFLAGS})
354 message(STATUS "Using system-installed zlib")
355 else()
356 set(BUILD_TESTING OFF CACHE BOOL "aaaaaa" FORCE)
357 set(BUILD_PROGRAMS OFF CACHE BOOL "aaa" FORCE)
358 set(BUILD_EXAMPLES OFF CACHE BOOL "a" FORCE)
359 set(ENABLE_EXTERNAL_LIBS OFF CACHE BOOL "come on" FORCE)
360 set(ENABLE_MPEG OFF CACHE BOOL "come on" FORCE)
361 set(ZLIB_BUILD_EXAMPLES OFF CACHE BOOL "come on" FORCE)
362 add_subdirectory(extern/zlib EXCLUDE_FROM_ALL)
363 list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/zlib ${CMAKE_CURRENT_BINARY_DIR}/extern/zlib)
364 list(APPEND DEPENDENCIES_LIBRARIES zlibstatic)
365 message(STATUS "Using vendored zlib")
366 endif()
367
368 if (USE_SDL2)
369 if (SYSTEM_SDL2)
370 if (PKG_CONFIG_FOUND)
371 pkg_check_modules(SDL2 sdl2>=${SYSTEM_SDL_MIN_VER})
372 if (SDL2_FOUND)
373 list(APPEND DEPENDENCIES_DEFINES HAVE_SDL2)
374 list(APPEND DEPENDENCIES_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS})
375 list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${SDL2_CFLAGS_OTHER})
376 list(APPEND DEPENDENCIES_LIBRARIES ${SDL2_LIBRARIES})
377 list(APPEND DEPENDENCIES_LIBRARY_DIRS ${SDL2_LIBRARY_DIRS})
378 list(APPEND DEPENDENCIES_LINK_OPTIONS ${SDL2_LDFLAGS_OTHER})
379 list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${SDL2_LDFLAGS})
380 endif()
381 endif()
382 if (NOT SDL2_FOUND)
383 find_package(SDL2 ${SYSTEM_SDL_MIN_VER} REQUIRED)
384 list(APPEND DEPENDENCIES_DEFINES HAVE_SDL2)
385 list(APPEND DEPENDENCIES_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
386 list(APPEND DEPENDENCIES_LIBRARIES ${SDL2_LIBRARY})
387 endif()
388 message(STATUS "Using system-installed SDL2")
389 else()
390 if (ANDROID AND NOT TERMUX)
391 set(SDL_SHARED ON CACHE BOOL "Force no dynamically-linked SDL" FORCE)
392 set(SDL_STATIC OFF CACHE BOOL "Force statically-linked SDL" FORCE)
393 else()
394 set(SDL_SHARED OFF CACHE BOOL "Force no dynamically-linked SDL" FORCE)
395 set(SDL_STATIC ON CACHE BOOL "Force statically-linked SDL" FORCE)
396 endif()
397 # https://github.com/libsdl-org/SDL/issues/5535
398 # disable PipeWire support due to an unfixable bug:
399 # Looks like their headers have a C90 violation... I imagine they're probably on C99 so not the craziest bug in the world. Definitely file this at the PipeWire repository as well so they know this is out there.
400 set(SDL_PIPEWIRE OFF CACHE BOOL "Use Pipewire audio" FORCE)
401
402 # https://github.com/libsdl-org/SDL/issues/1481
403 # On 2014-06-22 17:15:50 +0000, Sam Lantinga wrote:
404 # If you link SDL statically, you also need to define HAVE_LIBC so it builds with the C runtime that your application uses.
405 # This should probably go in a FAQ.
406 set(SDL_LIBC ON CACHE BOOL "Tell SDL that we want it to use our C runtime (required for proper static linking)" FORCE)
407
408 # https://github.com/tildearrow/furnace/issues/1237
409 # enabling this will result in SDL finding the Direct3D headers, forcing _WIN32_WINNT to an undesirable value (which makes the Wine headers define GetTickCount64)
410 if (SUPPORT_XP)
411 set(SDL_RENDER_D3D OFF CACHE BOOL "Enable the Direct3D render driver" FORCE)
412 endif()
413
414 CHECK_INCLUDE_FILE(GLES/gl.h GLES_GL_FOUND)
415 if (NOT GLES_GL_FOUND AND NOT USE_GLES)
416 set(SDL_OPENGLES OFF CACHE BOOL "Enable OpenGL ES" FORCE)
417 endif()
418
419 add_subdirectory(extern/SDL EXCLUDE_FROM_ALL)
420 list(APPEND DEPENDENCIES_DEFINES HAVE_SDL2)
421 list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/SDL/include)
422 if (ANDROID AND NOT TERMUX)
423 list(APPEND DEPENDENCIES_LIBRARIES SDL2)
424 else()
425 list(APPEND DEPENDENCIES_LIBRARIES SDL2-static)
426 endif()
427 # Work around add_subdirectory'd SDL not propagating HAVE_LIBC to MSVC furnace build
428 if (MSVC)
429 list(APPEND DEPENDENCIES_COMPILE_OPTIONS "/DHAVE_LIBC")
430 endif()
431 if (WIN32)
432 list(APPEND DEPENDENCIES_LIBRARIES SDL2main)
433 endif()
434 message(STATUS "Using vendored SDL2")
435 endif()
436 else()
437 message(STATUS "Not using SDL2")
438 if (BUILD_GUI)
439 message(FATAL_ERROR "SDL2 is required in order to build with GUI! Disable BUILD_GUI otherwise.")
440 endif()
441 endif()
442
443 set(AUDIO_SOURCES
444 src/audio/abstract.cpp
445 src/audio/midi.cpp
446 src/audio/pipe.cpp
447 )
448
449 if (USE_SDL2)
450 list(APPEND AUDIO_SOURCES src/audio/sdlAudio.cpp)
451 endif()
452
453 if (WITH_JACK)
454 find_package(PkgConfig REQUIRED)
455 pkg_check_modules(JACK REQUIRED jack)
456 list(APPEND AUDIO_SOURCES extern/weakjack/weak_libjack.c)
457 list(APPEND AUDIO_SOURCES src/audio/jack.cpp)
458 list(APPEND DEPENDENCIES_INCLUDE_DIRS ${JACK_INCLUDE_DIRS})
459 list(APPEND DEPENDENCIES_DEFINES HAVE_JACK)
460 list(APPEND DEPENDENCIES_DEFINES USE_WEAK_JACK)
461 #list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${JACK_CFLAGS_OTHER})
462 #list(APPEND DEPENDENCIES_LIBRARIES ${JACK_LIBRARIES})
463 #list(APPEND DEPENDENCIES_LIBRARY_DIRS ${JACK_LIBRARY_DIRS})
464 #list(APPEND DEPENDENCIES_LINK_OPTIONS ${JACK_LDFLAGS_OTHER})
465 #list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${JACK_LDFLAGS})
466 message(STATUS "Building with JACK support")
467 else()
468 message(STATUS "Building without JACK support")
469 endif()
470
471 if (WITH_PORTAUDIO)
472 list(APPEND AUDIO_SOURCES src/audio/pa.cpp)
473 message(STATUS "Building with PortAudio")
474 list(APPEND DEPENDENCIES_DEFINES HAVE_PA)
475 else()
476 message(STATUS "Building without PortAudio")
477 endif()
478
479 if (USE_RTMIDI)
480 list(APPEND AUDIO_SOURCES src/audio/rtmidi.cpp)
481 message(STATUS "Building with RtMidi")
482 list(APPEND DEPENDENCIES_DEFINES HAVE_RTMIDI)
483 else()
484 message(STATUS "Building without RtMidi")
485 endif()
486
487 set(ENGINE_SOURCES
488 src/log.cpp
489 src/baseutils.cpp
490 src/fileutils.cpp
491 src/utfutils.cpp
492
493 extern/itcompress/compression.c
494
495 extern/SAASound/src/SAAAmp.cpp
496 extern/SAASound/src/SAADevice.cpp
497 extern/SAASound/src/SAAEnv.cpp
498 extern/SAASound/src/SAAFreq.cpp
499 extern/SAASound/src/SAAImpl.cpp
500 extern/SAASound/src/SAANoise.cpp
501 extern/SAASound/src/SAASndC.cpp
502 extern/SAASound/src/SAASound.cpp
503
504 extern/vgsound_emu-modified/vgsound_emu/src/core/vox/vox.cpp
505
506 extern/vgsound_emu-modified/vgsound_emu/src/es550x/es550x.cpp
507 extern/vgsound_emu-modified/vgsound_emu/src/es550x/es550x_alu.cpp
508 extern/vgsound_emu-modified/vgsound_emu/src/es550x/es550x_filter.cpp
509 extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5504.cpp
510 extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5505.cpp
511 extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5506.cpp
512
513 extern/vgsound_emu-modified/vgsound_emu/src/k005289/k005289.cpp
514
515 extern/vgsound_emu-modified/vgsound_emu/src/k007232/k007232.cpp
516
517 extern/vgsound_emu-modified/vgsound_emu/src/k053260/k053260.cpp
518
519 extern/vgsound_emu-modified/vgsound_emu/src/msm6295/msm6295.cpp
520
521 extern/vgsound_emu-modified/vgsound_emu/src/n163/n163.cpp
522
523 extern/vgsound_emu-modified/vgsound_emu/src/scc/scc.cpp
524
525 extern/vgsound_emu-modified/vgsound_emu/src/vrcvi/vrcvi.cpp
526
527 extern/vgsound_emu-modified/vgsound_emu/src/x1_010/x1_010.cpp
528
529 extern/adpcm/bs_codec.c
530 extern/adpcm/oki_codec.c
531 extern/adpcm/yma_codec.c
532 extern/adpcm/ymb_codec.c
533 extern/adpcm/ymz_codec.c
534
535 extern/adpcm-xq-s/adpcm-lib.c
536
537 extern/opn/ym3438.c
538 extern/Nuked-PSG/ympsg.c
539 extern/opm/opm.c
540 extern/Nuked-OPLL/opll.c
541 extern/opl/opl3.c
542 extern/YM3812-LLE/fmopl2.c
543 extern/YMF262-LLE/fmopl3.c
544 extern/YMF276-LLE/fmopn2.c
545 extern/ESFMu/esfm.c
546 extern/ESFMu/esfm_registers.c
547 extern/emu2413/emu2413.c
548 extern/YM2608-LLE/fmopna_2608.c
549 extern/YM2608-LLE/fmopna_2610.c
550 extern/YM2608-LLE/fmopna_2612.c
551
552 extern/pwrnoise/pwrnoise.c
553
554 extern/blip_buf/blip_buf.c
555
556 src/pch.cpp
557
558 src/engine/platform/sound/sn76496.cpp
559 src/engine/platform/sound/ay8910.cpp
560 src/engine/platform/sound/saa1099.cpp
561 src/engine/platform/sound/namco.cpp
562 src/engine/platform/sound/segapcm.cpp
563 src/engine/platform/sound/gb/apu.c
564 src/engine/platform/sound/gb/timing.c
565 src/engine/platform/sound/pce_psg.cpp
566 src/engine/platform/sound/nes/apu.cpp
567 src/engine/platform/sound/nes/fds.cpp
568 src/engine/platform/sound/nes/mmc5.cpp
569 src/engine/platform/sound/vera_psg.c
570 src/engine/platform/sound/vera_pcm.c
571 src/engine/platform/sound/ymf278b/ymf278.cpp
572
573 src/engine/platform/sound/atomicssg/ssg.c
574
575 src/engine/platform/sound/nes_nsfplay/5e01_apu.cpp
576 src/engine/platform/sound/nes_nsfplay/5e01_dmc.cpp
577 src/engine/platform/sound/nes_nsfplay/nes_apu.cpp
578 src/engine/platform/sound/nes_nsfplay/nes_dmc.cpp
579 src/engine/platform/sound/nes_nsfplay/nes_fds.cpp
580 src/engine/platform/sound/nes_nsfplay/nes_mmc5.cpp
581 src/engine/platform/sound/nes_nsfplay/nes_n106.cpp
582 src/engine/platform/sound/nes_nsfplay/nes_vrc6.cpp
583
584 src/engine/platform/sound/c64/sid.cc
585 src/engine/platform/sound/c64/voice.cc
586 src/engine/platform/sound/c64/wave.cc
587 src/engine/platform/sound/c64/envelope.cc
588 src/engine/platform/sound/c64/filter.cc
589 src/engine/platform/sound/c64/extfilt.cc
590 src/engine/platform/sound/c64/pot.cc
591 src/engine/platform/sound/c64/version.cc
592
593 src/engine/platform/sound/c64/wave6581_PS_.cc
594 src/engine/platform/sound/c64/wave6581_PST.cc
595 src/engine/platform/sound/c64/wave6581_P_T.cc
596 src/engine/platform/sound/c64/wave6581__ST.cc
597 src/engine/platform/sound/c64/wave8580_PS_.cc
598 src/engine/platform/sound/c64/wave8580_PST.cc
599 src/engine/platform/sound/c64/wave8580_P_T.cc
600 src/engine/platform/sound/c64/wave8580__ST.cc
601
602 src/engine/platform/sound/c64_fp/array.cpp
603 src/engine/platform/sound/c64_fp/Dac.cpp
604 src/engine/platform/sound/c64_fp/EnvelopeGenerator.cpp
605 src/engine/platform/sound/c64_fp/ExternalFilter.cpp
606 src/engine/platform/sound/c64_fp/Filter6581.cpp
607 src/engine/platform/sound/c64_fp/Filter8580.cpp
608 src/engine/platform/sound/c64_fp/Filter.cpp
609 src/engine/platform/sound/c64_fp/FilterModelConfig6581.cpp
610 src/engine/platform/sound/c64_fp/FilterModelConfig8580.cpp
611 src/engine/platform/sound/c64_fp/FilterModelConfig.cpp
612 src/engine/platform/sound/c64_fp/Integrator6581.cpp
613 src/engine/platform/sound/c64_fp/Integrator8580.cpp
614 src/engine/platform/sound/c64_fp/OpAmp.cpp
615 src/engine/platform/sound/c64_fp/SID.cpp
616 src/engine/platform/sound/c64_fp/Spline.cpp
617 src/engine/platform/sound/c64_fp/WaveformCalculator.cpp
618 src/engine/platform/sound/c64_fp/WaveformGenerator.cpp
619 src/engine/platform/sound/c64_fp/resample/SincResampler.cpp
620
621 src/engine/platform/sound/c64_d/dsid.c
622
623 src/engine/platform/sound/tia/AudioChannel.cpp
624 src/engine/platform/sound/tia/Audio.cpp
625
626 src/engine/platform/sound/ymfm/ymfm_adpcm.cpp
627 src/engine/platform/sound/ymfm/ymfm_opl.cpp
628 src/engine/platform/sound/ymfm/ymfm_opm.cpp
629 src/engine/platform/sound/ymfm/ymfm_opn.cpp
630 src/engine/platform/sound/ymfm/ymfm_opz.cpp
631 src/engine/platform/sound/ymfm/ymfm_pcm.cpp
632 src/engine/platform/sound/ymfm/ymfm_ssg.cpp
633
634 src/engine/platform/sound/lynx/Mikey.cpp
635
636 src/engine/platform/sound/pokey/mzpokeysnd.c
637 src/engine/platform/sound/pokey/AltASAP.cpp
638
639 src/engine/platform/sound/qsound.c
640
641 src/engine/platform/sound/swan.c
642 src/engine/platform/sound/swan_mdfn.cpp
643
644 src/engine/platform/sound/su.cpp
645
646 src/engine/platform/sound/vic20sound.c
647
648 src/engine/platform/sound/ymz280b.cpp
649
650 src/engine/platform/sound/vsu.cpp
651
652 src/engine/platform/sound/t6w28/T6W28_Apu.cpp
653
654 src/engine/platform/sound/rf5c68.cpp
655
656 src/engine/platform/sound/oki/msm5232.cpp
657 src/engine/platform/sound/oki/okim6258.cpp
658
659 src/engine/platform/sound/snes/SPC_DSP.cpp
660
661 src/engine/platform/sound/ga20/iremga20.cpp
662
663 src/engine/platform/sound/sm8521.c
664
665 src/engine/platform/sound/supervision.c
666
667 src/engine/platform/sound/upd1771.cpp
668
669 src/engine/platform/sound/d65modified.c
670
671 src/engine/platform/sound/ted-sound.c
672
673 src/engine/platform/sound/c140_c219.c
674
675 src/engine/platform/sound/dave/dave.cpp
676
677 src/engine/platform/sound/nds.cpp
678
679 src/engine/platform/sound/sid2/envelope.cc
680 src/engine/platform/sound/sid2/filter.cc
681 src/engine/platform/sound/sid2/sid.cc
682 src/engine/platform/sound/sid2/version.cc
683 src/engine/platform/sound/sid2/voice.cc
684 src/engine/platform/sound/sid2/wave8580_PS_.cc
685 src/engine/platform/sound/sid2/wave8580_PST.cc
686 src/engine/platform/sound/sid2/wave8580_P_T.cc
687 src/engine/platform/sound/sid2/wave8580__ST.cc
688 src/engine/platform/sound/sid2/wave.cc
689
690 src/engine/platform/sound/sid3.c
691
692 src/engine/platform/oplAInterface.cpp
693 src/engine/platform/ym2608Interface.cpp
694 src/engine/platform/ym2610Interface.cpp
695
696 src/engine/fileOps/fileOpsCommon.cpp
697 src/engine/fileOps/dmf.cpp
698 src/engine/fileOps/fc.cpp
699 src/engine/fileOps/ftm.cpp
700 src/engine/fileOps/fur.cpp
701 src/engine/fileOps/it.cpp
702 src/engine/fileOps/mod.cpp
703 src/engine/fileOps/s3m.cpp
704 src/engine/fileOps/text.cpp
705 src/engine/fileOps/tfm.cpp
706 src/engine/fileOps/xm.cpp
707
708 src/engine/fileOps/p.cpp
709 src/engine/fileOps/p86.cpp
710 src/engine/fileOps/pdx.cpp
711 src/engine/fileOps/ppc.cpp
712 src/engine/fileOps/pps.cpp
713 src/engine/fileOps/pvi.cpp
714 src/engine/fileOps/pzi.cpp
715
716 src/engine/brrUtils.c
717 src/engine/safeReader.cpp
718 src/engine/safeWriter.cpp
719 src/engine/workPool.cpp
720 src/engine/cmdStream.cpp
721 src/engine/cmdStreamOps.cpp
722 src/engine/config.cpp
723 src/engine/configEngine.cpp
724 src/engine/dispatchContainer.cpp
725 src/engine/engine.cpp
726 src/engine/export.cpp
727 src/engine/exportDef.cpp
728 src/engine/fileOpsIns.cpp
729 src/engine/fileOpsSample.cpp
730 src/engine/filter.cpp
731 src/engine/instrument.cpp
732 src/engine/macroInt.cpp
733 src/engine/pattern.cpp
734 src/engine/pitchTable.cpp
735 src/engine/playback.cpp
736 src/engine/sample.cpp
737 src/engine/song.cpp
738 src/engine/sysDef.cpp
739 src/engine/wavetable.cpp
740 src/engine/waveSynth.cpp
741 src/engine/wavOps.cpp
742 src/engine/vgmOps.cpp
743
744 src/engine/platform/abstract.cpp
745 src/engine/platform/genesis.cpp
746 src/engine/platform/genesisext.cpp
747 src/engine/platform/sms.cpp
748 src/engine/platform/opll.cpp
749 src/engine/platform/gb.cpp
750 src/engine/platform/pce.cpp
751 src/engine/platform/mmc5.cpp
752 src/engine/platform/nes.cpp
753 src/engine/platform/c64.cpp
754 src/engine/platform/arcade.cpp
755 src/engine/platform/tx81z.cpp
756 src/engine/platform/ym2203.cpp
757 src/engine/platform/ym2203ext.cpp
758 src/engine/platform/ym2608.cpp
759 src/engine/platform/ym2608ext.cpp
760 src/engine/platform/ym2610.cpp
761 src/engine/platform/ym2610ext.cpp
762 src/engine/platform/ym2610b.cpp
763 src/engine/platform/ym2610bext.cpp
764 src/engine/platform/ay.cpp
765 src/engine/platform/ay8930.cpp
766 src/engine/platform/opl.cpp
767 src/engine/platform/fds.cpp
768 src/engine/platform/tia.cpp
769 src/engine/platform/saa.cpp
770 src/engine/platform/amiga.cpp
771 src/engine/platform/msm5232.cpp
772 src/engine/platform/msm6258.cpp
773 src/engine/platform/msm6295.cpp
774 src/engine/platform/pcspkr.cpp
775 src/engine/platform/segapcm.cpp
776 src/engine/platform/qsound.cpp
777 src/engine/platform/x1_010.cpp
778 src/engine/platform/pokey.cpp
779 src/engine/platform/lynx.cpp
780 src/engine/platform/su.cpp
781 src/engine/platform/swan.cpp
782 src/engine/platform/t6w28.cpp
783 src/engine/platform/vb.cpp
784 src/engine/platform/vera.cpp
785 src/engine/platform/zxbeeper.cpp
786 src/engine/platform/zxbeeperquadtone.cpp
787 src/engine/platform/bubsyswsg.cpp
788 src/engine/platform/n163.cpp
789 src/engine/platform/pet.cpp
790 src/engine/platform/pokemini.cpp
791 src/engine/platform/pong.cpp
792 src/engine/platform/vic20.cpp
793 src/engine/platform/vrc6.cpp
794 src/engine/platform/es5506.cpp
795 src/engine/platform/scc.cpp
796 src/engine/platform/ymz280b.cpp
797 src/engine/platform/namcowsg.cpp
798 src/engine/platform/rf5c68.cpp
799 src/engine/platform/snes.cpp
800 src/engine/platform/k007232.cpp
801 src/engine/platform/ga20.cpp
802 src/engine/platform/sm8521.cpp
803 src/engine/platform/supervision.cpp
804 src/engine/platform/scvtone.cpp
805 src/engine/platform/pv1000.cpp
806 src/engine/platform/k053260.cpp
807 src/engine/platform/ted.cpp
808 src/engine/platform/c140.cpp
809 src/engine/platform/esfm.cpp
810 src/engine/platform/powernoise.cpp
811 src/engine/platform/dave.cpp
812 src/engine/platform/gbadma.cpp
813 src/engine/platform/gbaminmod.cpp
814 src/engine/platform/nds.cpp
815 src/engine/platform/bifurcator.cpp
816 src/engine/platform/sid2.cpp
817 src/engine/platform/sid3.cpp
818 src/engine/platform/pcmdac.cpp
819 src/engine/platform/dummy.cpp
820
821 src/engine/export/abstract.cpp
822 src/engine/export/amigaValidation.cpp
823 src/engine/export/sapr.cpp
824 src/engine/export/tiuna.cpp
825 src/engine/export/zsm.cpp
826 src/engine/export/ipod.cpp
827 src/engine/export/grub.cpp
828
829 src/engine/effect/abstract.cpp
830 src/engine/effect/dummy.cpp
831 )
832
833 if (USE_SNDFILE)
834 list(APPEND ENGINE_SOURCES src/engine/sfWrapper.cpp)
835 endif()
836
837 if (WIN32)
838 list(APPEND ENGINE_SOURCES src/utfutils.cpp)
839 list(APPEND ENGINE_SOURCES src/engine/winStuff.cpp)
840 list(APPEND ENGINE_SOURCES res/furnace.rc)
841 endif()
842
843 if (APPLE)
844 if (CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.12)
845 list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/macports-legacy-support/include)
846 list(APPEND ENGINE_SOURCES extern/macports-legacy-support/src/time.c)
847 endif()
848 endif()
849
850 set(CLI_SOURCES
851 src/cli/cli.cpp
852 )
853
854 set(GUI_SOURCES
855 extern/imgui_patched/imgui.cpp
856 extern/imgui_patched/imgui_draw.cpp
857 extern/imgui_patched/imgui_tables.cpp
858 extern/imgui_patched/imgui_widgets.cpp
859 extern/imgui_patched/backends/imgui_impl_sdl2.cpp
860 extern/imgui_software_renderer/imgui_sw.cpp
861 extern/imgui_patched/misc/cpp/imgui_stdlib.cpp
862 extern/igfd/ImGuiFileDialog.cpp
863
864 src/gui/plot_nolerp.cpp
865
866 src/gui/render.cpp
867 src/gui/render/abstract.cpp
868 src/gui/render/renderSoftware.cpp
869
870 src/gui/font_exo.cpp
871 src/gui/font_liberationSans.cpp
872 src/gui/font_mononoki.cpp
873 src/gui/font_plexMono.cpp
874 src/gui/font_plexSans.cpp
875 src/gui/font_plexSansJP.cpp
876 src/gui/font_plexSansKR.cpp
877 src/gui/font_proggyClean.cpp
878 src/gui/font_ptMono.cpp
879 src/gui/font_unifont.cpp
880 src/gui/font_icon.cpp
881 src/gui/font_furicon.cpp
882 src/gui/fonts.cpp
883 src/gui/fontzlib.cpp
884
885 src/gui/image_icon.cpp
886 src/gui/image.cpp
887
888 src/gui/debug.cpp
889 src/gui/fileDialog.cpp
890
891 src/gui/intConst.cpp
892 src/gui/guiConst.cpp
893
894 src/gui/about.cpp
895 src/gui/channels.cpp
896 src/gui/chanOsc.cpp
897 src/gui/clock.cpp
898 src/gui/compatFlags.cpp
899 src/gui/csPlayer.cpp
900 src/gui/cursor.cpp
901 src/gui/dataList.cpp
902 src/gui/debugWindow.cpp
903 src/gui/doAction.cpp
904 src/gui/editing.cpp
905 src/gui/editControls.cpp
906 src/gui/effectList.cpp
907 src/gui/exportOptions.cpp
908 src/gui/findReplace.cpp
909 src/gui/fmPreview.cpp
910 src/gui/gradient.cpp
911 src/gui/grooves.cpp
912 src/gui/insEdit.cpp
913 src/gui/log.cpp
914 src/gui/memory.cpp
915 src/gui/mixer.cpp
916 src/gui/midiMap.cpp
917 src/gui/newSong.cpp
918 src/gui/commandPalette.cpp
919 src/gui/orders.cpp
920 src/gui/osc.cpp
921 src/gui/patManager.cpp
922 src/gui/pattern.cpp
923 src/gui/piano.cpp
924 src/gui/presets.cpp
925 src/gui/regView.cpp
926 src/gui/sampleEdit.cpp
927 src/gui/scaling.cpp
928 src/gui/settings.cpp
929 src/gui/songInfo.cpp
930 src/gui/songNotes.cpp
931 src/gui/speed.cpp
932 src/gui/spoiler.cpp
933 src/gui/stats.cpp
934 src/gui/subSongs.cpp
935 src/gui/sysConf.cpp
936 src/gui/sysEx.cpp
937 src/gui/sysManager.cpp
938 src/gui/sysMiscInfo.cpp
939 src/gui/sysPicker.cpp
940 src/gui/tutorial.cpp
941 src/gui/userPresets.cpp
942 src/gui/util.cpp
943 src/gui/waveEdit.cpp
944 src/gui/volMeter.cpp
945 src/gui/xyOsc.cpp
946 src/gui/gui.cpp
947 )
948
949 if (NOT NO_INTRO)
950 list(APPEND GUI_SOURCES src/gui/introTune.cpp)
951 list(APPEND GUI_SOURCES src/gui/intro.cpp)
952 list(APPEND GUI_SOURCES
953 src/gui/image_talogo.cpp
954 src/gui/image_tachip.cpp
955 src/gui/image_logo.cpp
956 src/gui/image_wordmark.cpp
957 src/gui/image_introbg.cpp
958 src/gui/image_pat.cpp
959 )
960 else()
961 list(APPEND DEPENDENCIES_DEFINES NO_INTRO)
962 endif()
963
964 if (WIN32 AND NOT SUPPORT_XP)
965 list(APPEND GUI_SOURCES extern/nfd-modified/src/nfd_common.cpp)
966 list(APPEND GUI_SOURCES extern/nfd-modified/src/nfd_win.cpp)
967 endif()
968
969 if (USE_FREETYPE)
970 list(APPEND GUI_SOURCES extern/imgui_patched/misc/freetype/imgui_freetype.cpp)
971 endif()
972
973 if (APPLE)
974 list(APPEND GUI_SOURCES extern/nfd-modified/src/nfd_common.cpp)
975 list(APPEND GUI_SOURCES src/gui/macstuff.m)
976 list(APPEND GUI_SOURCES extern/nfd-modified/src/nfd_cocoa.mm)
977 endif()
978
979 if (WITH_RENDER_SDL)
980 list(APPEND GUI_SOURCES src/gui/render/renderSDL.cpp)
981 list(APPEND GUI_SOURCES extern/imgui_patched/backends/imgui_impl_sdlrenderer2.cpp)
982 list(APPEND DEPENDENCIES_DEFINES HAVE_RENDER_SDL)
983 message(STATUS "UI render backend: SDL_Renderer")
984 endif()
985
986 if (WITH_RENDER_OPENGL)
987 list(APPEND GUI_SOURCES src/gui/render/renderGL.cpp)
988 list(APPEND GUI_SOURCES extern/imgui_patched/backends/imgui_impl_opengl3.cpp)
989 list(APPEND DEPENDENCIES_DEFINES HAVE_RENDER_GL)
990 if (USE_GLES)
991 list(APPEND DEPENDENCIES_DEFINES USE_GLES)
992 list(APPEND DEPENDENCIES_DEFINES IMGUI_IMPL_OPENGL_ES2)
993 endif()
994 if (WIN32)
995 list(APPEND DEPENDENCIES_LIBRARIES opengl32)
996 elseif(APPLE)
997 list(APPEND DEPENDENCIES_LIBRARIES "-framework OpenGL")
998 elseif(USE_GLES)
999 list(APPEND DEPENDENCIES_LIBRARIES GLESv2)
1000 else()
1001 list(APPEND DEPENDENCIES_LIBRARIES GL)
1002 endif()
1003 if (USE_GLES)
1004 message(STATUS "UI render backend: OpenGL ES 2.0")
1005 else()
1006 message(STATUS "UI render backend: OpenGL 3.0/2.0")
1007 endif()
1008 endif()
1009
1010 if (WITH_RENDER_OPENGL1)
1011 list(APPEND GUI_SOURCES src/gui/render/renderGL1.cpp)
1012 list(APPEND GUI_SOURCES extern/imgui_patched/backends/imgui_impl_opengl2.cpp)
1013 list(APPEND DEPENDENCIES_DEFINES HAVE_RENDER_GL1)
1014 if (NOT WITH_RENDER_OPENGL)
1015 if (WIN32)
1016 list(APPEND DEPENDENCIES_LIBRARIES opengl32)
1017 else()
1018 list(APPEND DEPENDENCIES_LIBRARIES GL)
1019 endif()
1020 endif()
1021 message(STATUS "UI render backend: OpenGL 1.1")
1022 endif()
1023
1024 if (WITH_RENDER_DX11)
1025 if (WIN32)
1026 if (SUPPORT_XP)
1027 message(FATAL_ERROR "SUPPORT_XP is on. cannot enable DirectX 11 backend.")
1028 else()
1029 list(APPEND GUI_SOURCES src/gui/render/renderDX11.cpp)
1030 list(APPEND GUI_SOURCES extern/imgui_patched/backends/imgui_impl_dx11.cpp)
1031 list(APPEND DEPENDENCIES_DEFINES HAVE_RENDER_DX11)
1032 list(APPEND DEPENDENCIES_LIBRARIES d3d11 dxgi)
1033 message(STATUS "UI render backend: DirectX 11")
1034 endif()
1035 else()
1036 message(FATAL_ERROR "DirectX 11 render backend only for Windows!")
1037 endif()
1038 endif()
1039
1040 if (WITH_RENDER_DX9)
1041 if (WIN32)
1042 list(APPEND GUI_SOURCES src/gui/render/renderDX9.cpp)
1043 list(APPEND GUI_SOURCES extern/imgui_patched/backends/imgui_impl_dx9.cpp)
1044 list(APPEND DEPENDENCIES_DEFINES HAVE_RENDER_DX9)
1045 list(APPEND DEPENDENCIES_LIBRARIES d3d9)
1046 message(STATUS "UI render backend: DirectX 9")
1047 else()
1048 message(FATAL_ERROR "DirectX 9 render backend only for Windows!")
1049 endif()
1050 endif()
1051
1052 if (WITH_RENDER_METAL)
1053 if (APPLE)
1054 list(APPEND GUI_SOURCES src/gui/render/renderMetal.mm)
1055 list(APPEND GUI_SOURCES extern/imgui_patched/backends/imgui_impl_metal.mm)
1056 list(APPEND DEPENDENCIES_DEFINES HAVE_RENDER_METAL)
1057 list(APPEND DEPENDENCIES_LIBRARIES "-framework Metal")
1058 list(APPEND DEPENDENCIES_LIBRARIES "-framework MetalKit")
1059 message(STATUS "UI render backend: Metal")
1060 else()
1061 message(FATAL_ERROR "Metal render backend only for Apple operating systems!")
1062 endif()
1063 endif()
1064
1065 if (NOT WIN32 AND NOT APPLE)
1066 CHECK_INCLUDE_FILE(sys/io.h SYS_IO_FOUND)
1067 CHECK_INCLUDE_FILE(linux/input.h LINUX_INPUT_FOUND)
1068 CHECK_INCLUDE_FILE(linux/kd.h LINUX_KD_FOUND)
1069 if (SYS_IO_FOUND)
1070 try_compile(HAVE_INOUTB ${CMAKE_BINARY_DIR}/check SOURCES ${CMAKE_SOURCE_DIR}/src/check/check_sysIO.c)
1071 if (HAVE_INOUTB)
1072 list(APPEND DEPENDENCIES_DEFINES HAVE_SYS_IO)
1073 message(STATUS "PC speaker output: outb()")
1074 else()
1075 message(STATUS "sys/io.h found but inb()/outb() not present")
1076 endif()
1077 endif()
1078 if (LINUX_INPUT_FOUND)
1079 list(APPEND DEPENDENCIES_DEFINES HAVE_LINUX_INPUT)
1080 message(STATUS "PC speaker output: evdev")
1081 endif()
1082 if (LINUX_KD_FOUND)
1083 list(APPEND DEPENDENCIES_DEFINES HAVE_LINUX_KD)
1084 message(STATUS "PC speaker output: KIOCSOUND")
1085 endif()
1086 endif()
1087
1088 if (NOT WIN32)
1089 try_compile(HAVE_DIRENT_TYPE ${CMAKE_BINARY_DIR}/check SOURCES ${CMAKE_SOURCE_DIR}/src/check/check_dirent_type.c)
1090 if (HAVE_DIRENT_TYPE)
1091 list(APPEND DEPENDENCIES_DEFINES HAVE_DIRENT_TYPE)
1092 endif()
1093 endif()
1094
1095 if (WITH_LOCALE)
1096 if (HAVE_SETLOCALE)
1097 list(APPEND DEPENDENCIES_DEFINES HAVE_SETLOCALE)
1098 message(STATUS "setlocale() found")
1099 else()
1100 if (NOT USE_MOMO)
1101 message(FATAL_ERROR "setlocale() is not defined! This means the C library in your system does not support locale at all. Try enabling USE_MOMO.")
1102 else()
1103 message(STATUS "setlocale() is not defined")
1104 endif()
1105 endif()
1106 if (USE_MOMO)
1107 list(APPEND ENGINE_SOURCES src/momo/momo.c)
1108 list(APPEND DEPENDENCIES_DEFINES HAVE_LOCALE)
1109 list(APPEND DEPENDENCIES_DEFINES HAVE_MOMO)
1110 list(APPEND DEPENDENCIES_INCLUDE_DIRS src/momo)
1111 message(STATUS "Using libintl (Momo)")
1112 else()
1113 if ("${CMAKE_VERSION}" VERSION_LESS "3.2")
1114 message(FATAL_ERROR "CMake 3.2 or later required for locale support.")
1115 else()
1116 if (NOT Intl_FOUND)
1117 message(FATAL_ERROR "Could not find libintl! Try enabling USE_MOMO.")
1118 endif()
1119 list(APPEND DEPENDENCIES_DEFINES HAVE_LOCALE)
1120 list(APPEND DEPENDENCIES_DEFINES GNULIB_overrides_sprintf)
1121 list(APPEND DEPENDENCIES_INCLUDE_DIRS ${Intl_INCLUDE_DIRS})
1122 list(APPEND DEPENDENCIES_LIBRARIES ${Intl_LIBRARIES})
1123 message(STATUS "Using libintl (system)")
1124 endif()
1125 endif()
1126 endif()
1127
1128 set(USED_SOURCES ${ENGINE_SOURCES} ${AUDIO_SOURCES} ${CLI_SOURCES} src/main.cpp)
1129
1130 if (USE_BACKWARD)
1131 list(APPEND USED_SOURCES src/backtrace.cpp)
1132 if (WIN32)
1133 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
1134 include(CheckCXXCompilerFlag)
1135 check_cxx_compiler_flag(-gcodeview GCC_CODEVIEW)
1136 if (GCC_CODEVIEW OR FORCE_CODEVIEW)
1137 set(CMAKE_EXE_LINKER_FLAGS "-Wl,--pdb= ")
1138 add_compile_options(-gcodeview)
1139 message(STATUS "Enabling -gcodeview flag for backward-cpp.")
1140 else()
1141 message(WARNING "Could not enable -gcodeview! backward-cpp will not work.")
1142 endif()
1143 list(APPEND DEPENDENCIES_LIBRARIES dbghelp psapi)
1144 endif()
1145 endif()
1146 find_library(EXECINFO_IS_LIBRARY execinfo)
1147 if (EXECINFO_IS_LIBRARY)
1148 list(APPEND DEPENDENCIES_LIBRARIES execinfo)
1149 endif()
1150 message(STATUS "Using backward-cpp")
1151 else()
1152 message(STATUS "Not using backward-cpp")
1153 endif()
1154
1155 if (BUILD_GUI)
1156 list(APPEND USED_SOURCES ${GUI_SOURCES})
1157 list(APPEND DEPENDENCIES_INCLUDE_DIRS
1158 extern/imgui_patched
1159 extern/imgui_patched/backends
1160 extern/imgui_software_renderer
1161 extern/igfd
1162 )
1163 if (WIN32 OR APPLE)
1164 list(APPEND DEPENDENCIES_INCLUDE_DIRS
1165 extern/nfd-modified/src/include
1166 )
1167 endif()
1168 list(APPEND DEPENDENCIES_DEFINES HAVE_GUI)
1169 message(STATUS "Building GUI")
1170 else()
1171 message(STATUS "Building headless")
1172 endif()
1173
1174 if (WIN32)
1175 list(APPEND DEPENDENCIES_LIBRARIES shlwapi)
1176 if (NOT MSVC)
1177 list(APPEND DEPENDENCIES_LIBRARIES -static)
1178 endif()
1179 elseif (APPLE)
1180 find_library(COCOA Cocoa REQUIRED)
1181 list(APPEND DEPENDENCIES_LIBRARIES ${COCOA})
1182 else()
1183 list(APPEND DEPENDENCIES_LIBRARIES ${CMAKE_DL_LIBS})
1184 endif()
1185
1186 if (NOT MSVC)
1187 set(WARNING_FLAGS -Wall -Wextra -Wno-unused-parameter)
1188 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
1189 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0.0)
1190 # nothing
1191 else()
1192 list(APPEND WARNING_FLAGS -Wno-cast-function-type)
1193 endif()
1194 endif()
1195 if (WARNINGS_ARE_ERRORS)
1196 list(APPEND WARNING_FLAGS -Werror)
1197 endif()
1198 else()
1199 add_compile_options("/utf-8")
1200 set(WARNING_FLAGS /W2 /D_CRT_SECURE_NO_WARNINGS)
1201 list(APPEND WARNING_FLAGS
1202 /wd4244 # implicit type conversions
1203 /wd4305 # truncations
1204 /wd4309 # truncations of constant values
1205 )
1206 if (WARNINGS_ARE_ERRORS)
1207 list(APPEND WARNING_FLAGS /WX)
1208 endif()
1209 endif()
1210 # Nicer but cannot be narrowed down to just C++
1211 # target_compile_options(furnace PRIVATE ${WARNING_FLAGS})
1212 string(REPLACE ";" " " WARNING_FLAGS_STRING "${WARNING_FLAGS}")
1213 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS_STRING}")
1214 if (WARNINGS_ARE_ERRORS)
1215 message(STATUS
1216 "Treating all warnings in furnace's C++ code as errors! "
1217 "Please report any errors you encounter on the bug tracker."
1218 )
1219 endif()
1220
1221 if (NOT ANDROID OR TERMUX)
1222 if (NOT WIN32 AND NOT APPLE)
1223 if (NOT DONT_HAVE_GIT)
1224 add_custom_command(OUTPUT furnace.appdata.xml COMMAND res/make-appdata.sh ARGS ${CMAKE_SOURCE_DIR}/res/furnace.appdata.xml.in ${CMAKE_BINARY_DIR}/furnace.appdata.xml DEPENDS res/furnace.appdata.xml.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
1225 list(APPEND USED_SOURCES furnace.appdata.xml)
1226 endif()
1227 endif()
1228 endif()
1229
1230 if (WIN32 AND CONSOLE_SUBSYSTEM)
1231 list(APPEND DEPENDENCIES_DEFINES "TA_SUBSYSTEM_CONSOLE")
1232 endif()
1233
1234 if (MAKE_BUNDLE)
1235 set(FURNACE Furnace)
1236 else()
1237 set(FURNACE furnace)
1238 endif()
1239
1240 if(ANDROID AND NOT TERMUX)
1241 add_library(${FURNACE} SHARED ${USED_SOURCES})
1242 elseif(WIN32 AND NOT CONSOLE_SUBSYSTEM)
1243 add_executable(${FURNACE} WIN32 ${USED_SOURCES})
1244 else()
1245 add_executable(${FURNACE} ${USED_SOURCES})
1246 endif()
1247
1248 if (MAKE_BUNDLE AND NOT FORCE_APPLE_BIN)
1249 set_target_properties(${FURNACE} PROPERTIES
1250 MACOSX_BUNDLE True
1251 MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/Info.plist)
1252 endif()
1253
1254 target_include_directories(${FURNACE} SYSTEM PRIVATE ${DEPENDENCIES_INCLUDE_DIRS})
1255 target_compile_options(${FURNACE} PRIVATE ${DEPENDENCIES_COMPILE_OPTIONS})
1256 target_link_libraries(${FURNACE} PRIVATE ${DEPENDENCIES_LIBRARIES})
1257 if (PKG_CONFIG_FOUND AND (SYSTEM_FMT OR SYSTEM_LIBSNDFILE OR SYSTEM_ZLIB OR SYSTEM_SDL2 OR SYSTEM_RTMIDI OR WITH_JACK))
1258 if ("${CMAKE_VERSION}" VERSION_LESS "3.13")
1259 message(WARNING
1260 "CMake version is <3.13, using old pkg-config LDFLAGS. "
1261 "You may encounter linking problems with these!"
1262 )
1263 target_link_libraries(${FURNACE} PRIVATE ${DEPENDENCIES_LEGACY_LDFLAGS})
1264 else()
1265 target_link_directories(${FURNACE} PRIVATE ${DEPENDENCIES_LIBRARY_DIRS})
1266 target_link_options(${FURNACE} PRIVATE ${DEPENDENCIES_LINK_OPTIONS})
1267 endif()
1268 endif()
1269
1270 # why 3.16..... why not 3.0?
1271 if (NOT "${CMAKE_VERSION}" VERSION_LESS "3.16")
1272 if (BUILD_GUI)
1273 target_precompile_headers(${FURNACE} PUBLIC
1274 $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/src/pch.h>
1275 $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/extern/imgui_patched/imgui.h>
1276 $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/extern/imgui_patched/imgui_internal.h>
1277 )
1278 else()
1279 target_precompile_headers(${FURNACE} PUBLIC
1280 $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/src/pch.h>
1281 )
1282 endif()
1283 endif()
1284
1285 if (NOT ANDROID OR TERMUX)
1286 if (NOT WIN32 AND NOT APPLE)
1287 include(GNUInstallDirs)
1288 install(TARGETS ${FURNACE} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
1289 install(FILES res/furnace.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
1290 install(FILES res/mime.xml RENAME furnace.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages)
1291 if (NOT DONT_HAVE_GIT)
1292 install(FILES ${CMAKE_BINARY_DIR}/furnace.appdata.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo)
1293 endif()
1294 install(DIRECTORY doc DESTINATION ${CMAKE_INSTALL_DOCDIR})
1295 install(DIRECTORY papers DESTINATION ${CMAKE_INSTALL_DOCDIR}/other)
1296 install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DATADIR}/licenses/furnace)
1297 list(APPEND DEPENDENCIES_DEFINES LOCALE_DIR="${CMAKE_INSTALL_FULL_LOCALEDIR}")
1298 install(DIRECTORY po/locale/ DESTINATION ${CMAKE_INSTALL_LOCALEDIR})
1299 if (WITH_DEMOS OR WITH_INSTRUMENTS OR WITH_WAVETABLES)
1300 set(FURNACE_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}/furnace)
1301 if (WITH_DEMOS)
1302 install(DIRECTORY demos DESTINATION ${FURNACE_DATADIR})
1303 endif()
1304 if (WITH_INSTRUMENTS)
1305 install(DIRECTORY instruments DESTINATION ${FURNACE_DATADIR})
1306 endif()
1307 if (WITH_WAVETABLES)
1308 install(DIRECTORY wavetables DESTINATION ${FURNACE_DATADIR})
1309 endif()
1310 list(APPEND DEPENDENCIES_DEFINES FURNACE_DATADIR="${FURNACE_DATADIR}")
1311 if (SHOW_OPEN_ASSETS_MENU_ENTRY)
1312 list(APPEND DEPENDENCIES_DEFINES SHOW_OPEN_ASSETS_MENU_ENTRY)
1313 endif()
1314 endif()
1315 foreach(num 16 32 64 128 256 512)
1316 set(res ${num}x${num})
1317 install(FILES res/icon.iconset/icon_${res}.png RENAME furnace.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/${res}/apps)
1318 install(FILES res/icon.iconset/icon_${res}@2x.png RENAME furnace.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/${res}@2/apps)
1319 endforeach()
1320 install(FILES res/logo.png RENAME furnace.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/1024x1024/apps)
1321 else()
1322 if (MAKE_BUNDLE)
1323 install(TARGETS ${FURNACE} BUNDLE DESTINATION Applications RESOURCE DESTINATION Resources)
1324 else()
1325 install(TARGETS ${FURNACE} RUNTIME DESTINATION bin)
1326 endif()
1327 endif()
1328 endif()
1329
1330 target_compile_definitions(${FURNACE} PRIVATE ${DEPENDENCIES_DEFINES})