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 if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
15 message(WARNING "WARNING: IN-PLACE BUILDS ARE NOT RECOMMENDED - PLEASE USE A BUILD DIRECTORY")
19 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules
23 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/cmake_uninstall.cmake.in"
24 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
27 ADD_CUSTOM_TARGET(uninstall
28 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
31 ADD_CUSTOM_TARGET(setMainVersion ALL
32 sh ${CMAKE_CURRENT_SOURCE_DIR}/setMainVersion.sh
33 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
39 STRING(REGEX REPLACE "^.*MacOSX10.([0-9]+).*$" "\\1" MAC_OSX_SDK_VERSION "${CMAKE_OSX_SYSROOT}")
41 if(CMAKE_OSX_DEPLOYMENT_TARGET)
42 if (CMAKE_OSX_DEPLOYMENT_TARGET GREATER 10.4)
43 set(HID_UTIL_DIR "HID_Utilities")
45 set(HID_UTIL_DIR "HID_Utilities_10_4")
48 if (${MAC_OSX_SDK_VERSION} GREATER 4)
49 set(HID_UTIL_DIR "HID_Utilities")
51 set(HID_UTIL_DIR "HID_Utilities_10_4")
54 MESSAGE( STATUS "Using HID Utilities from folder '${HID_UTIL_DIR}'")
57 if (CMAKE_SYSTEM_NAME MATCHES "Linux")
61 #############################################
64 if (${CMAKE_COMPILER_IS_GNUCXX})
65 exec_program(${CMAKE_CXX_COMPILER} ARGS -dumpversion OUTPUT_VARIABLE _gcc_version)
67 add_definitions("-fschedule-insns2" "-fomit-frame-pointer")
69 add_definitions("-Wreturn-type")
71 # disabled for now: -ffast-math breaks avx intrinsics and -fsigned-zeros/-fno-associative-math are not available in some versions
72 # if (${_gcc_version} VERSION_GREATER 4.0.99)
73 # add_definitions("-ffast-math -fsigned-zeros -fno-associative-math")
76 option(DSO_VISIBILITY "DSO visibility support for gcc" OFF)
79 add_definitions(-fvisibility=hidden)
83 exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info)
84 if ("${_gcc_version_info}" MATCHES "Apple")
85 add_definitions("-fpascal-strings")
87 add_definitions("-D_REENTRANT")
88 elseif(NOT (WIN32 AND NOT CYGWIN))
89 add_definitions("-pthread")
93 if (${CMAKE_CXX_COMPILER} MATCHES icpc)
94 set(CMAKE_COMPILER_IS_INTEL 1)
95 add_definitions(-Wno-unknown-pragmas)
96 add_definitions(-simd)
99 if (${CMAKE_CXX_COMPILER} MATCHES clang)
100 option(DSO_VISIBILITY "DSO visibility support for clang" OFF)
103 add_definitions(-fvisibility=hidden)
106 set(CMAKE_COMPILER_IS_CLANG 1)
110 set_property(DIRECTORY
112 PROPERTY COMPILE_DEFINITIONS SC_DARWIN)
113 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
114 add_definitions("-DSC_LINUX")
115 add_definitions(-DSC_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/SuperCollider")
116 elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
117 add_definitions("-DSC_FREEBSD")
118 add_definitions(-DSC_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/SuperCollider")
122 set_property(DIRECTORY
124 PROPERTY COMPILE_DEFINITIONS SC_WIN32 NOMINMAX _WINSOCKAPI_)
127 SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} /MTd")
128 SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} /MT")
133 #############################################
134 # some default libraries
136 find_package(Pthreads)
138 if (NOT PTHREADS_FOUND)
139 message(SEND_ERROR "cannot find libpthreads")
141 include_directories(${PTHREADS_INCLUDE_DIR})
146 find_library(MATH_LIBRARY m)
152 add_definitions("-DHAVE_LIBCURL")
153 include_directories(${CURL_INCLUDE_DIRS})
157 #############################################
159 option(NOVA_SIMD "Build with nova-simd support." ON)
160 option(FINAL_BUILD "Build as single source file." OFF)
162 option(CURL "Build with curl for remote file download." ON)
164 option(FFT_GREEN "Use internal 'Green' FFT lib rather than FFTW. (Not recommended.)" OFF)
166 option(SSE "Compile with support for SSE instructions.")
167 option(SSE41 "Compile with support for SSE4.1 instructions.")
168 option(SSE42 "Compile with support for SSE4.2 instructions.")
171 option(INSTALL_HELP "Install help docs and examples along with the software" ON)
172 option(INSTALL_OLD_HELP "Install old and deprecated help files" ON)
173 option(SC_DOC_RENDER "Pre-render SCDoc documentation. (For putting online, etc)" OFF)
175 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
176 option(SUPERNOVA "Build with supernova as optional audio synthesis server" ON)
178 option(SUPERNOVA "Build with supernova as optional audio synthesis server" OFF)
181 option(SN_MEMORY_DEBUGGING "Build supernova for memory debugging (disable memory pools).")
182 option(SC_MEMORY_DEBUGGING "Build sclang&scsynth for memory debugging (disable memory pools).")
183 option(GC_SANITYCHECK "Enable sanity checks in the sclang garbage collector.")
185 option(NO_LIBSNDFILE "Disable soundfile functionality. (Not recommended.)" OFF)
187 option(NO_AVAHI "Disable Avahi support. (Not recommended.)" OFF)
190 option(SCLANG_SERVER "Build with internal server." ON)
193 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
194 option(SC_WII "Build sclang with WII support" ON)
197 option(SC_QT "Build SuperCollider with Qt GUI" ON)
199 message( STATUS "Compiling with Qt GUI" )
203 option(SC_PSYCOLLIDER "Build PsyCollider" ON)
205 option(SC_PSYCOLLIDER "Build PsyCollider" OFF)
208 if(CMAKE_COMPILER_IS_GNUCXX)
209 option(NATIVE "Optimize binary for this architecture (binaries may not run on other machines, requires gcc-4.3 or higher).")
210 option(LTO "Use GCC's link time optimizer' (experimental).")
213 option(SC_SYMLINK_CLASSLIB "Place a symlink of SCCLassLibrary instead of copying" OFF)
214 option(SC_OX "Try to compile with support for C++0x (experimental, mainly related to supernova)" OFF)
216 #############################################
217 # some preprocessor flags
218 if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
220 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -mfpmath=sse")
221 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -mfpmath=sse")
224 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
225 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
228 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
229 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
232 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
233 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
237 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
241 if (CMAKE_COMPILER_IS_INTEL AND NOT WIN32)
243 add_definitions(-xSSE4.2)
245 add_definitions(-xSSE4.1)
247 add_definitions(-mia32)
250 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
254 add_definitions(-diag-disable 170) # pointer points outside of underlying object ... used heavily in sclang
255 add_definitions(-diag-disable 279) # controlling expression is constant
259 if (SC_MEMORY_DEBUGGING)
260 add_definitions(-DDISABLE_MEMORY_POOLS)
263 #############################################
265 add_subdirectory(external_libraries)
266 add_subdirectory(server)
267 add_subdirectory(lang)
268 add_subdirectory(bindings)
269 add_subdirectory(platform)
270 add_subdirectory(editors)
272 if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
273 install(DIRECTORY include/common include/plugin_interface include/server include/lang
274 DESTINATION ${CMAKE_INSTALL_PREFIX}/include/SuperCollider
275 FILES_MATCHING PATTERN "*.h"
280 # determines the app name and app install location (scappbundlename, scappdir):
281 include (cmake_modules/MacAppFolder.cmake)
283 set(auxresourcesdir ${scappauxresourcesdir})
285 # Some aux files which go in the app's folder
286 install(FILES README.txt ChangeLog
287 DESTINATION ${auxresourcesdir}
289 install(FILES COPYING AUTHORS
290 DESTINATION ${scappdir}
293 set(auxresourcesdir "SuperCollider")
295 set(auxresourcesdir "share/SuperCollider")
299 set(SCCLASSLIB_EXCLUDE_REGEX "QtCollider")
301 set(SCCLASSLIB_EXCLUDE_REGEX "IGNOREME")
305 #if directory contains symlinks, unlink them.
306 if(EXISTS "${auxresourcesdir}/SCClassLibrary")
307 file(GLOB classlibraryfolders "${auxresourcesdir}/SCClassLibrary/[^.]*")
308 foreach(onedirectory ${classlibraryfolders})
309 if(IS_SYMLINK "${onedirectory}")
310 install( CODE "EXECUTE_PROCESS(COMMAND unlink ${onedirectory} )" )
312 endforeach(onedirectory)
315 if(SC_SYMLINK_CLASSLIB)
317 #if there are folders inside SCCLassLibrary abort cmake.
318 file(GLOB classlibraryfolders "${auxresourcesdir}/SCClassLibrary/[^.]*")
319 foreach(onedirectory ${classlibraryfolders})
320 if(NOT IS_SYMLINK "${onedirectory}")
321 message(FATAL_ERROR "Symlinking will fail ! SCClassLibrary folder already exists and has directories inside, please delete it first." )
323 endforeach(onedirectory)
325 message(STATUS "Will create symlink of SCClassLibrary to ${auxresourcesdir}/SCClassLibrary" )
326 if(NOT EXISTS "${auxresourcesdir}/SCClassLibrary")
327 install( CODE "EXECUTE_PROCESS(COMMAND mkdir ${auxresourcesdir}/SCClassLibrary)" )
329 #symlink the folders inside SCCLassLibrary. Check if QtCollider folder should be symlinked or not.
330 file(GLOB classlibraryfolders RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary" "SCClassLibrary/[^.]*")
331 foreach(onedirectory ${classlibraryfolders})
332 if(NOT "${onedirectory}" MATCHES "${SCCLASSLIB_EXCLUDE_REGEX}")
334 "EXECUTE_PROCESS(COMMAND ln -s ${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/${onedirectory} ${auxresourcesdir}/SCClassLibrary/${onedirectory} )" )
336 endforeach(onedirectory)
338 message(STATUS "Will copy SCCLassLibrary to ${auxresourcesdir}")
339 install(DIRECTORY SCClassLibrary
340 DESTINATION ${auxresourcesdir}
341 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
345 install(DIRECTORY SCClassLibrary
346 DESTINATION ${auxresourcesdir}
347 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
354 install(DIRECTORY sounds
355 DESTINATION ${auxresourcesdir}
359 install(DIRECTORY Help
360 DESTINATION ${auxresourcesdir}
365 install(DIRECTORY examples HelpSource
366 DESTINATION ${auxresourcesdir}
372 #############################################
374 # build scdoc help files
376 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Common")
377 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Platform")
378 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/SCDoc")
379 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/DefaultLibrary")
380 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/JITLib")
381 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/backwards_compatibility")
383 # this folder has an extension to Platform that disables the loadStartupFiles method
384 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/platform/disable_startup_files")
386 foreach(arg ${BUILD_CLASSLIBRARIES})
387 set(BUILD_CLASSLIBRARYPATH "${BUILD_CLASSLIBRARYPATH}+${arg}\n")
390 configure_file(build_sclang.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg)
393 file(GLOB_RECURSE SCDocSources RELATIVE HelpSource .*[^~])
394 file(GLOB_RECURSE SCDocClasses RELATIVE SCClassLibrary/SCDoc *.sc)
396 add_custom_target(doc ALL
397 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lang/sclang${CMAKE_EXECUTABLE_SUFFIX}
398 -l ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg
399 platform/renderAllHelp.scd ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_CURRENT_BINARY_DIR}/RenderedHelp
400 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
401 DEPENDS sclang ${SCDocSources} ${SCDocClasses})
405 set_directory_properties(
407 ADDITIONAL_MAKE_CLEAN_FILES "RenderedHelp")
409 #############################################
413 add_subdirectory(testsuite)
415 #############################################
416 # win32 install support
419 install(FILES ${FFTW3F_LIBRARY} ${SNDFILE_LIBRARY} ${PTHREADS_LIBRARY} ${PORTAUDIO_LIBRARIES}
420 DESTINATION "SuperCollider"
421 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
424 #############################################
427 set(CPACK_PACKAGE_VERSION_MAJOR 3)
428 set(CPACK_PACKAGE_VERSION_MINOR 5)
429 set(CPACK_PACKAGE_VERSION_PATCH dev)
432 set(CPACK_MONOLITHIC_INSTALL 1)
435 #############################################
436 # hide advanced variables
437 mark_as_advanced(AVAHI_LIBRARIES AVAHI_INCLUDE_DIRS AVAHI_INCLUDE_DIR AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT)
439 mark_as_advanced(EMACS_EXECUTABLE)
440 mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY)
441 mark_as_advanced(JACK JACK_INCLUDE_DIR JACK_LIBRARY)
442 mark_as_advanced(MATH_LIBRARY)
443 mark_as_advanced(QT_QMAKE_EXECUTABLE)
444 mark_as_advanced(SNDFILE)