zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

CMakeLists.txt (24647B)


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