scide: don't try to select region on double-click
[supercollider.git] / CMakeLists.txt
blob307cccfb79351ea441edbf8d53379e3aae2db696
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}")
8 include(CTest)
9 enable_testing()
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")
16 endif()
18 if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
19         message(WARNING "WARNING: IN-PLACE BUILDS ARE NOT RECOMMENDED - PLEASE USE A BUILD DIRECTORY")
20 endif()
23 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules
24                       ${CMAKE_MODULE_PATH})
26 CONFIGURE_FILE(
27   "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/cmake_uninstall.cmake.in"
28   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
29   IMMEDIATE @ONLY)
31 ADD_CUSTOM_TARGET(uninstall
32   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
34 if(APPLE)
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")
40                 else()
41                         set(HID_UTIL_DIR "HID_Utilities_10_4")
42                 endif()
43         else()
44                 if (${MAC_OSX_SDK_VERSION} GREATER 4)
45                         set(HID_UTIL_DIR "HID_Utilities")
46                 else()
47                         set(HID_UTIL_DIR "HID_Utilities_10_4")
48                 endif()
49         endif()
50         MESSAGE( STATUS "Using HID Utilities from folder '${HID_UTIL_DIR}'")
51 endif()
53 if (CMAKE_SYSTEM_NAME MATCHES "Linux")
54         set(LINUX 1)
55 endif()
57 #############################################
58 # Compiler flags etc
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")
70 #       endif()
72         option(DSO_VISIBILITY "DSO visibility support for gcc" OFF)
74         if (DSO_VISIBILITY)
75                 add_definitions(-fvisibility=hidden)
76         endif()
78         if(APPLE)
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")
82                 endif()
83                 add_definitions("-D_REENTRANT")
84         elseif(NOT (WIN32 AND NOT CYGWIN))
85                 add_definitions("-pthread")
86         endif()
87 endif ()
89 if (${CMAKE_CXX_COMPILER} MATCHES icpc)
90         set(CMAKE_COMPILER_IS_INTEL 1)
91         add_definitions(-Wno-unknown-pragmas)
92         add_definitions(-simd)
93 endif()
95 if (${CMAKE_CXX_COMPILER} MATCHES clang)
96         option(DSO_VISIBILITY "DSO visibility support for clang" OFF)
98         if (DSO_VISIBILITY)
99                 add_definitions(-fvisibility=hidden)
100         endif()
102         set(CMAKE_COMPILER_IS_CLANG 1)
103 endif()
105 if(APPLE)
106         set_property(DIRECTORY
107                 APPEND
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")
115 endif()
117 if(WIN32)
118     set_property(DIRECTORY
119                  APPEND
120                  PROPERTY COMPILE_DEFINITIONS SC_WIN32 NOMINMAX _WIN32_WINNT=0x0500)
122     add_definitions(-DWIN32_LEAN_AND_MEAN)
124     if(MSVC)
125         SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
126         SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
127     endif()
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)
133 endif()
136 #############################################
137 # Options
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)
158 elseif()
159     option(SUPERNOVA "Build with supernova as optional audio synthesis server" OFF)
160 endif()
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)
174 endif()
176 option(SC_QT "Build SuperCollider with Qt GUI" ON)
177 if (SC_QT)
178   message( STATUS "Compiling with Qt GUI" )
179 endif (SC_QT)
181 if(WIN32)
182     option(SC_WIN_DEP_DIRS
183         "A list of directories where dependencies will be searched for when packaging.")
184 endif()
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).")
189 endif()
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")
203 endif()
204 include_directories(${PTHREADS_INCLUDE_DIR})
206 if (MSVC OR MINGW)
207     set(MATH_LIBRARY "")
208 else()
209     find_library(MATH_LIBRARY m)
210 endif()
212 if(CURL)
213         find_package(CURL)
214         if(CURL_FOUND)
215                 add_definitions("-DHAVE_LIBCURL")
216                 include_directories(${CURL_INCLUDE_DIRS})
217         endif()
218 endif()
220 if (SYSTEM_BOOST)
221   set(Boost_USE_MULTITHREADED      ON)
222   find_package( Boost 1.48.0 COMPONENTS thread system filesystem program_options regex test )
224   if (SC_OX)
225           set(Boost_FOUND OFF) # boost 1.48 does not like c++11
226   endif()
227 endif()
229 if (Boost_FOUND)
230         link_directories(${Boost_LIBRARY_DIRS})
231 else()
232         message("building boost libraries manually")
233 endif()
237 #############################################
238 # some preprocessor flags
239 if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
240         if (SSE)
241                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -mfpmath=sse")
242                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -mfpmath=sse")
243         endif()
244         if (SSE41)
245                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
246                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
247         endif()
248         if (SSE42)
249                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
250                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
251         endif()
252         if (NATIVE)
253                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
254                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
255         endif()
257         if (SC_OX)
258                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
259         endif()
260 endif()
262 if (CMAKE_COMPILER_IS_INTEL AND NOT WIN32)
263         if (SSE42)
264                 add_definitions(-xSSE4.2)
265         elseif (SSE41)
266                 add_definitions(-xSSE4.1)
267         elseif (SSE)
268                 add_definitions(-mia32)
269         endif()
270         if (SC_OX)
271                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
272         endif()
274         # disable warnings
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
278 endif()
280 if (SC_MEMORY_DEBUGGING)
281         add_definitions(-DDISABLE_MEMORY_POOLS)
282 endif()
284 #############################################
285 # subdirectories
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"
296     )
297 endif()
299 if(APPLE)
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}
308         )
309 elseif (WIN32)
310         set(auxresourcesdir "SuperCollider")
311 else()
312         set(auxresourcesdir "share/SuperCollider")
313 endif()
315 set(SCCLASSLIB_EXCLUDE_REGEX "IGNOREME")
317 if(NOT SC_QT)
318         set(SCCLASSLIB_EXCLUDE_REGEX "${SCCLASSLIB_EXCLUDE_REGEX}|QtCollider")
319 endif()
321 if(WIN32)
322         set(SCCLASSLIB_EXCLUDE_REGEX "${SCCLASSLIB_EXCLUDE_REGEX}")
323 endif()
326 if(APPLE)
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." )
336                         endif()
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)" )
342                 endif()
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}")
347                                 install( CODE
348                                         "EXECUTE_PROCESS(COMMAND ln -shF ${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/${onedirectory} ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/${onedirectory} )" )
349                         endif()
350                 endforeach(onedirectory)
351         else()
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} )" )
361                                 endif()
362                         endforeach(onedirectory)
363                 endif()
365                 install(DIRECTORY SCClassLibrary
366                         DESTINATION ${auxresourcesdir}
367                         REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
368                 )
369         endif()
370 else()
371         install(DIRECTORY SCClassLibrary
372                 DESTINATION ${auxresourcesdir}
373                 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
374                 PATTERN "*~" EXCLUDE
375                 PATTERN "*#" EXCLUDE
376         )
377 endif()
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}")
388 else()
389         set(exampledir "${auxresourcesdir}")
390 endif()
392 install(DIRECTORY examples
393         DESTINATION ${exampledir}
394         PATTERN "*~" EXCLUDE
395         PATTERN "*#" EXCLUDE
398 if(INSTALL_HELP)
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." )
403                 endif()
404                 install( CODE
405                                         "EXECUTE_PROCESS(COMMAND ln -shF ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource )" )
406         else()
407                 message(STATUS "Will copy HelpSource to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}")
408                 if(APPLE)
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 )" )
413                                 endif()
414                         endif()
415                 endif()
416                 install(DIRECTORY HelpSource
417                         DESTINATION ${auxresourcesdir}
418                         PATTERN "*~" EXCLUDE
419                         PATTERN "*#" EXCLUDE
420                 )
421         endif()
422 endif()
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")
440 endforeach()
442 configure_file(build_sclang.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg)
444 if(SC_DOC_RENDER)
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})
455 endif()
457 set_directory_properties(
458         PROPERTIES
459         ADDITIONAL_MAKE_CLEAN_FILES "RenderedHelp")
461 #############################################
463 # testsuite
465 add_subdirectory(testsuite)
467 #############################################
468 # CPack support
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})
474 if(APPLE)
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")
483 endif()
485 if(NOT WIN32) # We define a custom 'package' target in platform/windows/CMakeLists.txt
486     include(CPack)
487 endif()
489 #############################################
490 # hide advanced variables
491 mark_as_advanced(AVAHI_LIBRARIES AVAHI_INCLUDE_DIRS AVAHI_INCLUDE_DIR AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT)
492 mark_as_advanced(DL)
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)