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(FATAL_ERROR "Rejecting in-place build. 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 if (${_gcc_version} VERSION_GREATER 4.0.99)
70 add_definitions("-ffast-math")
73 if (${_gcc_version} VERSION_GREATER 4.5.99)
74 add_definitions("-fpermissive") # boost.atomic is using a deprecated syntax
77 option(DSO_VISIBILITY "DSO visibility support for gcc" OFF)
80 add_definitions(-fvisibility=hidden)
84 exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info)
86 if ("${_gcc_version_info}" MATCHES "darwin10-llvm-g..-4.2")
87 message(FATAL_ERROR "llvm-gcc-4.2 was reported to be broken. please use another compiler.")
89 if ("${_gcc_version_info}" MATCHES "Apple")
90 add_definitions("-fpascal-strings")
92 add_definitions("-D_REENTRANT")
93 elseif(NOT (WIN32 AND NOT CYGWIN))
94 add_definitions("-pthread")
98 if (${CMAKE_CXX_COMPILER} MATCHES icpc)
99 set(CMAKE_COMPILER_IS_INTEL 1)
100 add_definitions(-Wno-unknown-pragmas)
101 add_definitions(-simd)
105 set_property(DIRECTORY
107 PROPERTY COMPILE_DEFINITIONS SC_DARWIN)
108 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
109 add_definitions("-DSC_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 _WINSOCKAPI_)
122 SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} /MTd")
123 SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} /MT")
128 #############################################
129 # some default libraries
131 find_package(Pthreads)
133 if (NOT PTHREADS_FOUND)
134 message(SEND_ERROR "cannot find libpthreads")
136 include_directories(${PTHREADS_INCLUDE_DIR})
141 find_library(MATH_LIBRARY m)
147 add_definitions("-DHAVE_LIBCURL")
148 include_directories(${CURL_INCLUDE_DIRS})
152 #############################################
154 option(NOVA_SIMD "Build with nova-simd support." ON)
155 option(FINAL_BUILD "Build as single source file." OFF)
157 option(CURL "Build with curl for remote file download." ON)
159 option(FFT_GREEN "Use internal 'Green' FFT lib rather than FFTW. (Not recommended.)" OFF)
160 mark_as_advanced(FFT_GREEN)
162 option(SSE "Compile with support for SSE instructions.")
163 option(SSE41 "Compile with support for SSE4.1 instructions.")
164 option(SSE42 "Compile with support for SSE4.2 instructions.")
167 option(SC_DOC_RENDER "Pre-render SCDoc documentation. (For putting online, etc)" OFF)
169 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
170 option(SUPERNOVA "Build with supernova as optional audio synthesis server" ON)
172 option(SUPERNOVA "Build with supernova as optional audio synthesis server" OFF)
175 option(SN_MEMORY_DEBUGGING "Build supernova for memory debugging (disable memory pools).")
176 option(SC_MEMORY_DEBUGGING "Build sclang&scsynth for memory debugging (disable memory pools).")
177 option(GC_SANITYCHECK "Enable sanity checks in the sclang garbage collector.")
179 option(NO_LIBSNDFILE "Disable soundfile functionality. (Not recommended.)" OFF)
180 mark_as_advanced(NO_LIBSNDFILE)
183 option(SCLANG_SERVER "Build with internal server." ON)
186 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
187 option(SC_WII "Build sclang with WII support" ON)
190 option(SC_QT "Build SuperCollider with Qt GUI" ON)
193 option(SC_PSYCOLLIDER "Build PsyCollider" ON)
195 option(SC_PSYCOLLIDER "Build PsyCollider" OFF)
198 if(CMAKE_COMPILER_IS_GNUCXX)
199 option(NATIVE "Optimize binary for this architecture (binaries may not run on other machines, requires gcc-4.3 or higher).")
200 option(LTO "Use GCC's link time optimizer' (experimental).")
203 option(SC_SYMLINK_CLASSLIB "Place a symlink of SCCLassLibrary instead of copying" OFF)
205 #############################################
206 # some preprocessor flags
207 if (CMAKE_COMPILER_IS_GNUCXX)
209 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -mfpmath=sse")
210 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -mfpmath=sse")
213 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
214 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
217 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
218 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
221 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
222 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
226 if (CMAKE_COMPILER_IS_INTEL AND NOT WIN32)
228 add_definitions(-xSSE4.2)
230 add_definitions(-xSSE4.1)
232 add_definitions(-mia32)
236 if (SC_MEMORY_DEBUGGING)
237 add_definitions(-DDISABLE_MEMORY_POOLS)
240 #############################################
242 add_subdirectory(server)
243 add_subdirectory(lang)
244 add_subdirectory(bindings)
245 add_subdirectory(platform)
246 add_subdirectory(editors)
247 add_subdirectory(external_libraries)
250 message( STATUS "Compiling with Qt GUI" )
251 add_subdirectory(QtCollider)
254 if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
255 install(DIRECTORY include/common include/plugin_interface include/server include/lang
256 DESTINATION ${CMAKE_INSTALL_PREFIX}/include/SuperCollider
257 FILES_MATCHING PATTERN "*.h"
262 # determines the app name and app install location (scappbundlename, scappdir):
263 include (cmake_modules/MacAppFolder.cmake)
265 set(auxresourcesdir ${scappauxresourcesdir})
267 # Some aux files which go in the app's folder
268 install(FILES README ChangeLog
269 DESTINATION ${auxresourcesdir}
271 install(FILES COPYING AUTHORS
272 DESTINATION ${scappdir}
275 set(auxresourcesdir "SuperCollider")
277 set(auxresourcesdir "share/SuperCollider")
281 set(SCCLASSLIB_EXCLUDE_REGEX "QtCollider")
283 set(SCCLASSLIB_EXCLUDE_REGEX "IGNOREME")
287 #if directory contains symlinks, unlink them.
288 if(EXISTS "${auxresourcesdir}/SCClassLibrary")
289 file(GLOB classlibraryfolders "${auxresourcesdir}/SCClassLibrary/[^.]*")
290 foreach(onedirectory ${classlibraryfolders})
291 if(IS_SYMLINK "${onedirectory}")
292 install( CODE "EXECUTE_PROCESS(COMMAND unlink ${onedirectory} )" )
294 endforeach(onedirectory)
297 if(SC_SYMLINK_CLASSLIB)
299 #if there are folders inside SCCLassLibrary abort cmake.
300 file(GLOB classlibraryfolders "${auxresourcesdir}/SCClassLibrary/[^.]*")
301 foreach(onedirectory ${classlibraryfolders})
302 if(NOT IS_SYMLINK "${onedirectory}")
303 message(FATAL_ERROR "Symlinking will fail ! SCClassLibrary folder already exists and has directories inside, please delete it first." )
305 endforeach(onedirectory)
307 message(STATUS "Will create symlink of SCClassLibrary to ${auxresourcesdir}/SCClassLibrary" )
308 if(NOT EXISTS "${auxresourcesdir}/SCClassLibrary")
309 install( CODE "EXECUTE_PROCESS(COMMAND mkdir ${auxresourcesdir}/SCClassLibrary)" )
311 #symlink the folders inside SCCLassLibrary. Check if QtCollider folder should be symlinked or not.
312 file(GLOB classlibraryfolders RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary" "SCClassLibrary/[^.]*")
313 foreach(onedirectory ${classlibraryfolders})
314 if(NOT "${onedirectory}" MATCHES "${SCCLASSLIB_EXCLUDE_REGEX}")
316 "EXECUTE_PROCESS(COMMAND ln -s ${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/${onedirectory} ${auxresourcesdir}/SCClassLibrary/${onedirectory} )" )
318 endforeach(onedirectory)
320 message(STATUS "Will copy SCCLassLibrary to ${auxresourcesdir}")
321 install(DIRECTORY SCClassLibrary
322 DESTINATION ${auxresourcesdir}
323 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
327 install(DIRECTORY SCClassLibrary
328 DESTINATION ${auxresourcesdir}
329 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
334 install(DIRECTORY Help examples sounds HelpSource
335 DESTINATION ${auxresourcesdir}
338 #############################################
340 # build scdoc help files
342 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Common")
343 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Platform")
344 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/SCDoc")
345 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/DefaultLibrary")
346 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/JITLib")
347 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/backwards_compatibility")
349 # this folder has an extension to Platform that disables the loadStartupFiles method
350 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/platform/disable_startup_files")
352 foreach(arg ${BUILD_CLASSLIBRARIES})
353 set(BUILD_CLASSLIBRARYPATH "${BUILD_CLASSLIBRARYPATH}+${arg}\n")
356 configure_file(build_sclang.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg)
359 file(GLOB_RECURSE SCDocSources RELATIVE HelpSource .*[^~])
360 file(GLOB_RECURSE SCDocClasses RELATIVE SCClassLibrary/SCDoc *.sc)
362 add_custom_target(doc ALL
363 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lang/sclang${CMAKE_EXECUTABLE_SUFFIX}
364 -l ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg
365 platform/renderAllHelp.scd ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_CURRENT_BINARY_DIR}/RenderedHelp
366 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
367 DEPENDS sclang ${SCDocSources} ${SCDocClasses})
371 set_directory_properties(
373 ADDITIONAL_MAKE_CLEAN_FILES "RenderedHelp")
375 #############################################
379 add_subdirectory(testsuite)
381 #############################################
382 # win32 install support
385 install(FILES ${FFTW3F_LIBRARY} ${SNDFILE_LIBRARY} ${PTHREADS_LIBRARY} ${PORTAUDIO_LIBRARIES}
386 DESTINATION "SuperCollider"
387 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
390 #############################################
393 set(CPACK_PACKAGE_VERSION_MAJOR 3)
394 set(CPACK_PACKAGE_VERSION_MINOR 5)
395 set(CPACK_PACKAGE_VERSION_PATCH dev)
398 set(CPACK_MONOLITHIC_INSTALL 1)
401 #############################################
402 # hide advanced variables
403 mark_as_advanced(AVAHI_LIBRARIES AVAHI_INCLUDE_DIRS AVAHI_INCLUDE_DIR AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT)
405 mark_as_advanced(EMACS_EXECUTABLE)
406 mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY)
407 mark_as_advanced(JACK JACK_INCLUDE_DIR JACK_LIBRARY)
408 mark_as_advanced(MATH_LIBRARY)
409 mark_as_advanced(QT_QMAKE_EXECUTABLE)
410 mark_as_advanced(SNDFILE)