scide: LookupDialog - use more expressive function names
[supercollider.git] / CMakeLists.txt
blobe71720c683ea986504890bcf5d82861168dc2aea
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_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")
114 endif()
116 if(WIN32)
117     set_property(DIRECTORY
118                  APPEND
119                  PROPERTY COMPILE_DEFINITIONS SC_WIN32 NOMINMAX _WIN32_WINNT=0x0500)
121     add_definitions(-DWIN32_LEAN_AND_MEAN)
123     if(MSVC)
124         SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
125         SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
126     endif()
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)
132 endif()
135 #############################################
136 # Options
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 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
156     option(SUPERNOVA "Build with supernova as optional audio synthesis server" ON)
157 elseif()
158     option(SUPERNOVA "Build with supernova as optional audio synthesis server" OFF)
159 endif()
161 option(SN_MEMORY_DEBUGGING "Build supernova for memory debugging (disable memory pools).")
162 option(SC_MEMORY_DEBUGGING "Build sclang&scsynth for memory debugging (disable memory pools).")
163 option(GC_SANITYCHECK "Enable sanity checks in the sclang garbage collector.")
165 option(NO_LIBSNDFILE "Disable soundfile functionality. (Not recommended.)" OFF)
167 option(NO_AVAHI "Disable Avahi support. (Not recommended.)" OFF)
169 option(SCLANG_SERVER "Build with internal server." ON)
171 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
172         option(SC_WII "Build sclang with WII support" ON)
173 endif()
175 option(SC_QT "Build SuperCollider with Qt GUI" ON)
176 if (SC_QT)
177   message( STATUS "Compiling with Qt GUI" )
178 endif (SC_QT)
180 if(WIN32)
181     option(SC_WIN_DEP_DIRS
182         "A list of directories where dependencies will be searched for when packaging.")
183 endif()
185 if(CMAKE_COMPILER_IS_GNUCXX)
186     option(NATIVE "Optimize binary for this architecture (binaries may not run on other machines, requires gcc-4.3 or higher).")
187     option(LTO "Use GCC's link time optimizer' (experimental).")
188 endif()
190 option(SC_SYMLINK_CLASSLIB "Place a symlink of SCCLassLibrary instead of copying" OFF)
191 option(SC_OX "Try to compile with support for C++0x (experimental, mainly related to supernova)" OFF)
193 option(SYSTEM_BOOST "Use boost libraries from system" OFF)
195 #############################################
196 # some default libraries
198 find_package(Pthreads)
200 if (NOT PTHREADS_FOUND)
201     message(SEND_ERROR "cannot find libpthreads")
202 endif()
203 include_directories(${PTHREADS_INCLUDE_DIR})
205 if (MSVC OR MINGW)
206     set(MATH_LIBRARY "")
207 else()
208     find_library(MATH_LIBRARY m)
209 endif()
211 if(CURL)
212         find_package(CURL)
213         if(CURL_FOUND)
214                 add_definitions("-DHAVE_LIBCURL")
215                 include_directories(${CURL_INCLUDE_DIRS})
216         endif()
217 endif()
219 if (SYSTEM_BOOST)
220   set(Boost_USE_MULTITHREADED      ON)
221   find_package( Boost 1.48.0 COMPONENTS thread system filesystem program_options regex test )
223   if (SC_OX)
224           set(Boost_FOUND OFF) # boost 1.48 does not like c++11
225   endif()
226 endif()
228 if (Boost_FOUND)
229         link_directories(${Boost_LIBRARY_DIRS})
230 else()
231         message("building boost libraries manually")
232 endif()
236 #############################################
237 # some preprocessor flags
238 if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
239         if (SSE)
240                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -mfpmath=sse")
241                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -mfpmath=sse")
242         endif()
243         if (SSE41)
244                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
245                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
246         endif()
247         if (SSE42)
248                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
249                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
250         endif()
251         if (NATIVE)
252                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
253                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
254         endif()
256         if (SC_OX)
257                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
258         endif()
259 endif()
261 if (CMAKE_COMPILER_IS_INTEL AND NOT WIN32)
262         if (SSE42)
263                 add_definitions(-xSSE4.2)
264         elseif (SSE41)
265                 add_definitions(-xSSE4.1)
266         elseif (SSE)
267                 add_definitions(-mia32)
268         endif()
269         if (SC_OX)
270                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
271         endif()
273         # disable warnings
274         add_definitions(-diag-disable 170) # pointer points outside of underlying object ... used heavily in sclang
275         add_definitions(-diag-disable 279) # controlling expression is constant
277 endif()
279 if (SC_MEMORY_DEBUGGING)
280         add_definitions(-DDISABLE_MEMORY_POOLS)
281 endif()
283 #############################################
284 # subdirectories
285 add_subdirectory(external_libraries)
286 add_subdirectory(server)
287 add_subdirectory(lang)
288 add_subdirectory(editors)
289 add_subdirectory(platform)
291 if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
292     install(DIRECTORY include/common include/plugin_interface include/server include/lang
293         DESTINATION ${CMAKE_INSTALL_PREFIX}/include/SuperCollider
294         FILES_MATCHING PATTERN "*.h"
295     )
296 endif()
298 if(APPLE)
299         # determines the app name and app install location (scappbundlename, scappdir):
300         include (cmake_modules/MacAppFolder.cmake)
302         set(auxresourcesdir ${scappauxresourcesdir})
304         # Some aux files which go in the app's folder
305         install(FILES README.txt ChangeLog COPYING AUTHORS platform/mac/MOVED_STUFF.txt
306                 DESTINATION ${scappbundlename}
307         )
308 elseif (WIN32)
309         set(auxresourcesdir "SuperCollider")
310 else()
311         set(auxresourcesdir "share/SuperCollider")
312 endif()
314 set(SCCLASSLIB_EXCLUDE_REGEX "IGNOREME")
316 if(NOT SC_QT)
317         set(SCCLASSLIB_EXCLUDE_REGEX "${SCCLASSLIB_EXCLUDE_REGEX}|QtCollider")
318 endif()
320 if(WIN32)
321         set(SCCLASSLIB_EXCLUDE_REGEX "${SCCLASSLIB_EXCLUDE_REGEX}")
322 endif()
325 if(APPLE)
327         if(SC_SYMLINK_CLASSLIB)
329                 #if there are folders inside SCCLassLibrary abort cmake.
330                 file(GLOB classlibraryfolders "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/[^.]*")
331                 foreach(onedirectory ${classlibraryfolders})
332                         message( "${onedirectory}" )
333                         if(NOT IS_SYMLINK "${onedirectory}")
334                                 message(FATAL_ERROR "Symlinking will fail ! SCClassLibrary folder already exists and has directories inside, please delete it first." )
335                         endif()
336                 endforeach(onedirectory)
338                 message(STATUS "Will create symlink of SCClassLibrary to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary" )
339                 if(NOT EXISTS "{CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary")
340                         install( CODE "EXECUTE_PROCESS(COMMAND mkdir ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary)" )
341                 endif()
342                 #symlink the folders inside SCCLassLibrary. Check if QtCollider folder should be symlinked or not.
343                 file(GLOB classlibraryfolders RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary" "SCClassLibrary/[^.]*")
344                 foreach(onedirectory ${classlibraryfolders})
345                         if(NOT "${onedirectory}" MATCHES "${SCCLASSLIB_EXCLUDE_REGEX}")
346                                 install( CODE
347                                         "EXECUTE_PROCESS(COMMAND ln -shF ${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/${onedirectory} ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/${onedirectory} )" )
348                         endif()
349                 endforeach(onedirectory)
350         else()
351                 message(STATUS "Will copy SCCLassLibrary to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}")
353                 #if directory contains symlinks, unlink them.
354                 if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary")
355                         file(GLOB classlibraryfolders "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/[^.]*")
356                         foreach(onedirectory ${classlibraryfolders})
357                                 if(IS_SYMLINK "${onedirectory}")
358                                         message(STATUS "Unlinking ${onedirectory}")
359                                         install( CODE "EXECUTE_PROCESS(COMMAND unlink ${onedirectory} )" )
360                                 endif()
361                         endforeach(onedirectory)
362                 endif()
364                 install(DIRECTORY SCClassLibrary
365                         DESTINATION ${auxresourcesdir}
366                         REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
367                 )
368         endif()
369 else()
370         install(DIRECTORY SCClassLibrary
371                 DESTINATION ${auxresourcesdir}
372                 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
373                 PATTERN "*~" EXCLUDE
374                 PATTERN "*#" EXCLUDE
375         )
376 endif()
378 configure_file(platform/SCVersion.sc.in SCVersion/SCVersion.sc)
379 install(DIRECTORY "${CMAKE_BINARY_DIR}/SCVersion" DESTINATION "${auxresourcesdir}/SCClassLibrary")
381 install(DIRECTORY sounds
382         DESTINATION ${auxresourcesdir}
385 if(APPLE AND ("${standalone}" STREQUAL ""))
386         set(exampledir "${scappbundlename}")
387 else()
388         set(exampledir "${auxresourcesdir}")
389 endif()
391 install(DIRECTORY examples
392         DESTINATION ${exampledir}
393         PATTERN "*~" EXCLUDE
394         PATTERN "*#" EXCLUDE
397 if(INSTALL_HELP)
398         if(SC_SYMLINK_CLASSLIB AND APPLE)
399                 message(STATUS "Will create symlink of HelpSource to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
400                 if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
401                         message(FATAL_ERROR "Symlinking will fail ! HelpSource folder already exists, please delete it first." )
402                 endif()
403                 install( CODE
404                                         "EXECUTE_PROCESS(COMMAND ln -shF ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource )" )
405         else()
406                 message(STATUS "Will copy HelpSource to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}")
407                 if(APPLE)
408                         if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
409                                 if(IS_SYMLINK "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
410                                         message(STATUS "Unlinking ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
411                                         install( CODE "EXECUTE_PROCESS(COMMAND unlink ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource )" )
412                                 endif()
413                         endif()
414                 endif()
415                 install(DIRECTORY HelpSource
416                         DESTINATION ${auxresourcesdir}
417                         PATTERN "*~" EXCLUDE
418                         PATTERN "*#" EXCLUDE
419                 )
420         endif()
421 endif()
423 #############################################
425 # build scdoc help files
427 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Common")
428 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Platform")
429 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/SCDoc")
430 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/DefaultLibrary")
431 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/JITLib")
432 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/backwards_compatibility")
434 # this folder has an extension to Platform that disables the loadStartupFiles method
435 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/platform/disable_startup_files")
437 foreach(arg ${BUILD_CLASSLIBRARIES})
438         set(BUILD_CLASSLIBRARYPATH "${BUILD_CLASSLIBRARYPATH}+${arg}\n")
439 endforeach()
441 configure_file(build_sclang.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg)
443 if(SC_DOC_RENDER)
444         file(GLOB_RECURSE SCDocSources RELATIVE HelpSource .*[^~])
445         file(GLOB_RECURSE SCDocClasses RELATIVE SCClassLibrary/SCDoc *.sc)
447         add_custom_target(doc ALL
448                                         COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lang/sclang${CMAKE_EXECUTABLE_SUFFIX}
449                                                         -l ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg
450                                                         platform/renderAllHelp.scd ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_CURRENT_BINARY_DIR}/RenderedHelp
451                                         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
452                                         DEPENDS sclang ${SCDocSources} ${SCDocClasses})
454 endif()
456 set_directory_properties(
457         PROPERTIES
458         ADDITIONAL_MAKE_CLEAN_FILES "RenderedHelp")
460 #############################################
462 # testsuite
464 add_subdirectory(testsuite)
466 #############################################
467 # CPack support
469 set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
470 set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
471 set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
473 if(APPLE)
474         set(CPACK_GENERATOR "DragNDrop")
475         set(CPACK_DMG_FORMAT "UDBZ")
476         set(CPACK_DMG_VOLUME_NAME "${scappbundlename}")
477         set(CPACK_SYSTEM_NAME "OSX")
478 #       set(CPACK_PACKAGE_FILE_NAME "${scappbundlename}-${PROJECT_VERSION}")
479         set(CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/package/ds_store")
480         set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/package/background.png")
481         set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/platform/mac/Resources/SCcube.icns")
482 endif()
484 if(NOT WIN32) # We define a custom 'package' target in platform/windows/CMakeLists.txt
485     include(CPack)
486 endif()
488 #############################################
489 # hide advanced variables
490 mark_as_advanced(AVAHI_LIBRARIES AVAHI_INCLUDE_DIRS AVAHI_INCLUDE_DIR AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT)
491 mark_as_advanced(DL)
492 mark_as_advanced(EMACS_EXECUTABLE)
493 mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY)
494 mark_as_advanced(JACK JACK_INCLUDE_DIR JACK_LIBRARY)
495 mark_as_advanced(MATH_LIBRARY)
496 mark_as_advanced(QT_QMAKE_EXECUTABLE)
497 mark_as_advanced(SNDFILE)