cmake build system: prototype generation of nested sclang.app bundle
[supercollider.git] / server / supernova / CMakeLists.txt
blobd0782998985d0480b8ccbe8748ae0308b43bc96b
1 if (FFT_GREEN)
2     add_definitions("-DSC_FFT_GREEN")
3 elseif (APPLE)
4     add_definitions("-DSC_FFT_VDSP")
5 else()
6     find_package(FFTW3f 3.3)
7     if (FFTW3F_FOUND)
8         add_definitions("-DSC_FFT_FFTW")
9     else()
10         message(SEND_ERROR "Cannot find libfftw3f")
11     endif()
12 endif()
14 if(CMAKE_COMPILER_IS_GNUCXX)
15   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-4096")
16   set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer")
18   if(APPLE)
19     if (CMAKE_SIZEOF_VOID_P MATCHES "4")
20       # cmpxchg8b is available on all intel apples
21       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686 -msse -msse2 -mfpmath=sse")
22     endif()
23   endif()
24 endif(CMAKE_COMPILER_IS_GNUCXX)
27 if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_INTEL OR CMAKE_COMPILER_IS_CLANG)
28     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
29 else()
30     message(FATAL_ERROR "unknown compiler. supernova cannot be compiled")
31 endif()
33 if(MEMORY_DEBUGGING)
34     set_property(DIRECTORY .
35                  APPEND
36                  PROPERTY COMPILE_DEFINITIONS_DEBUG NOVA_MEMORY_DEBUGGING)
37 endif()
39 if(NOVA_SIMD)
40     add_definitions(-DNOVA_SIMD)
41 endif()
44 include_directories(${CMAKE_SOURCE_DIR}/external_libraries/boost_endian
45                     ${CMAKE_SOURCE_DIR}/external_libraries/oscpack
46                     ${CMAKE_SOURCE_DIR}/external_libraries/TLSF-2.4.6/src
47                     )
49 if(APPLE)
50     include_directories(${CMAKE_SOURCE_DIR}/external_libraries/libsndfile)
51 endif()
53 include_directories(${CMAKE_SOURCE_DIR}/include/plugin_interface
54                     ${CMAKE_SOURCE_DIR}/include/server
55                     ${CMAKE_SOURCE_DIR}/include/common
56                     .
57                     )
59 set(libsupernova_src
60     sc/sc_synth_prototype.cpp
61     sc/sc_osc_handler.cpp
62     sc/sc_plugin_interface.cpp
63     sc/sc_synth.cpp
64     sc/sc_synthdef.cpp
65     sc/sc_ugen_factory.cpp
66     ../scsynth/Samp.cpp
67     ${CMAKE_SOURCE_DIR}/common/SC_fftlib.cpp
68     ${CMAKE_SOURCE_DIR}/common/SC_DirUtils.cpp
69     ${CMAKE_SOURCE_DIR}/common/SC_StandAloneInfo_Darwin.cpp
70     server/buffer_manager.cpp
71     server/dsp_context.cpp
72     server/memory_pool.cpp
73     server/node_graph.cpp
74     server/server.cpp
75     server/server_args.cpp
78 if(FFT_GREEN)
79     list(APPEND libsupernova_src ../../common/fftlib.c)
80 endif()
82 file(GLOB_RECURSE supernova_headers *hpp)
84 if(COMPACT_BUILD)
85   CREATE_FINAL_FILE(libsupernova_final.cpp ${libsupernova_src})
86   add_library (libsupernova STATIC libsupernova_final.cpp)
87 else()
88   add_library (libsupernova STATIC ${libsupernova_src})
89 endif()
91 set_property(TARGET libsupernova
92              PROPERTY OUTPUT_NAME supernova)
94 add_executable(supernova server/main.cpp ${supernova_headers})
96 set_property(TARGET libsupernova supernova
97              APPEND
98              PROPERTY COMPILE_DEFINITIONS SUPERNOVA)
100 find_library(DL NAMES dl)
101 if (DL)
102     set_property(TARGET libsupernova
103                  APPEND
104                  PROPERTY COMPILE_DEFINITIONS DLOPEN)
105     target_link_libraries(libsupernova ${DL})
106 endif()
108 if (WIN32 OR APPLE)
109     find_package(Portaudio)
110     if(NOT PORTAUDIO_FOUND)
111         message(FATAL_ERROR "Portaudio missing")
112     endif()
113     add_definitions(-DPORTAUDIO_BACKEND ${PORTAUDIO_DEFINITIONS})
114     include_directories(${PORTAUDIO_INCLUDE_DIRS})
115     target_link_libraries(libsupernova ${PORTAUDIO_LIBRARIES})
116 else()
117     find_library(JACK NAMES jack)
118     if (JACK)
119         set_property(TARGET libsupernova supernova
120                     APPEND
121                     PROPERTY COMPILE_DEFINITIONS JACK_BACKEND)
122         target_link_libraries(libsupernova ${JACK})
123         include_directories(${JACK_INCLUDE_DIRS})
124     endif()
125 endif()
127 find_package(Sndfile)
128 if (NOT SNDFILE_FOUND)
129     message(SEND_ERROR "Cannot find libsndfile")
130 else()
131     target_link_libraries(libsupernova ${SNDFILE_LIBRARIES})
132     include_directories(${SNDFILE_INCLUDE_DIR})
133 endif()
135 if (FFTW3F_FOUND)
136         target_link_libraries(libsupernova ${FFTW3F_LIBRARY})
137 endif()
139 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
140     target_link_libraries(libsupernova rt)
141 endif()
143 target_link_libraries(libsupernova oscpack tlsf ${PTHREADS_LIBRARIES})
145 if (Boost_FOUND)
146     target_link_libraries(libsupernova   ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
147 else()
148     target_link_libraries(libsupernova boost_system boost_filesystem boost_program_options)
149 endif()
151 target_link_libraries(supernova libsupernova)
153 if(APPLE)
154         # determines the app name and app install location (scappbundlename, scappdir):
155         include (${CMAKE_SOURCE_DIR}/cmake_modules/MacAppFolder.cmake)
157         install(TARGETS supernova
158                         DESTINATION ${sclangauxresourcesdir}
159                         PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE OWNER_WRITE)
160 else()
162 install(TARGETS supernova
163         DESTINATION "bin"
164         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
165 endif()
167 if(LTO)
168     set_property(TARGET supernova libsupernova
169                  APPEND PROPERTY COMPILE_FLAGS "-flto -flto-report")
171     set_property(TARGET supernova libsupernova
172                  APPEND PROPERTY LINK_FLAGS "-flto -flto-report -fwhole-program")
173 endif()
175 if (APPLE)
176     target_link_libraries(libsupernova "-framework vecLib")
177     target_link_libraries(libsupernova "-framework CoreAudio -framework CoreServices")
178 endif()