1 cmake_minimum_required (VERSION 2.8)
2 project (SuperCollider)
4 include("SCVersion.txt")
5 set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}${PROJECT_VERSION_PATCH}")
6 message(STATUS "SuperCollider Version: ${PROJECT_VERSION}")
11 include (cmake_modules/FinalFile.cmake)
13 if (NOT CMAKE_BUILD_TYPE)
14 message(STATUS "Build type defaulting to \"RelWithDebInfo\"")
15 set(CMAKE_BUILD_TYPE "RelWithDebInfo")
18 if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
19 message(WARNING "WARNING: IN-PLACE BUILDS ARE NOT RECOMMENDED - PLEASE USE A BUILD DIRECTORY")
23 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules
27 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/cmake_uninstall.cmake.in"
28 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
31 ADD_CUSTOM_TARGET(uninstall
32 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
35 STRING(REGEX REPLACE "^.*MacOSX10.([0-9]+).*$" "\\1" MAC_OSX_SDK_VERSION "${CMAKE_OSX_SYSROOT}")
37 if(CMAKE_OSX_DEPLOYMENT_TARGET)
38 if (CMAKE_OSX_DEPLOYMENT_TARGET GREATER 10.4)
39 set(HID_UTIL_DIR "HID_Utilities")
41 set(HID_UTIL_DIR "HID_Utilities_10_4")
44 if (${MAC_OSX_SDK_VERSION} GREATER 4)
45 set(HID_UTIL_DIR "HID_Utilities")
47 set(HID_UTIL_DIR "HID_Utilities_10_4")
50 MESSAGE( STATUS "Using HID Utilities from folder '${HID_UTIL_DIR}'")
53 if (CMAKE_SYSTEM_NAME MATCHES "Linux")
57 #############################################
60 if (${CMAKE_COMPILER_IS_GNUCXX})
61 exec_program(${CMAKE_CXX_COMPILER} ARGS -dumpversion OUTPUT_VARIABLE _gcc_version)
63 add_definitions("-fschedule-insns2" "-fomit-frame-pointer")
65 add_definitions("-Wreturn-type")
67 # disabled for now: -ffast-math breaks avx intrinsics and -fsigned-zeros/-fno-associative-math are not available in some versions
68 # if (${_gcc_version} VERSION_GREATER 4.0.99)
69 # add_definitions("-ffast-math -fsigned-zeros -fno-associative-math")
72 option(DSO_VISIBILITY "DSO visibility support for gcc" OFF)
75 add_definitions(-fvisibility=hidden)
79 exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info)
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")
89 if (${CMAKE_CXX_COMPILER} MATCHES icpc)
90 set(CMAKE_COMPILER_IS_INTEL 1)
91 add_definitions(-Wno-unknown-pragmas)
92 add_definitions(-simd)
95 if (${CMAKE_CXX_COMPILER} MATCHES clang)
96 option(DSO_VISIBILITY "DSO visibility support for clang" OFF)
99 add_definitions(-fvisibility=hidden)
102 set(CMAKE_COMPILER_IS_CLANG 1)
106 set_property(DIRECTORY
108 PROPERTY COMPILE_DEFINITIONS SC_DARWIN)
109 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
110 add_definitions("-DSC_LINUX")
111 add_definitions(-DSC_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/SuperCollider")
112 elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
113 add_definitions("-DSC_FREEBSD")
114 add_definitions(-DSC_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/SuperCollider")
118 set_property(DIRECTORY
120 PROPERTY COMPILE_DEFINITIONS SC_WIN32 NOMINMAX _WIN32_WINNT=0x0500)
122 add_definitions(-DWIN32_LEAN_AND_MEAN)
125 SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
126 SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
129 # correctly link the static Boost Thread library:
130 add_definitions(-DBOOST_THREAD_USE_LIB)
131 #avoid unnecesary autolink
132 add_definitions(-DBOOST_DATE_TIME_NO_LIB)
136 #############################################
138 option(NOVA_SIMD "Build with nova-simd support." ON)
139 option(FINAL_BUILD "Build as single source file." OFF)
141 option(CURL "Build with curl for remote file download." ON)
143 option(FFT_GREEN "Use internal 'Green' FFT lib rather than FFTW. (Not recommended.)" OFF)
145 option(SSE "Compile with support for SSE instructions.")
146 option(SSE41 "Compile with support for SSE4.1 instructions.")
147 option(SSE42 "Compile with support for SSE4.2 instructions.")
149 set(AUDIOAPI "default" CACHE STRING "Audio API to use (one of {default,coreaudio,jack,portaudio})")
150 option(LIBSCSYNTH "Compile libscsynth as shared library" OFF)
152 option(INSTALL_HELP "Install help docs and examples along with the software" ON)
153 option(SC_DOC_RENDER "Pre-render SCDoc documentation. (For putting online, etc)" OFF)
154 option(SC_IDE "Build Qt IDE." ON)
156 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
157 option(SUPERNOVA "Build with supernova as optional audio synthesis server" ON)
159 option(SUPERNOVA "Build with supernova as optional audio synthesis server" OFF)
162 option(SN_MEMORY_DEBUGGING "Build supernova for memory debugging (disable memory pools).")
163 option(SC_MEMORY_DEBUGGING "Build sclang&scsynth for memory debugging (disable memory pools).")
164 option(GC_SANITYCHECK "Enable sanity checks in the sclang garbage collector.")
166 option(NO_LIBSNDFILE "Disable soundfile functionality. (Not recommended.)" OFF)
168 option(NO_AVAHI "Disable Avahi support. (Not recommended.)" OFF)
170 option(SCLANG_SERVER "Build with internal server." ON)
172 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
173 option(SC_WII "Build sclang with WII support" ON)
176 option(SC_QT "Build SuperCollider with Qt GUI" ON)
178 message( STATUS "Compiling with Qt GUI" )
182 option(SC_WIN_DEP_DIRS
183 "A list of directories where dependencies will be searched for when packaging.")
186 if(CMAKE_COMPILER_IS_GNUCXX)
187 option(NATIVE "Optimize binary for this architecture (binaries may not run on other machines, requires gcc-4.3 or higher).")
188 option(LTO "Use GCC's link time optimizer' (experimental).")
191 option(SC_SYMLINK_CLASSLIB "Place a symlink of SCCLassLibrary instead of copying" OFF)
192 option(SC_OX "Try to compile with support for C++0x (experimental, mainly related to supernova)" OFF)
194 option(SYSTEM_BOOST "Use boost libraries from system" OFF)
196 #############################################
197 # some default libraries
199 find_package(Pthreads)
201 if (NOT PTHREADS_FOUND)
202 message(SEND_ERROR "cannot find libpthreads")
204 include_directories(${PTHREADS_INCLUDE_DIR})
209 find_library(MATH_LIBRARY m)
215 add_definitions("-DHAVE_LIBCURL")
216 include_directories(${CURL_INCLUDE_DIRS})
221 set(Boost_USE_MULTITHREADED ON)
222 find_package( Boost 1.48.0 COMPONENTS thread system filesystem program_options regex test )
225 set(Boost_FOUND OFF) # boost 1.48 does not like c++11
230 link_directories(${Boost_LIBRARY_DIRS})
232 message("building boost libraries manually")
237 #############################################
238 # some preprocessor flags
239 if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
241 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -mfpmath=sse")
242 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -mfpmath=sse")
245 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
246 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
249 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
250 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
253 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
254 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
258 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
262 if (CMAKE_COMPILER_IS_INTEL AND NOT WIN32)
264 add_definitions(-xSSE4.2)
266 add_definitions(-xSSE4.1)
268 add_definitions(-mia32)
271 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
275 add_definitions(-diag-disable 170) # pointer points outside of underlying object ... used heavily in sclang
276 add_definitions(-diag-disable 279) # controlling expression is constant
280 if (SC_MEMORY_DEBUGGING)
281 add_definitions(-DDISABLE_MEMORY_POOLS)
284 #############################################
286 add_subdirectory(external_libraries)
287 add_subdirectory(server)
288 add_subdirectory(lang)
289 add_subdirectory(editors)
290 add_subdirectory(platform)
292 if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
293 install(DIRECTORY include/common include/plugin_interface include/server include/lang
294 DESTINATION ${CMAKE_INSTALL_PREFIX}/include/SuperCollider
295 FILES_MATCHING PATTERN "*.h"
300 # determines the app name and app install location (scappbundlename, scappdir):
301 include (cmake_modules/MacAppFolder.cmake)
303 set(auxresourcesdir ${scappauxresourcesdir})
305 # Some aux files which go in the app's folder
306 install(FILES README.txt ChangeLog COPYING AUTHORS platform/mac/MOVED_STUFF.txt
307 DESTINATION ${scappbundlename}
310 set(auxresourcesdir "SuperCollider")
312 set(auxresourcesdir "share/SuperCollider")
315 set(SCCLASSLIB_EXCLUDE_REGEX "IGNOREME")
318 set(SCCLASSLIB_EXCLUDE_REGEX "${SCCLASSLIB_EXCLUDE_REGEX}|QtCollider")
322 set(SCCLASSLIB_EXCLUDE_REGEX "${SCCLASSLIB_EXCLUDE_REGEX}")
328 if(SC_SYMLINK_CLASSLIB)
330 #if there are folders inside SCCLassLibrary abort cmake.
331 file(GLOB classlibraryfolders "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/[^.]*")
332 foreach(onedirectory ${classlibraryfolders})
333 message( "${onedirectory}" )
334 if(NOT IS_SYMLINK "${onedirectory}")
335 message(FATAL_ERROR "Symlinking will fail ! SCClassLibrary folder already exists and has directories inside, please delete it first." )
337 endforeach(onedirectory)
339 message(STATUS "Will create symlink of SCClassLibrary to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary" )
340 if(NOT EXISTS "{CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary")
341 install( CODE "EXECUTE_PROCESS(COMMAND mkdir ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary)" )
343 #symlink the folders inside SCCLassLibrary. Check if QtCollider folder should be symlinked or not.
344 file(GLOB classlibraryfolders RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary" "SCClassLibrary/[^.]*")
345 foreach(onedirectory ${classlibraryfolders})
346 if(NOT "${onedirectory}" MATCHES "${SCCLASSLIB_EXCLUDE_REGEX}")
348 "EXECUTE_PROCESS(COMMAND ln -shF ${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/${onedirectory} ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/${onedirectory} )" )
350 endforeach(onedirectory)
352 message(STATUS "Will copy SCCLassLibrary to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}")
354 #if directory contains symlinks, unlink them.
355 if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary")
356 file(GLOB classlibraryfolders "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/[^.]*")
357 foreach(onedirectory ${classlibraryfolders})
358 if(IS_SYMLINK "${onedirectory}")
359 message(STATUS "Unlinking ${onedirectory}")
360 install( CODE "EXECUTE_PROCESS(COMMAND unlink ${onedirectory} )" )
362 endforeach(onedirectory)
365 install(DIRECTORY SCClassLibrary
366 DESTINATION ${auxresourcesdir}
367 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
371 install(DIRECTORY SCClassLibrary
372 DESTINATION ${auxresourcesdir}
373 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
379 configure_file(platform/SCVersion.sc.in SCVersion/SCVersion.sc)
380 install(DIRECTORY "${CMAKE_BINARY_DIR}/SCVersion" DESTINATION "${auxresourcesdir}/SCClassLibrary")
382 install(DIRECTORY sounds
383 DESTINATION ${auxresourcesdir}
386 if(APPLE AND ("${standalone}" STREQUAL ""))
387 set(exampledir "${scappbundlename}")
389 set(exampledir "${auxresourcesdir}")
392 install(DIRECTORY examples
393 DESTINATION ${exampledir}
399 if(SC_SYMLINK_CLASSLIB AND APPLE)
400 message(STATUS "Will create symlink of HelpSource to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
401 if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
402 message(FATAL_ERROR "Symlinking will fail ! HelpSource folder already exists, please delete it first." )
405 "EXECUTE_PROCESS(COMMAND ln -shF ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource )" )
407 message(STATUS "Will copy HelpSource to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}")
409 if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
410 if(IS_SYMLINK "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
411 message(STATUS "Unlinking ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
412 install( CODE "EXECUTE_PROCESS(COMMAND unlink ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource )" )
416 install(DIRECTORY HelpSource
417 DESTINATION ${auxresourcesdir}
424 #############################################
426 # build scdoc help files
428 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Common")
429 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Platform")
430 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/SCDoc")
431 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/DefaultLibrary")
432 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/JITLib")
433 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/backwards_compatibility")
435 # this folder has an extension to Platform that disables the loadStartupFiles method
436 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/platform/disable_startup_files")
438 foreach(arg ${BUILD_CLASSLIBRARIES})
439 set(BUILD_CLASSLIBRARYPATH "${BUILD_CLASSLIBRARYPATH}+${arg}\n")
442 configure_file(build_sclang.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg)
445 file(GLOB_RECURSE SCDocSources RELATIVE HelpSource .*[^~])
446 file(GLOB_RECURSE SCDocClasses RELATIVE SCClassLibrary/SCDoc *.sc)
448 add_custom_target(doc ALL
449 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lang/sclang${CMAKE_EXECUTABLE_SUFFIX}
450 -l ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg
451 platform/renderAllHelp.scd ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_CURRENT_BINARY_DIR}/RenderedHelp
452 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
453 DEPENDS sclang ${SCDocSources} ${SCDocClasses})
457 set_directory_properties(
459 ADDITIONAL_MAKE_CLEAN_FILES "RenderedHelp")
461 #############################################
465 add_subdirectory(testsuite)
467 #############################################
470 set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
471 set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
472 set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
475 set(CPACK_GENERATOR "DragNDrop")
476 set(CPACK_DMG_FORMAT "UDBZ")
477 set(CPACK_DMG_VOLUME_NAME "${scappbundlename}")
478 set(CPACK_SYSTEM_NAME "OSX")
479 # set(CPACK_PACKAGE_FILE_NAME "${scappbundlename}-${PROJECT_VERSION}")
480 set(CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/package/ds_store")
481 set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/package/background.png")
482 set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/platform/mac/Resources/SCcube.icns")
485 if(NOT WIN32) # We define a custom 'package' target in platform/windows/CMakeLists.txt
489 #############################################
490 # hide advanced variables
491 mark_as_advanced(AVAHI_LIBRARIES AVAHI_INCLUDE_DIRS AVAHI_INCLUDE_DIR AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT)
493 mark_as_advanced(EMACS_EXECUTABLE)
494 mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY)
495 mark_as_advanced(JACK JACK_INCLUDE_DIR JACK_LIBRARY)
496 mark_as_advanced(MATH_LIBRARY)
497 mark_as_advanced(QT_QMAKE_EXECUTABLE)
498 mark_as_advanced(SNDFILE)