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_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/SuperCollider")
111 elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
112 add_definitions("-DSC_FREEBSD")
113 add_definitions(-DSC_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/SuperCollider")
117 set_property(DIRECTORY
119 PROPERTY COMPILE_DEFINITIONS SC_WIN32 NOMINMAX _WIN32_WINNT=0x0500)
121 add_definitions(-DWIN32_LEAN_AND_MEAN)
124 SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
125 SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
128 # correctly link the static Boost Thread library:
129 add_definitions(-DBOOST_THREAD_USE_LIB)
130 #avoid unnecesary autolink
131 add_definitions(-DBOOST_DATE_TIME_NO_LIB)
135 #############################################
137 option(NOVA_SIMD "Build with nova-simd support." ON)
138 option(FINAL_BUILD "Build as single source file." OFF)
140 option(CURL "Build with curl for remote file download." ON)
142 option(FFT_GREEN "Use internal 'Green' FFT lib rather than FFTW. (Not recommended.)" OFF)
144 option(SSE "Compile with support for SSE instructions.")
145 option(SSE41 "Compile with support for SSE4.1 instructions.")
146 option(SSE42 "Compile with support for SSE4.2 instructions.")
148 set(AUDIOAPI "default" CACHE STRING "Audio API to use (one of {default,coreaudio,jack,portaudio})")
149 option(LIBSCSYNTH "Compile libscsynth as shared library" OFF)
151 option(INSTALL_HELP "Install help docs and examples along with the software" ON)
152 option(SC_DOC_RENDER "Pre-render SCDoc documentation. (For putting online, etc)" OFF)
153 option(SC_IDE "Build Qt IDE." ON)
155 option(ENABLE_TESTSUITE "Compile testsuite." ON)
157 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
158 option(SUPERNOVA "Build with supernova as optional audio synthesis server" ON)
160 option(SUPERNOVA "Build with supernova as optional audio synthesis server" OFF)
163 option(SN_MEMORY_DEBUGGING "Build supernova for memory debugging (disable memory pools).")
164 option(SC_MEMORY_DEBUGGING "Build sclang&scsynth for memory debugging (disable memory pools).")
165 option(GC_SANITYCHECK "Enable sanity checks in the sclang garbage collector.")
167 option(NO_LIBSNDFILE "Disable soundfile functionality. (Not recommended.)" OFF)
169 option(NO_AVAHI "Disable Avahi support. (Not recommended.)" OFF)
171 option(SCLANG_SERVER "Build with internal server." ON)
173 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
174 option(SC_WII "Build sclang with WII support" ON)
177 option(SC_QT "Build SuperCollider with Qt GUI" ON)
179 message( STATUS "Compiling with Qt GUI" )
183 option(SC_WIN_DEP_DIRS
184 "A list of directories where dependencies will be searched for when packaging.")
187 if(CMAKE_COMPILER_IS_GNUCXX)
188 option(NATIVE "Optimize binary for this architecture (binaries may not run on other machines, requires gcc-4.3 or higher).")
189 option(LTO "Use GCC's link time optimizer' (experimental).")
192 option(SC_SYMLINK_CLASSLIB "Place a symlink of SCCLassLibrary instead of copying" OFF)
193 option(SC_OX "Try to compile with support for C++0x (experimental, mainly related to supernova)" OFF)
195 option(SYSTEM_BOOST "Use boost libraries from system" OFF)
197 #############################################
198 # some default libraries
200 find_package(Pthreads)
202 if (NOT PTHREADS_FOUND)
203 message(SEND_ERROR "cannot find libpthreads")
205 include_directories(${PTHREADS_INCLUDE_DIR})
210 find_library(MATH_LIBRARY m)
216 add_definitions("-DHAVE_LIBCURL")
217 include_directories(${CURL_INCLUDE_DIRS})
222 set(Boost_USE_MULTITHREADED ON)
223 find_package( Boost 1.48.0 COMPONENTS thread system filesystem program_options regex test )
226 set(Boost_FOUND OFF) # boost 1.48 does not like c++11
231 link_directories(${Boost_LIBRARY_DIRS})
233 message("building boost libraries manually")
238 #############################################
239 # some preprocessor flags
240 if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
242 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -mfpmath=sse")
243 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -mfpmath=sse")
246 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
247 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
250 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
251 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
254 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
255 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
259 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
263 if (CMAKE_COMPILER_IS_INTEL AND NOT WIN32)
265 add_definitions(-xSSE4.2)
267 add_definitions(-xSSE4.1)
269 add_definitions(-mia32)
272 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
276 add_definitions(-diag-disable 170) # pointer points outside of underlying object ... used heavily in sclang
277 add_definitions(-diag-disable 279) # controlling expression is constant
281 if (SC_MEMORY_DEBUGGING)
282 add_definitions(-DDISABLE_MEMORY_POOLS)
285 #############################################
287 add_subdirectory(external_libraries)
288 add_subdirectory(server)
289 add_subdirectory(lang)
290 add_subdirectory(editors)
291 add_subdirectory(platform)
293 if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
294 install(DIRECTORY include/common include/plugin_interface include/server include/lang
295 DESTINATION ${CMAKE_INSTALL_PREFIX}/include/SuperCollider
296 FILES_MATCHING PATTERN "*.h"
301 # determines the app name and app install location (scappbundlename, scappdir):
302 include (cmake_modules/MacAppFolder.cmake)
304 set(auxresourcesdir ${scappauxresourcesdir})
306 # Some aux files which go in the app's folder
307 install(FILES README.txt ChangeLog COPYING AUTHORS platform/mac/MOVED_STUFF.txt
308 DESTINATION ${scappbundlename}
311 set(auxresourcesdir "SuperCollider")
313 set(auxresourcesdir "share/SuperCollider")
316 set(SCCLASSLIB_EXCLUDE_REGEX "IGNOREME")
319 set(SCCLASSLIB_EXCLUDE_REGEX "${SCCLASSLIB_EXCLUDE_REGEX}|QtCollider")
323 set(SCCLASSLIB_EXCLUDE_REGEX "${SCCLASSLIB_EXCLUDE_REGEX}")
329 if(SC_SYMLINK_CLASSLIB)
331 #if there are folders inside SCCLassLibrary abort cmake.
332 file(GLOB classlibraryfolders "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/[^.]*")
333 foreach(onedirectory ${classlibraryfolders})
334 message( "${onedirectory}" )
335 if(NOT IS_SYMLINK "${onedirectory}")
336 message(FATAL_ERROR "Symlinking will fail ! SCClassLibrary folder already exists and has directories inside, please delete it first." )
338 endforeach(onedirectory)
340 message(STATUS "Will create symlink of SCClassLibrary to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary" )
341 if(NOT EXISTS "{CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary")
342 install( CODE "EXECUTE_PROCESS(COMMAND mkdir ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary)" )
344 #symlink the folders inside SCCLassLibrary. Check if QtCollider folder should be symlinked or not.
345 file(GLOB classlibraryfolders RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary" "SCClassLibrary/[^.]*")
346 foreach(onedirectory ${classlibraryfolders})
347 if(NOT "${onedirectory}" MATCHES "${SCCLASSLIB_EXCLUDE_REGEX}")
349 "EXECUTE_PROCESS(COMMAND ln -shF ${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/${onedirectory} ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/${onedirectory} )" )
351 endforeach(onedirectory)
353 message(STATUS "Will copy SCCLassLibrary to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}")
355 #if directory contains symlinks, unlink them.
356 if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary")
357 file(GLOB classlibraryfolders "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/[^.]*")
358 foreach(onedirectory ${classlibraryfolders})
359 if(IS_SYMLINK "${onedirectory}")
360 message(STATUS "Unlinking ${onedirectory}")
361 install( CODE "EXECUTE_PROCESS(COMMAND unlink ${onedirectory} )" )
363 endforeach(onedirectory)
366 install(DIRECTORY SCClassLibrary
367 DESTINATION ${auxresourcesdir}
368 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
372 install(DIRECTORY SCClassLibrary
373 DESTINATION ${auxresourcesdir}
374 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
380 configure_file(platform/SCVersion.sc.in SCVersion/SCVersion.sc)
381 install(DIRECTORY "${CMAKE_BINARY_DIR}/SCVersion" DESTINATION "${auxresourcesdir}/SCClassLibrary")
383 install(DIRECTORY sounds
384 DESTINATION ${auxresourcesdir}
387 if(APPLE AND ("${standalone}" STREQUAL ""))
388 set(exampledir "${scappbundlename}")
390 set(exampledir "${auxresourcesdir}")
393 install(DIRECTORY examples
394 DESTINATION ${exampledir}
400 if(SC_SYMLINK_CLASSLIB AND APPLE)
401 message(STATUS "Will create symlink of HelpSource to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
402 if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
403 message(FATAL_ERROR "Symlinking will fail ! HelpSource folder already exists, please delete it first." )
406 "EXECUTE_PROCESS(COMMAND ln -shF ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource )" )
408 message(STATUS "Will copy HelpSource to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}")
410 if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
411 if(IS_SYMLINK "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
412 message(STATUS "Unlinking ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
413 install( CODE "EXECUTE_PROCESS(COMMAND unlink ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource )" )
417 install(DIRECTORY HelpSource
418 DESTINATION ${auxresourcesdir}
425 #############################################
427 # build scdoc help files
429 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Common")
430 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Platform")
431 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/SCDoc")
432 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/DefaultLibrary")
433 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/JITLib")
434 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/backwards_compatibility")
436 # this folder has an extension to Platform that disables the loadStartupFiles method
437 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/platform/disable_startup_files")
439 foreach(arg ${BUILD_CLASSLIBRARIES})
440 set(BUILD_CLASSLIBRARYPATH "${BUILD_CLASSLIBRARYPATH}+${arg}\n")
443 configure_file(build_sclang.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg)
446 file(GLOB_RECURSE SCDocSources RELATIVE HelpSource .*[^~])
447 file(GLOB_RECURSE SCDocClasses RELATIVE SCClassLibrary/SCDoc *.sc)
449 add_custom_target(doc ALL
450 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lang/sclang${CMAKE_EXECUTABLE_SUFFIX}
451 -l ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg
452 platform/renderAllHelp.scd ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_CURRENT_BINARY_DIR}/RenderedHelp
453 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
454 DEPENDS sclang ${SCDocSources} ${SCDocClasses})
458 set_directory_properties(
460 ADDITIONAL_MAKE_CLEAN_FILES "RenderedHelp")
462 #############################################
467 add_subdirectory(testsuite)
470 #############################################
473 set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
474 set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
475 set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
478 set(CPACK_GENERATOR "DragNDrop")
479 set(CPACK_DMG_FORMAT "UDBZ")
480 set(CPACK_DMG_VOLUME_NAME "${scappbundlename}")
481 set(CPACK_SYSTEM_NAME "OSX")
482 # set(CPACK_PACKAGE_FILE_NAME "${scappbundlename}-${PROJECT_VERSION}")
483 set(CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/package/ds_store")
484 set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/package/background.png")
485 set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/platform/mac/Resources/SCcube.icns")
488 if(NOT WIN32) # We define a custom 'package' target in platform/windows/CMakeLists.txt
492 #############################################
493 # hide advanced variables
494 mark_as_advanced(AVAHI_LIBRARIES AVAHI_INCLUDE_DIRS AVAHI_INCLUDE_DIR AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT)
496 mark_as_advanced(EMACS_EXECUTABLE)
497 mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY)
498 mark_as_advanced(JACK JACK_INCLUDE_DIR JACK_LIBRARY)
499 mark_as_advanced(MATH_LIBRARY)
500 mark_as_advanced(QT_QMAKE_EXECUTABLE)
501 mark_as_advanced(SNDFILE)