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 #############################################
204 # some preprocessor flags
205 if (CMAKE_COMPILER_IS_GNUCXX)
207 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -mfpmath=sse")
208 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -mfpmath=sse")
211 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
212 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
215 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
216 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
219 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
220 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
224 if (CMAKE_COMPILER_IS_INTEL AND NOT WIN32)
226 add_definitions(-xSSE4.2)
228 add_definitions(-xSSE4.1)
230 add_definitions(-mia32)
234 if (SC_MEMORY_DEBUGGING)
235 add_definitions(-DDISABLE_MEMORY_POOLS)
238 #############################################
240 add_subdirectory(server)
241 add_subdirectory(lang)
242 add_subdirectory(bindings)
243 add_subdirectory(platform)
244 add_subdirectory(editors)
245 add_subdirectory(external_libraries)
248 message( STATUS "Compiling with Qt GUI" )
249 add_subdirectory(QtCollider)
252 if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
253 install(DIRECTORY include/common include/plugin_interface include/server include/lang
254 DESTINATION ${CMAKE_INSTALL_PREFIX}/include/SuperCollider
255 FILES_MATCHING PATTERN "*.h"
260 # determines the app name and app install location (scappbundlename, scappdir):
261 include (cmake_modules/MacAppFolder.cmake)
263 set(auxresourcesdir ${scappauxresourcesdir})
265 # Some aux files which go in the app's folder
266 install(FILES README ChangeLog
267 DESTINATION ${auxresourcesdir}
269 install(FILES COPYING AUTHORS
270 DESTINATION ${scappdir}
273 set(auxresourcesdir "SuperCollider")
275 set(auxresourcesdir "share/SuperCollider")
279 set(SCCLASSLIB_EXCLUDE_REGEX "QtCollider")
281 set(SCCLASSLIB_EXCLUDE_REGEX "IGNOREME")
284 install(DIRECTORY SCClassLibrary
285 DESTINATION ${auxresourcesdir}
286 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
289 install(DIRECTORY Help examples sounds HelpSource
290 DESTINATION ${auxresourcesdir}
293 #############################################
295 # build scdoc help files
297 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Common")
298 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Platform")
299 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/SCDoc")
300 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/DefaultLibrary")
301 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/JITLib")
302 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/backwards_compatibility")
304 # this folder has an extension to Platform that disables the loadStartupFiles method
305 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/platform/disable_startup_files")
307 foreach(arg ${BUILD_CLASSLIBRARIES})
308 set(BUILD_CLASSLIBRARYPATH "${BUILD_CLASSLIBRARYPATH}+${arg}\n")
311 configure_file(build_sclang.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg)
314 file(GLOB_RECURSE SCDocSources RELATIVE HelpSource .*[^~])
315 file(GLOB_RECURSE SCDocClasses RELATIVE SCClassLibrary/SCDoc *.sc)
317 add_custom_target(doc ALL
318 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lang/sclang${CMAKE_EXECUTABLE_SUFFIX}
319 -l ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg
320 platform/renderAllHelp.scd ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_CURRENT_BINARY_DIR}/RenderedHelp
321 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
322 DEPENDS sclang ${SCDocSources} ${SCDocClasses})
326 set_directory_properties(
328 ADDITIONAL_MAKE_CLEAN_FILES "RenderedHelp")
330 #############################################
334 add_subdirectory(testsuite)
336 #############################################
337 # win32 install support
340 install(FILES ${FFTW3F_LIBRARY} ${SNDFILE_LIBRARY} ${PTHREADS_LIBRARY} ${PORTAUDIO_LIBRARIES}
341 DESTINATION "SuperCollider"
342 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
345 #############################################
348 set(CPACK_PACKAGE_VERSION_MAJOR 3)
349 set(CPACK_PACKAGE_VERSION_MINOR 5)
350 set(CPACK_PACKAGE_VERSION_PATCH dev)
353 set(CPACK_MONOLITHIC_INSTALL 1)
356 #############################################
357 # hide advanced variables
358 mark_as_advanced(AVAHI_LIBRARIES AVAHI_INCLUDE_DIRS AVAHI_INCLUDE_DIR AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT)
360 mark_as_advanced(EMACS_EXECUTABLE)
361 mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY)
362 mark_as_advanced(JACK JACK_INCLUDE_DIR JACK_LIBRARY)
363 mark_as_advanced(MATH_LIBRARY)
364 mark_as_advanced(QT_QMAKE_EXECUTABLE)
365 mark_as_advanced(SNDFILE)