Change ALSA device default to 'default' from hw:0
[zynaddsubfx-code.git] / src / CMakeLists.txt
blobbed3c3379a4168268f53ceb0209bc68881cddfc5
1 #checking include/library paths
2 message(STATUS "Checking Include Path" $ENV{CMAKE_INCLUDE_PATH} ${CMAKE_INCLUDE_PATH})
3 message(STATUS "Checking Library Path" $ENV{CMAKE_LIBRARY_PATH} ${CMAKE_LIBRARY_PATH})
5 #Dependency check
6 include(CheckFunctionExists)
7 include(CheckIncludeFile)
8 include(CheckCXXSourceCompiles)
9 include(CheckCXXCompilerFlag)
10 if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Windows"))
11     find_package(PkgConfig)
12 endif()
13 find_package(ZLIB REQUIRED)
14 find_package(X11)
15 find_package(Threads   REQUIRED)
16 find_package(OSS)
17 find_package(Alsa)
18 find_package(Sndio)
19 find_package(FLTK)
20 find_package(OpenGL) #for FLTK
21 # lash
22 if(PKG_CONFIG_FOUND AND NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Windows"))
23     message("Looking For pkg config modules")
24     pkg_check_modules(JACK jack)
25     pkg_check_modules(PORTAUDIO portaudio-2.0>=19)
26     set(FLTK_SKIP_OPENGL true)
27     pkg_check_modules(NTK ntk)
28     pkg_check_modules(NTK_IMAGES ntk_images)
30     pkg_check_modules(FFTW3F REQUIRED fftw3f)
31     pkg_check_modules(MXML REQUIRED mxml)
33     pkg_search_module(LASH lash-1.0)
34     mark_as_advanced(LASH_LIBRARIES)
35     pkg_search_module(DSSI dssi>=0.9.0)
36     mark_as_advanced(DSSI_LIBRARIES)
37     pkg_search_module(LIBLO liblo>=0.26 REQUIRED)
38     mark_as_advanced(LIBLO_LIBRARIES)
39 else()
40     find_package(FFTW3F REQUIRED)
41     find_package(MXML REQUIRED)
42     find_package(LIBLO REQUIRED)
43     find_package(PORTAUDIO)
44 endif()
46 CHECK_FUNCTION_EXISTS(sched_setscheduler HAVE_SCHEDULER)
47 set(CMAKE_REQUIRED_FLAGS "-std=c++11")
48 CHECK_CXX_SOURCE_COMPILES(
49     "#include <future>
50     #if ATOMIC_INT_LOCK_FREE<2
51     #error unreliable atomics
52     #endif
53     int main(){return 0;}" HAVE_ASYNC)
55 check_include_file_cxx(complex HAVE_CPP_STD_COMPLEX)
57 find_library(HAVE_LIBRT rt)
59 set(CMAKE_REQUIRED_FLAGS "")
62 CHECK_CXX_SOURCE_COMPILES(
63     "int main(){
64     __asm__ __volatile__ (\"fistpl 0\");
65     return 0;}" HAVE_X86_FISTPL)
67 ######### Settings ###########
68 # NOTE: These cache variables should normally not be changed in this
69 # file, but either in in CMakeCache.txt before compile, or by passing
70 # parameters directly into cmake using the -D flag.
71 if(NTK_FOUND)
72   SET (GuiModule ntk  CACHE STRING "GUI module, either fltk, ntk, zest, or off")
73 elseif(FLTK_FOUND)
74   SET (GuiModule fltk CACHE STRING "GUI module, either fltk, ntk, zest, or off")
75 else()
76   SET (GuiModule off  CACHE STRING "GUI module, either fltk, ntk, zest, or off")
77 endif()
78 SET (CompileTests ON CACHE BOOL "whether tests should be compiled in or not")
79 SET (AlsaEnable ${ALSA_FOUND} CACHE BOOL
80     "Enable support for Advanced Linux Sound Architecture")
81 SET (JackEnable ${JACK_FOUND} CACHE BOOL
82     "Enable support for JACK Audio Connection toolKit")
83 SET (OssEnable ${OSS_FOUND} CACHE BOOL
84     "Enable support for Open Sound System")
85 SET (PaEnable ${PORTAUDIO_FOUND} CACHE BOOL
86     "Enable support for Port Audio System")
87 SET (SndioEnable ${SNDIO_FOUND} CACHE BOOL
88     "Enable support for Sndio System")
89 SET (LashEnable ${LASH_FOUND} CACHE BOOL
90     "Enable LASH Audio Session Handler")
91 SET (DssiEnable ${DSSI_FOUND} CACHE BOOL
92     "Enable DSSI Plugin compilation")
93 SET (NoNeonPlease False CACHE BOOL
94     "Workaround For Broken Neon Detection")
95 SET (PluginLibDir "lib" CACHE STRING
96     "Install directory for plugin libraries PREFIX/PLUGIN_LIB_DIR/{lv2,vst}")
97 SET (DemoMode FALSE CACHE BOOL "Enable 10 minute silence")
98 SET (PluginEnable TRUE CACHE BOOL "Enable Plugins")
99 SET (ZynFusionDir "" CACHE STRING "Developers only: zest binary's dir; useful if fusion is not system-installed.")
100 mark_as_advanced(FORCE ZynFusionDir)
102 # Now, handle the incoming settings and set define flags/variables based
103 # on this
105 # Add version information
106 add_definitions(-DVERSION="${VERSION}")
107 if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
108   add_definitions(-static)
109 endif()
111 if(HAVE_SCHEDULER AND (NOT "Darwin" STREQUAL ${CMAKE_SYSTEM_NAME}))
112     # Add scheduler function existence info (OSX compatibility)
113     add_definitions(-DHAVE_SCHEDULER=${HAVE_SCHEDULER})
114 endif()
116 if(HAVE_ASYNC)
117     add_definitions(-DHAVE_ASYNC=1)
118 else()
119     add_definitions(-DHAVE_ASYNC=0)
120 endif()
122 if(HAVE_CPP_STD_COMPLEX)
123     add_definitions(-DHAVE_CPP_STD_COMPLEX=1)
124 endif()
126 if(DemoMode)
127     add_definitions(-DDEMO_VERSION=1)
128 endif()
131 # Give a good guess on the best Input/Output default backends
132 if (JackEnable)
133     SET (DefaultOutput jack CACHE STRING
134         "Default Output module: [null, alsa, oss, jack, portaudio]")
135     # Override with perhaps more helpful midi backends
136     if (AlsaEnable)
137         SET (DefaultInput alsa CACHE STRING
138             "Default Input module: [null, alsa, oss, jack]")
139     elseif (OssEnable)
140         SET (DefaultInput oss CACHE STRING
141             "Default Input module: [null, alsa, oss, jack]")
142     else ()
143         SET (DefaultInput jack CACHE STRING
144             "Default Input module: [null, alsa, oss, jack]")
145     endif ()
146 elseif (AlsaEnable)
147     SET (DefaultOutput alsa CACHE STRING
148         "Default Output module: [null, alsa, oss, jack, portaudio]")
149     SET (DefaultInput alsa CACHE STRING
150         "Default Input module: [null, alsa, oss, jack]")
151 elseif (OssEnable)
152     SET (DefaultOutput oss CACHE STRING
153         "Default Output module: [null, alsa, oss, jack, portaudio]")
154     SET (DefaultInput oss CACHE STRING
155         "Default Input module: [null, alsa, oss, jack]")
156 elseif (PaEnable)
157     SET (DefaultOutput pa CACHE STRING
158         "Default Output module: [null, alsa, oss, jack, portaudio]")
159     SET (DefaultInput null CACHE STRING
160         "Default Input module: [null, alsa, oss, jack]")
161 elseif (SndioEnable)
162     SET (DefaultOutput sndio CACHE STRING
163         "Default Output module: [null, alsa, oss, jack, portaudio, sndio]")
164     SET (DefaultInput sndio CACHE STRING
165         "Default Input module: [null, alsa, oss, jack, sndio]")
166 else()
167     SET (DefaultOutput null CACHE STRING
168         "Default Output module: [null, alsa, oss, jack, portaudio]")
169     SET (DefaultInput null CACHE STRING
170         "Default Input module: [null, alsa, oss, jack]")
171 endif()
175 if(GuiModule STREQUAL ntk AND NTK_FOUND)
176         set (NtkGui TRUE)
177 elseif(GuiModule STREQUAL fltk AND FLTK_FOUND)
178         set (FltkGui TRUE)
179 elseif(GuiModule  STREQUAL zest)
180     set (ZestGui TRUE)
181 elseif(GuiModule STREQUAL off)
182         add_definitions(-DDISABLE_GUI)
183 else  ()
184         set (GuiModule off CACHE STRING "GUI module, either fltk, ntk, zest, or off")
185         add_definitions(-DDISABLE_GUI)
186         message(STATUS "GUI module defaulting to off")
187 endif()
190 #Build Flags
191 option (BuildForAMD_X86_64 "Build for AMD x86_64 system" OFF)
192 option (BuildForCore2_X86_64 "Build for Intel Core2 x86_64 system" OFF)
193 option (BuildForDebug "Include gdb debugging support" OFF)
194 option (ExtendedWarnings "Enable all useful warnings" OFF)
195 option (IncludeWhatYouUse "Check for useless includes" OFF)
196 mark_as_advanced(IncludeWhatYouUse)
198 set(CMAKE_BUILD_TYPE "Release")
200 set (BuildOptions_ExtendedWarnings "")
201 if (ExtendedWarnings)
202     if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
203         # The following generates a list of warning exceptions
204         # (after it enables all warnings).
205         # This is for developers who want to make sure they really
206         # see all possible warnings, with a few exceptions that don't
207         # make sense in this code base.
208         # You can remove those exceptions if they don't complain too
209         # often about the code base. If you want to add exceptions,
210         # be VERY CAREFUL, ask the project maintainers for
211         # their consent.
212         set (BuildOptions_ExtendedWarnings_List
213         "-Wall" "-Wextra" "-Weverything" # start with really everything
214         "-Wno-c++98-compat" "-Wno-c++98-compat-extra-semi" "-Wno-c++98-compat-pedantic" # C++11 is a zyn build requirement
215         "-Wno-cast-align" # not relevant for our case
216         "-Wno-double-promotion" # Used too often to fix
217         "-Wno-old-style-cast" # forces you to use static_cast<> etc everywhere! too many errors
218         "-Wno-padded" # this tells you to realign your structs to have better memory management
219         "-Wno-zero-as-null-pointer-constant" # wants you to use nullptr in the whole code base
220         "-Wno-implicit-int-conversion" # too often to fix
221         "-Wno-extra-semi" # one semicolon more than useful - no danger to disable this
222         "-Wno-vla-extension" "-Wno-vla" # rtosc currently heavily uses them, and they are supported by our CI
223         "-Wno-exit-time-destructors" "-Wno-global-constructors" # used too often in rtosc
224         "-Wno-gnu-zero-variadic-macro-arguments" # used too often in zyn
225         "-Wno-shadow" "-Wno-shadow-field" # used too often in zyn
226         "-Wno-cast-align" # used too often in zyn
227         "-Wno-missing-prototypes" # used too often in zyn
228         "-Wno-sign-conversion" # used too often in zyn
229         "-Wno-float-equal" # can be disturbing in some cases
230         "-Wno-switch-enum" # used too often in zyn
231         )
232         STRING(REPLACE ";" " " BuildOptions_ExtendedWarnings "${BuildOptions_ExtendedWarnings_List}")
233         MESSAGE(STATUS "Using extended Warning options: ${BuildOptions_ExtendedWarnings}")
234     else()
235         MESSAGE(WARNING "\"ExtendedWarnings\" selected, but this is only supported for clang - ignoring")
236     endif()
237 endif()
239 set (BuildOptions_x86_64AMD
240     "-march=athlon64 -m64 -Wall -Wno-unused-parameter"
241   CACHE STRING "X86_64 compiler options"
244 set (BuildOptions_X86_64Core2
245     "-march=core2 -m64 -Wall -Wno-unused-parameter"
246   CACHE STRING "X86_64 compiler options"
249 set (BuildOptions_NEON
250     "-march=armv7-a -mfloat-abi=hard -mfpu=neon -mcpu=cortex-a9 -mtune=cortex-a9 -pipe -mvectorize-with-neon-quad -funsafe-loop-optimizations"
251   CACHE STRING "Cortex_a9 compiler options"
254 check_cxx_compiler_flag("${BuildOptions_NEON} -Werror" SUPPORT_NEON)
256 set (BuildOptions_SSE
257         "-msse -msse2 -mfpmath=sse"
258   CACHE STRING "SSE compiler options"
261 check_cxx_compiler_flag("${BuildOptions_SSE} -Werror" SUPPORT_SSE)
263 set (BuildOptionsBasic
264     "-std=c++11 -Wno-unused-parameter -O3 -ffast-math -fomit-frame-pointer"
265     CACHE STRING "basic X86 compiler options"
267 STRING(APPEND BuildOptionsBasic " ${BuildOptions_ExtendedWarnings}")
269 set (BuildOptionsDebug
270     "-std=c++11 -O0 -g3 -ggdb -Wall -Wno-unused-parameter -Wpointer-arith"
271     CACHE STRING "Debug build flags")
272 STRING(APPEND BuildOptionsDebug " ${BuildOptions_ExtendedWarnings}")
274 if(${CMAKE_VERSION} VERSION_LESS "3.3.0")
275     set(IwyuErr "disabled (cmake < 3.3.0)")
276 else()
277     if(IncludeWhatYouUse)
278         find_program(IwyuPath NAMES include-what-you-use iwyu)
279         if(NOT IwyuPath)
280             set(IwyuErr "package NOT found")
281         endif()
282     else()
283         set(IwyuErr "disabled (IncludeWhatYouUse=OFF)")
284     endif()
285 endif()
287 ########### Settings dependent code ###########
288 # From here on, the setting variables have  been prepared so concentrate
289 # on the actual compiling.
291 # To avoid a conflict if PortAudio v1 is installed, the linker directory
292 # of portaudio must be specified first, so that xxx/lib/portaudio2 is
293 # searched before xxx/lib where PortAudio v1 gets installed.
294 if(PaEnable)
295         include_directories(${PORTAUDIO_INCLUDE_DIRS})
296         add_definitions(-DPORTAUDIO=1)
297         list(APPEND AUDIO_LIBRARIES ${PORTAUDIO_LIBRARIES})
298         list(APPEND AUDIO_LIBRARY_DIRS ${PORTAUDIO_LIBRARY_DIRS})
299 endif()
301 if(AlsaEnable)
302         list(APPEND AUDIO_LIBRARIES ${ASOUND_LIBRARY})
303         list(APPEND AUDIO_LIBRARY_DIRS ${ASOUND_LIBRARY_DIRS})
304         add_definitions(-DALSA=1)
305 endif(AlsaEnable)
307 if(JackEnable)
308         list(APPEND AUDIO_LIBRARIES ${JACK_LIBRARIES})
309         list(APPEND AUDIO_LIBRARY_DIRS ${JACK_LIBRARY_DIRS})
310         add_definitions(-DJACK=1)
311 endif(JackEnable)
313 if(OssEnable)
314         add_definitions(-DOSS=1)
315 endif(OssEnable)
317 if(SndioEnable)
318         list(APPEND AUDIO_LIBRARIES ${SNDIO_LIBRARY})
319         list(APPEND AUDIO_LIBRARY_DIRS ${SNDIO_LIBRARY_DIRS})
320         add_definitions(-DSNDIO=1)
321 endif(SndioEnable)
323 if (CompileTests)
324         ENABLE_TESTING()
325 endif()
327 if(LashEnable)
328         include_directories(${LASH_INCLUDE_DIRS})
329         add_definitions(-DLASH=1)
330         list(APPEND AUDIO_LIBRARIES ${LASH_LIBRARIES})
331         list(APPEND AUDIO_LIBRARY_DIRS ${LASH_LIBRARY_DIRS})
332         message(STATUS "Compiling with lash")
333 endif()
335 include_directories(${LIBLO_INCLUDE_DIRS})
336 add_definitions(-DUSE_NSM=1)
337 list(APPEND AUDIO_LIBRARIES ${LIBLO_LIBRARIES})
338 list(APPEND AUDIO_LIBRARY_DIRS ${LIBLO_LIBRARY_DIRS})
339 message(STATUS "Compiling with liblo")
341 # other include directories
342 include_directories(${ZLIB_INCLUDE_DIRS} ${MXML_INCLUDE_DIRS})
343 include_directories(${CMAKE_BINARY_DIR}/src) # for zyn-version.h ...
345 if(NOT ${X11_X11_LIB} STREQUAL "")
346     get_filename_component(X11_LIBRARY_DIRS ${X11_X11_LIB} DIRECTORY)
347 endif()
349 if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
350     add_definitions(-DWIN32)
351 endif()
353 if(${CMAKE_SYSTEM_NAME} STREQUAL "CYGWIN")
354     add_definitions(-D_GNU_SOURCE=1 -D_POSIX_THREAD_PRIO_INHERIT=1)
355 endif()
357 add_definitions(
358          -Wall
359          -Wextra
360          )
362 # macro similar to "check_cxx_compiler_flag_extra", however,
363 # it also checks for warnings that are only output if other warnings are active
364 macro (check_cxx_compiler_flag_extra _FLAG _FAILREGEX _RESULT)
365     set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
366     set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
367     
368     check_cxx_source_compiles("int main() { int x; return x; }" ${_RESULT}
369         FAIL_REGEX "unrecognized|option"
370     )
372     set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
373 endmacro ()
375 check_cxx_compiler_flag_extra("-Wall -Wextra -Wno-inconsistent-missing-override"
376     "unrecognized|option"
377     COMPILER_SUPPORTS_NO_INCONSISTENT_MISSING_OVERRIDE
378     )
379 if(COMPILER_SUPPORTS_NO_INCONSISTENT_MISSING_OVERRIDE)
380     add_definitions(-Wno-inconsistent-missing-override)
381 endif()
383 check_cxx_compiler_flag("-Wall -Wextra -Werror --system-header-prefix='FL/'"
384     COMPILER_SUPPORTS_SYSTEM_HDR_PREFIX)
385 if(COMPILER_SUPPORTS_SYSTEM_HDR_PREFIX)
386     add_definitions(--system-header-prefix="FL/")
387 endif()
389 if(HAVE_X86_FISTPL)
390     message(STATUS "Compiling with x86 opcode support")
391     add_definitions(-DASM_F2I_YES)
392 endif()
394 if (BuildForDebug)
395         set (CMAKE_BUILD_TYPE "Debug")
396         set (CMAKE_CXX_FLAGS_DEBUG ${BuildOptionsDebug})
397         message (STATUS "Building for ${CMAKE_BUILD_TYPE}, flags: ${CMAKE_CXX_FLAGS_DEBUG}")
398 else (BuildForDebug)
399         set (CMAKE_BUILD_TYPE "Release")
400         
401         set (CMAKE_CXX_FLAGS_RELEASE ${BuildOptionsBasic})
403         if (BuildForAMD_X86_64)
404                 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BuildOptions_x86_64AMD}")
405         endif (BuildForAMD_X86_64)
406         
407         if (BuildForCore2_X86_64)
408                         set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BuildOptions_X86_64Core2}")
409         endif (BuildForCore2_X86_64)
411         if (SUPPORT_SSE)
412                 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BuildOptions_SSE}")
413         endif (SUPPORT_SSE)
414         
415         if (SUPPORT_NEON AND NOT NoNeonPlease)
416                 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BuildOptions_NEON}")
417         endif (SUPPORT_NEON AND NOT NoNeonPlease)
419         message (STATUS "Building for ${CMAKE_BUILD_TYPE}, flags: ${CMAKE_CXX_FLAGS_RELEASE}")
420 endif (BuildForDebug)
422 if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Windows"))
423     add_definitions(-fPIC)
424 endif()
426 if(FLTK_FOUND)
427         mark_as_advanced(FORCE FLTK_BASE_LIBRARY)
428         mark_as_advanced(FORCE FLTK_CONFIG_SCRIPT)
429         mark_as_advanced(FORCE FLTK_DIR)
430         mark_as_advanced(FORCE FLTK_FLUID_EXECUTABLE)
431         mark_as_advanced(FORCE FLTK_FORMS_LIBRARY)
432         mark_as_advanced(FORCE FLTK_GL_LIBRARY)
433         mark_as_advanced(FORCE FLTK_IMAGES_LIBRARY)
434         mark_as_advanced(FORCE FLTK_INCLUDE_DIR)
435         mark_as_advanced(FORCE FLTK_MATH_LIBRARY)
436 endif(FLTK_FOUND)
438 if(NTK_FOUND)
439         mark_as_advanced(FORCE NTK_BASE_LIBRARY)
440         mark_as_advanced(FORCE NTK_CONFIG_SCRIPT)
441         mark_as_advanced(FORCE NTK_DIR)
442         mark_as_advanced(FORCE FLTK_FLUID_EXECUTABLE)
443         mark_as_advanced(FORCE NTK_FORMS_LIBRARY)
444         mark_as_advanced(FORCE NTK_GL_LIBRARY)
445         mark_as_advanced(FORCE NTK_IMAGES_LIBRARY)
446         mark_as_advanced(FORCE NTK_INCLUDE_DIR)
447         mark_as_advanced(FORCE NTK_MATH_LIBRARY)
448 endif(NTK_FOUND)
450 if(FltkGui)
451         #UGLY WORKAROUND
452         find_program (FLTK_CONFIG fltk-config)
453         if (FLTK_CONFIG)
454                 execute_process (COMMAND ${FLTK_CONFIG} --use-images --ldflags OUTPUT_VARIABLE FLTK_LDFLAGS)
455                 string(STRIP "${FLTK_LDFLAGS}" FLTK_LIBRARIES)
456         endif()
458         message(STATUS ${FLTK_LDFLAGS})
461         set(GUI_LIBRARIES zynaddsubfx_gui ${FLTK_LIBRARIES} ${FLTK_LIBRARIES} ${OPENGL_LIBRARIES})
463         add_definitions(-DFLTK_GUI)
464         message(STATUS "Will build FLTK gui")
466         include_directories(
467                         ${FLTK_INCLUDE_DIR}
468                         "${CMAKE_CURRENT_SOURCE_DIR}/UI"
469                         "${CMAKE_CURRENT_BINARY_DIR}/UI"
470                         )
472         add_subdirectory(UI)
473 endif()
475 if(NtkGui)
477     find_program(FLTK_FLUID_EXECUTABLE ntk-fluid)
479         message(STATUS ${NTK_LDFLAGS} ${NTK_IMAGES_LDFLAGS})
481         set(GUI_LIBRARIES zynaddsubfx_gui ${NTK_IMAGES_LIBRARIES} ${NTK_LIBRARIES} ${OPENGL_LIBRARIES})
483         if(X11_FOUND AND X11_Xpm_FOUND)
484              set(GUI_LIBRARIES ${GUI_LIBRARIES} ${X11_LIBRARIES} -lXpm)
485         endif()
487         add_definitions(-DNTK_GUI)
489         message(STATUS "Will build NTK gui")
491         include_directories(BEFORE
492                         ${NTK_INCLUDE_DIRS}
493                         "${CMAKE_CURRENT_SOURCE_DIR}/UI"
494                         "${CMAKE_CURRENT_BINARY_DIR}/UI"
495                         )
497         add_subdirectory(UI)
498 endif()
500 if(ZestGui)
501     add_definitions(-DDGL_OPENGL=1)
502     add_definitions(-DHAVE_DGL)
503     add_definitions(-DZEST_GUI)
504 endif()
506 if(NOT FltkGui AND NOT NtkGui)
507     set(NSM_WORKAROUND UI/NSM.C UI/NSM/Client.C)
508     add_library(zynaddsubfx_gui_bridge STATIC UI/ConnectionDummy.cpp ${NSM_WORKAROUND})
509     add_definitions(-DNO_UI=1)
510 endif()
512 ########### General section ##############
513 # Following this should be only general compilation code, and no mention
514 # of module-specific variables
516 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zyn-version.h.in
517     ${CMAKE_CURRENT_BINARY_DIR}/zyn-version.h)
518 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zyn-config.h.in
519     ${CMAKE_CURRENT_BINARY_DIR}/zyn-config.h)
521 link_directories(${AUDIO_LIBRARY_DIRS} ${ZLIB_LIBRARY_DIRS} ${FFTW3F_LIBRARY_DIRS} ${MXML_LIBRARY_DIRS} ${FLTK_LIBRARY_DIRS} ${NTK_LIBRARY_DIRS} ${X11_LIBRARY_DIRS})
523 include_directories(
524         ${CMAKE_CURRENT_SOURCE_DIR}
525         ${CMAKE_CURRENT_BINARY_DIR}
526         )
529 set(NONGUI_LIBRARIES
530         zynaddsubfx_misc
531         zynaddsubfx_synth
532         zynaddsubfx_effect
533         zynaddsubfx_params
534         zynaddsubfx_dsp
535         zynaddsubfx_nio
536         )
538 add_subdirectory(Misc)
539 add_subdirectory(Synth)
540 add_subdirectory(Effects)
541 add_subdirectory(Params)
542 add_subdirectory(DSP)
543 add_subdirectory(Nio)
544 if (PluginEnable)
545     add_subdirectory(Plugin)
546 endif()
548 add_library(zynaddsubfx_core STATIC
549     version.cpp
550     globals.cpp
551     ../tlsf/tlsf.c
552     Containers/ScratchString.cpp
553     Containers/NotePool.cpp
554     Containers/MultiPseudoStack.cpp
555         ${zynaddsubfx_dsp_SRCS}
556         ${zynaddsubfx_effect_SRCS}
557         ${zynaddsubfx_misc_SRCS}
558         ${zynaddsubfx_params_SRCS}
559         ${zynaddsubfx_synth_SRCS}
560         )
562 if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
563     set(PTHREAD_LIBRARY winpthread)
564     set(PLATFORM_LIBRARIES ws2_32
565             winmm
566             wsock32
567             "-static" iphlpapi
568             "-static" winpthread)
569 elseif(APPLE)
570     set(PTHREAD_LIBRARY pthread)
571 else()
572     if(HAVE_LIBRT)
573         set(PLATFORM_LIBRARIES rt)
574     endif()
575     set(PTHREAD_LIBRARY pthread)
576 endif()
578 if(ZYN_SYSTEM_RTOSC)
579     target_link_libraries(zynaddsubfx_core
580         ${ZLIB_LIBRARIES}
581         ${FFTW3F_LIBRARIES}
582         ${MXML_LIBRARIES}
583         ${OS_LIBRARIES}
584         ${PTHREAD_LIBRARY}
585         ${RTOSC_LIBRARIES}
586         ${RTOSC_CPP_LIBRARIES}
587     )
588 else()
589     target_link_libraries(zynaddsubfx_core
590         ${ZLIB_LIBRARIES}
591         ${FFTW3F_LIBRARIES}
592         ${MXML_LIBRARIES}
593         ${OS_LIBRARIES}
594         ${PTHREAD_LIBRARY}
595         rtosc
596         rtosc-cpp
597     )
598 endif()
600 if(IwyuErr)
601     message (STATUS "Include what you use: ${IwyuErr}")
602 else()
603     set(IwyuPathAndOptions
604         ${IwyuPath}
605         -Xiwyu
606         --no_comments)
607     set_property(TARGET zynaddsubfx_core PROPERTY CXX_INCLUDE_WHAT_YOU_USE
608                  ${IwyuPathAndOptions})
609 endif()
611 if(CompileTests)
612         add_subdirectory(Tests)
613 endif(CompileTests)
616 add_executable(zynaddsubfx main.cpp)
618 #Warning: the required ordering of these to get proper linking depends upon the
619 #         phase of the moon
620 target_link_libraries(zynaddsubfx
621     zynaddsubfx_core
622         zynaddsubfx_nio
623     zynaddsubfx_gui_bridge
624         ${GUI_LIBRARIES}
625         ${NIO_LIBRARIES}
626         ${AUDIO_LIBRARIES}
627     ${PLATFORM_LIBRARIES}
628     )
630 if (DssiEnable)
631         add_library(zynaddsubfx_dssi SHARED
632                         UI/ConnectionDummy.cpp
633                         Output/DSSIaudiooutput.cpp
634                         globals.cpp
635                         Output/DSSIControl.cpp
636                         Output/DSSIControl.h
637                         Output/DSSIControlDescription.cpp
638                         Output/DSSIControlDescription.h)
640         target_link_libraries(zynaddsubfx_dssi
641                 zynaddsubfx_core
642                 ${OS_LIBRARIES}
643                 ${LIBLO_LIBRARIES}
644                 ${PLATFORM_LIBRARIES}
645                 -Wl,--no-undefined
646                 )
647     install(TARGETS zynaddsubfx_dssi LIBRARY DESTINATION ${PluginLibDir}/dssi/)
648 endif()
650 install(TARGETS zynaddsubfx
651         RUNTIME DESTINATION bin
652         )
653 if(NtkGui)
654     install(DIRECTORY ../pixmaps DESTINATION share/zynaddsubfx)
655 endif(NtkGui)
657 include(CTest)
660 ##Summarize The Full Configuration
661 message(STATUS)
662 message(STATUS "${ColorBold}ZynAddSubFX Build Configuration")
663 message(STATUS             "===============================${ColorReset}")
664 message(STATUS)
665 message(STATUS "Building on a '${CMAKE_SYSTEM_NAME}' System")
668 macro(package_status foundvar pkg state)#optional color
669     set (extra_macro_args ${ARGN})
670     list(LENGTH extra_macro_args num_extra_args)
671     if (${num_extra_args} GREATER 0)
672         list(GET extra_macro_args 0 color)
673     endif ()
674     if(${foundvar})
675         message(STATUS "${pkg} -- ${Green}${state}${ColorReset}")
676     else()
677         message(STATUS "${pkg} -- ${color}NOT ${state}${ColorReset}")
678     endif()
679 endmacro()
681 package_status(PKG_CONFIG_FOUND "PkgConfig" "found"   ${Red})
682 package_status(ZLIB_FOUND       "zlib     " "found"   ${Red})
683 package_status(MXML_FOUND       "mxml     " "found"   ${Red})
684 package_status(FFTW3F_FOUND     "fftw3f   " "found"   ${Red})
685 package_status(LIBLO_FOUND      "liblo    " "found"   ${Red})
686 package_status(X11_FOUND        "x11      " "found"   ${Yellow})
687 package_status(X11_Xpm_FOUND    "xpm      " "found"   ${Yellow})
688 package_status(FLTK_FOUND       "fltk     " "found"   ${Yellow})
689 package_status(NTK_FOUND        "ntk      " "found"   ${Yellow})
690 package_status(OSS_FOUND        "OSS      " "found"   ${Yellow})
691 package_status(ALSA_FOUND       "ALSA     " "found"   ${Yellow})
692 package_status(JACK_FOUND       "JACK     " "found"   ${Yellow})
693 package_status(PORTAUDIO_FOUND  "PA       " "found"   ${Yellow})
694 package_status(SNDIO_FOUND      "SNDIO    " "found"   ${Yellow})
695 package_status(LASH_FOUND       "Lash     " "found"   ${Yellow})
696 package_status(DSSI_FOUND       "DSSI     " "found"   ${Yellow})
697 package_status(LashEnable       "Lash     " "enabled" ${Yellow})
698 package_status(DssiEnable       "DSSI     " "enabled" ${Yellow})
699 package_status(CompileTests     "tests    " "enabled" ${Yellow})
700 package_status(AlsaEnable       "ALSA     " "enabled" ${Yellow})
701 package_status(JackEnable       "JACK     " "enabled" ${Yellow})
702 package_status(OssEnable        "OSS      " "enabled" ${Yellow})
703 package_status(PaEnable         "PA       " "enabled" ${Yellow})
704 package_status(SndioEnable      "SNDIO    " "enabled" ${Yellow})
705 #TODO GUI MODULE
706 package_status(HAVE_ASYNC       "c++ async" "usable"  ${Yellow})
709 message(STATUS "Link libraries: ${ZLIB_LIBRARY} ${FFTW3F_LIBRARY} ${MXML_LIBRARIES} ${AUDIO_LIBRARIES} ${OS_LIBRARIES}")