1 cmake_minimum_required (VERSION 2.8)
2 project (SuperCollider)
7 include (cmake_modules/FinalFile.cmake)
9 if (NOT CMAKE_BUILD_TYPE)
10 message(STATUS "Build type defaulting to \"Release\"")
11 set(CMAKE_BUILD_TYPE "Release")
14 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules
18 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/cmake_uninstall.cmake.in"
19 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
22 ADD_CUSTOM_TARGET(uninstall
23 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
26 ADD_CUSTOM_TARGET(setMainVersion ALL
27 sh ${CMAKE_CURRENT_SOURCE_DIR}/setMainVersion.sh
28 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
34 STRING(REGEX REPLACE "^.*MacOSX10.([0-9]+).*$" "\\1" MAC_OSX_SDK_VERSION "${CMAKE_OSX_SYSROOT}")
36 if(CMAKE_OSX_DEPLOYMENT_TARGET)
37 if (CMAKE_OSX_DEPLOYMENT_TARGET GREATER 10.4)
38 set(HID_UTIL_DIR "HID_Utilities")
40 set(HID_UTIL_DIR "HID_Utilities_10_4")
43 if (${MAC_OSX_SDK_VERSION} GREATER 4)
44 set(HID_UTIL_DIR "HID_Utilities")
46 set(HID_UTIL_DIR "HID_Utilities_10_4")
49 MESSAGE( STATUS "Using HID Utilities from folder '${HID_UTIL_DIR}'")
52 #############################################
55 if (${CMAKE_COMPILER_IS_GNUCXX})
56 exec_program(${CMAKE_CXX_COMPILER} ARGS -dumpversion OUTPUT_VARIABLE _gcc_version)
58 add_definitions("-fschedule-insns2" "-fomit-frame-pointer")
60 if (${_gcc_version} VERSION_GREATER 4.0.99)
61 add_definitions("-ffast-math")
64 if (${_gcc_version} VERSION_GREATER 4.5.99)
65 add_definitions("-fpermissive") # boost.atomic is using a deprecated syntax
68 option(DSO_VISIBILITY "DSO visibility support for gcc" OFF)
71 add_definitions(-fvisibility=hidden)
75 exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info)
77 if ("${_gcc_version_info}" MATCHES "darwin10-llvm-g..-4.2")
78 message(FATAL_ERROR "llvm-gcc-4.2 was reported to be broken. please use another compiler.")
80 if ("${_gcc_version_info}" MATCHES "Apple")
81 add_definitions("-fpascal-strings")
83 add_definitions("-D_REENTRANT")
84 elseif(NOT (WIN32 AND NOT CYGWIN))
85 add_definitions("-pthread")
90 set_property(DIRECTORY
92 PROPERTY COMPILE_DEFINITIONS SC_DARWIN)
93 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
94 add_definitions("-DSC_LINUX")
95 add_definitions(-DSC_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/SuperCollider")
96 elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
97 add_definitions("-DSC_FREEBSD")
98 add_definitions(-DSC_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/SuperCollider")
102 set_property(DIRECTORY
104 PROPERTY COMPILE_DEFINITIONS SC_WIN32 NOMINMAX _WINSOCKAPI_)
107 SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} /MTd")
108 SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} /MT")
113 #############################################
114 # some default libraries
116 find_package(Pthreads)
118 if (NOT PTHREADS_FOUND)
119 message(SEND_ERROR "cannot find libpthreads")
121 include_directories(${PTHREADS_INCLUDE_DIR})
126 find_library(MATH_LIBRARY m)
132 add_definitions("-DHAVE_LIBCURL")
133 include_directories(${CURL_INCLUDE_DIRS})
137 #############################################
139 option(NOVA_SIMD "Build with nova-simd support." ON)
140 option(FINAL_BUILD "Build as single source file." OFF)
142 option(CURL "Build with curl for remote file download." ON)
144 option(FFT_GREEN "Use internal 'Green' FFT lib rather than FFTW. (Not recommended.)" OFF)
145 mark_as_advanced(FFT_GREEN)
147 option(SSE "Compile with support for SSE instructions.")
148 option(SSE41 "Compile with support for SSE4.1 instructions.")
149 option(SSE42 "Compile with support for SSE4.2 instructions.")
152 option(SC_DOC_RENDER "Pre-render SCDoc documentation. (For putting online, etc)" OFF)
154 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
155 option(SUPERNOVA "Build with supernova as optional audio synthesis server" ON)
157 option(SUPERNOVA "Build with supernova as optional audio synthesis server" OFF)
160 option(SN_MEMORY_DEBUGGING "Build supernova for memory debugging (disable memory pools).")
161 option(SC_MEMORY_DEBUGGING "Build sclang&scsynth for memory debugging (disable memory pools).")
162 option(GC_SANITYCHECK "Enable sanity checks in the sclang garbage collector.")
164 option(NO_LIBSNDFILE "Disable soundfile functionality. (Not recommended.)" OFF)
165 mark_as_advanced(NO_LIBSNDFILE)
168 option(SCLANG_SERVER "Build with internal server." ON)
171 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
172 option(SC_WII "Build sclang with WII support" ON)
175 option(SC_QT "Build SuperCollider with Qt GUI" ON)
178 option(SC_PSYCOLLIDER "Build PsyCollider" ON)
180 option(SC_PSYCOLLIDER "Build PsyCollider" OFF)
183 if(CMAKE_COMPILER_IS_GNUCXX)
184 option(NATIVE "Optimize binary for this architecture (binaries may not run on other machines, requires gcc-4.3 or higher).")
185 option(LTO "Use GCC's link time optimizer' (experimental).")
188 #############################################
189 # some preprocessor flags
190 if(CMAKE_COMPILER_IS_GNUCXX)
192 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -mfpmath=sse")
193 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -mfpmath=sse")
196 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
197 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
200 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
201 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
204 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
205 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
209 if (SC_MEMORY_DEBUGGING)
210 add_definitions(-DDISABLE_MEMORY_POOLS)
213 #############################################
215 add_subdirectory(server)
216 add_subdirectory(lang)
217 add_subdirectory(bindings)
218 add_subdirectory(platform)
219 add_subdirectory(editors)
220 add_subdirectory(external_libraries)
223 message( STATUS "Compiling with Qt GUI" )
224 add_subdirectory(QtCollider)
227 if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
228 install(DIRECTORY include/common include/plugin_interface include/server include/lang
229 DESTINATION ${CMAKE_INSTALL_PREFIX}/include/SuperCollider
230 FILES_MATCHING PATTERN "*.h"
235 # determines the app name and app install location (scappbundlename, scappdir):
236 include (cmake_modules/MacAppFolder.cmake)
238 set(auxresourcesdir ${scappauxresourcesdir})
240 # Some aux files which go in the app's folder
241 install(FILES README ChangeLog
242 DESTINATION ${auxresourcesdir}
244 install(FILES COPYING AUTHORS
245 DESTINATION ${scappdir}
248 set(auxresourcesdir "SuperCollider")
250 set(auxresourcesdir "share/SuperCollider")
254 set(SCCLASSLIB_EXCLUDE_REGEX "QtCollider")
256 set(SCCLASSLIB_EXCLUDE_REGEX "IGNOREME")
259 install(DIRECTORY SCClassLibrary
260 DESTINATION ${auxresourcesdir}
261 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
264 install(DIRECTORY Help examples sounds HelpSource
265 DESTINATION ${auxresourcesdir}
268 #############################################
270 # build scdoc help files
272 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Common")
273 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Platform")
274 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/SCDoc")
275 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/DefaultLibrary")
276 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/JITLib")
277 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/backwards_compatibility")
279 # this folder has an extension to Platform that disables the loadStartupFiles method
280 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/platform/disable_startup_files")
282 foreach(arg ${BUILD_CLASSLIBRARIES})
283 set(BUILD_CLASSLIBRARYPATH "${BUILD_CLASSLIBRARYPATH}+${arg}\n")
286 configure_file(build_sclang.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg)
289 file(GLOB_RECURSE SCDocSources RELATIVE HelpSource .*[^~])
290 file(GLOB_RECURSE SCDocClasses RELATIVE SCClassLibrary/SCDoc *.sc)
292 add_custom_target(doc ALL
293 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lang/sclang${CMAKE_EXECUTABLE_SUFFIX}
294 -l ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg
295 platform/renderAllHelp.scd ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_CURRENT_BINARY_DIR}/RenderedHelp
296 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
297 DEPENDS sclang ${SCDocSources} ${SCDocClasses})
301 set_directory_properties(
303 ADDITIONAL_MAKE_CLEAN_FILES "RenderedHelp")
305 #############################################
309 add_subdirectory(testsuite)
311 #############################################
312 # win32 install support
315 install(FILES ${FFTW3F_LIBRARY} ${SNDFILE_LIBRARY} ${PTHREADS_LIBRARY} ${PORTAUDIO_LIBRARIES}
316 DESTINATION "SuperCollider"
317 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
320 #############################################
323 set(CPACK_PACKAGE_VERSION_MAJOR 3)
324 set(CPACK_PACKAGE_VERSION_MINOR 5)
325 set(CPACK_PACKAGE_VERSION_PATCH dev)
328 set(CPACK_MONOLITHIC_INSTALL 1)
331 #############################################
332 # hide advanced variables
333 mark_as_advanced(AVAHI_LIBRARIES AVAHI_INCLUDE_DIRS AVAHI_INCLUDE_DIR AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT)
335 mark_as_advanced(EMACS_EXECUTABLE)
336 mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY)
337 mark_as_advanced(JACK JACK_INCLUDE_DIR JACK_LIBRARY)
338 mark_as_advanced(MATH_LIBRARY)
339 mark_as_advanced(QT_QMAKE_EXECUTABLE)
340 mark_as_advanced(SNDFILE)