qtcollider: improve QPalette and color setters/getters
[supercollider.git] / CMakeLists.txt
bloba75dd890d728677686336e01b75e708022d30e8c
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 _WINSOCKAPI_)
122     if(MSVC)
123         SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} /MTd")
124         SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} /MT")
125     endif()
126 endif()
129 #############################################
130 # some default libraries
132 find_package(Pthreads)
134 if (NOT PTHREADS_FOUND)
135     message(SEND_ERROR "cannot find libpthreads")
136 endif()
137 include_directories(${PTHREADS_INCLUDE_DIR})
139 if (MSVC OR MINGW)
140     set(MATH_LIBRARY "")
141 else()
142     find_library(MATH_LIBRARY m)
143 endif()
145 if(CURL)
146         find_package(CURL)
147         if(CURL_FOUND)
148                 add_definitions("-DHAVE_LIBCURL")
149                 include_directories(${CURL_INCLUDE_DIRS})
150         endif()
151 endif()
153 #############################################
154 # Options
155 option(NOVA_SIMD "Build with nova-simd support." ON)
156 option(FINAL_BUILD "Build as single source file." OFF)
158 option(CURL "Build with curl for remote file download." ON)
160 option(FFT_GREEN "Use internal 'Green' FFT lib rather than FFTW. (Not recommended.)" OFF)
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(INSTALL_HELP "Install help docs and examples along with the software" ON)
168 option(INSTALL_OLD_HELP "Install old and deprecated help files" ON)
169 option(SC_DOC_RENDER "Pre-render SCDoc documentation. (For putting online, etc)" OFF)
171 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
172     option(SUPERNOVA "Build with supernova as optional audio synthesis server" ON)
173 elseif()
174     option(SUPERNOVA "Build with supernova as optional audio synthesis server" OFF)
175 endif()
177 option(SN_MEMORY_DEBUGGING "Build supernova for memory debugging (disable memory pools).")
178 option(SC_MEMORY_DEBUGGING "Build sclang&scsynth for memory debugging (disable memory pools).")
179 option(GC_SANITYCHECK "Enable sanity checks in the sclang garbage collector.")
181 option(NO_LIBSNDFILE "Disable soundfile functionality. (Not recommended.)" OFF)
183 option(NO_AVAHI "Disable Avahi support. (Not recommended.)" OFF)
185 if(NOT WIN32)
186         option(SCLANG_SERVER "Build with internal server." ON)
187 endif()
189 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
190         option(SC_WII "Build sclang with WII support" ON)
191 endif()
193 option(SC_QT "Build SuperCollider with Qt GUI" ON)
194 if (SC_QT)
195   message( STATUS "Compiling with Qt GUI" )
196 endif (SC_QT)
198 if(WIN32)
199         option(SC_PSYCOLLIDER "Build PsyCollider" ON)
200 else()
201         option(SC_PSYCOLLIDER "Build PsyCollider" OFF)
202 endif()
204 if(CMAKE_COMPILER_IS_GNUCXX)
205     option(NATIVE "Optimize binary for this architecture (binaries may not run on other machines, requires gcc-4.3 or higher).")
206     option(LTO "Use GCC's link time optimizer' (experimental).")
207 endif()
209 option(SC_SYMLINK_CLASSLIB "Place a symlink of SCCLassLibrary instead of copying" OFF)
210 option(SC_OX "Try to compile with support for C++0x (experimental, mainly related to supernova)" OFF)
212 #############################################
213 # some preprocessor flags
214 if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
215         if (SSE)
216                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -mfpmath=sse")
217                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -mfpmath=sse")
218         endif()
219         if (SSE41)
220                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
221                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
222         endif()
223         if (SSE42)
224                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
225                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
226         endif()
227         if (NATIVE)
228                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
229                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
230         endif()
232         if (SC_OX)
233                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
234         endif()
235 endif()
237 if (CMAKE_COMPILER_IS_INTEL AND NOT WIN32)
238         if (SSE42)
239                 add_definitions(-xSSE4.2)
240         elseif (SSE41)
241                 add_definitions(-xSSE4.1)
242         elseif (SSE)
243                 add_definitions(-mia32)
244         endif()
245         if (SC_OX)
246                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
247         endif()
249         # disable warnings
250         add_definitions(-diag-disable 170) # pointer points outside of underlying object ... used heavily in sclang
251         add_definitions(-diag-disable 279) # controlling expression is constant
253 endif()
255 if (SC_MEMORY_DEBUGGING)
256         add_definitions(-DDISABLE_MEMORY_POOLS)
257 endif()
259 #############################################
260 # subdirectories
261 add_subdirectory(external_libraries)
262 add_subdirectory(server)
263 add_subdirectory(lang)
264 add_subdirectory(bindings)
265 add_subdirectory(platform)
266 add_subdirectory(editors)
268 if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
269     install(DIRECTORY include/common include/plugin_interface include/server include/lang
270         DESTINATION ${CMAKE_INSTALL_PREFIX}/include/SuperCollider
271         FILES_MATCHING PATTERN "*.h"
272     )
273 endif()
275 if(APPLE)
276         # determines the app name and app install location (scappbundlename, scappdir):
277         include (cmake_modules/MacAppFolder.cmake)
279         set(auxresourcesdir ${scappauxresourcesdir})
281         # Some aux files which go in the app's folder
282         install(FILES README.txt ChangeLog COPYING AUTHORS platform/mac/MOVED_STUFF.txt
283                 DESTINATION ${scappbundlename}
284         )
285 elseif (WIN32)
286         set(auxresourcesdir "SuperCollider")
287 else()
288         set(auxresourcesdir "share/SuperCollider")
289 endif()
291 if(NOT SC_QT)
292         set(SCCLASSLIB_EXCLUDE_REGEX "QtCollider")
293 else()
294         set(SCCLASSLIB_EXCLUDE_REGEX "IGNOREME")
295 endif()
297 if(APPLE)
299         if(SC_SYMLINK_CLASSLIB)
301                 #if there are folders inside SCCLassLibrary abort cmake.
302                 file(GLOB classlibraryfolders "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/[^.]*")
303                 foreach(onedirectory ${classlibraryfolders})
304                         message( "${onedirectory}" )
305                         if(NOT IS_SYMLINK "${onedirectory}")
306                                 message(FATAL_ERROR "Symlinking will fail ! SCClassLibrary folder already exists and has directories inside, please delete it first." )
307                         endif()
308                 endforeach(onedirectory)
310                 message(STATUS "Will create symlink of SCClassLibrary to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary" )
311                 if(NOT EXISTS "{CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary")
312                         install( CODE "EXECUTE_PROCESS(COMMAND mkdir ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary)" )
313                 endif()
314                 #symlink the folders inside SCCLassLibrary. Check if QtCollider folder should be symlinked or not.
315                 file(GLOB classlibraryfolders RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary" "SCClassLibrary/[^.]*")
316                 foreach(onedirectory ${classlibraryfolders})
317                         if(NOT "${onedirectory}" MATCHES "${SCCLASSLIB_EXCLUDE_REGEX}")
318                                 install( CODE
319                                         "EXECUTE_PROCESS(COMMAND ln -shF ${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/${onedirectory} ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/${onedirectory} )" )
320                         endif()
321                 endforeach(onedirectory)
322         else()
323                 message(STATUS "Will copy SCCLassLibrary to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}")
325                 #if directory contains symlinks, unlink them.
326                 if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary")
327                         file(GLOB classlibraryfolders "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/[^.]*")
328                         foreach(onedirectory ${classlibraryfolders})
329                                 if(IS_SYMLINK "${onedirectory}")
330                                         message(STATUS "Unlinking ${onedirectory}")
331                                         install( CODE "EXECUTE_PROCESS(COMMAND unlink ${onedirectory} )" )
332                                 endif()
333                         endforeach(onedirectory)
334                 endif()
336                 install(DIRECTORY SCClassLibrary
337                         DESTINATION ${auxresourcesdir}
338                         REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
339                 )
340         endif()
341 else()
342         install(DIRECTORY SCClassLibrary
343                 DESTINATION ${auxresourcesdir}
344                 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
345                 PATTERN "*~" EXCLUDE
346                 PATTERN "*#" EXCLUDE
347         )
348 endif()
350 configure_file(platform/SCVersion.sc.in SCVersion/SCVersion.sc)
351 install(DIRECTORY "${CMAKE_BINARY_DIR}/SCVersion" DESTINATION "${auxresourcesdir}/SCClassLibrary")
353 install(DIRECTORY sounds
354         DESTINATION ${auxresourcesdir}
357 if(APPLE AND ("${standalone}" STREQUAL ""))
358         set(exampledir "${scappbundlename}")
359 else()
360         set(exampledir "${auxresourcesdir}")
361 endif()
363 install(DIRECTORY examples
364         DESTINATION ${exampledir}
365         PATTERN "*~" EXCLUDE
366         PATTERN "*#" EXCLUDE
369 if(INSTALL_OLD_HELP)
370         install(DIRECTORY Help
371                 DESTINATION ${auxresourcesdir}
372         )
373 endif()
375 if(INSTALL_HELP)
376         if(SC_SYMLINK_CLASSLIB AND APPLE)
377                 message(STATUS "Will create symlink of HelpSource to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
378                 if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
379                         message(FATAL_ERROR "Symlinking will fail ! HelpSource folder already exists, please delete it first." )
380                 endif()
381                 install( CODE
382                                         "EXECUTE_PROCESS(COMMAND ln -shF ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource )" )
383         else()
384                 message(STATUS "Will copy HelpSource to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}")
385                 if(APPLE)
386                         if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
387                                 if(IS_SYMLINK "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
388                                         message(STATUS "Unlinking ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
389                                         install( CODE "EXECUTE_PROCESS(COMMAND unlink ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource )" )
390                                 endif()
391                         endif()
392                 endif()
393                 install(DIRECTORY HelpSource
394                         DESTINATION ${auxresourcesdir}
395                         PATTERN "*~" EXCLUDE
396                         PATTERN "*#" EXCLUDE
397                 )
398         endif()
399 endif()
401 #############################################
403 # build scdoc help files
405 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Common")
406 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Platform")
407 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/SCDoc")
408 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/DefaultLibrary")
409 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/JITLib")
410 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/backwards_compatibility")
412 # this folder has an extension to Platform that disables the loadStartupFiles method
413 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/platform/disable_startup_files")
415 foreach(arg ${BUILD_CLASSLIBRARIES})
416         set(BUILD_CLASSLIBRARYPATH "${BUILD_CLASSLIBRARYPATH}+${arg}\n")
417 endforeach()
419 configure_file(build_sclang.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg)
421 if(SC_DOC_RENDER)
422         file(GLOB_RECURSE SCDocSources RELATIVE HelpSource .*[^~])
423         file(GLOB_RECURSE SCDocClasses RELATIVE SCClassLibrary/SCDoc *.sc)
425         add_custom_target(doc ALL
426                                         COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lang/sclang${CMAKE_EXECUTABLE_SUFFIX}
427                                                         -l ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg
428                                                         platform/renderAllHelp.scd ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_CURRENT_BINARY_DIR}/RenderedHelp
429                                         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
430                                         DEPENDS sclang ${SCDocSources} ${SCDocClasses})
432 endif()
434 set_directory_properties(
435         PROPERTIES
436         ADDITIONAL_MAKE_CLEAN_FILES "RenderedHelp")
438 #############################################
440 # testsuite
442 add_subdirectory(testsuite)
444 #############################################
445 # win32 install support
447 if(WIN32)
448         install(FILES ${FFTW3F_LIBRARY} ${SNDFILE_LIBRARY} ${PTHREADS_LIBRARY} ${PORTAUDIO_LIBRARIES}
449                 DESTINATION "SuperCollider"
450                 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
451 endif()
453 #############################################
454 # CPack support
456 set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
457 set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
458 set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
460 if(APPLE)
461         set(CPACK_GENERATOR "DragNDrop")
462         set(CPACK_DMG_FORMAT "UDBZ")
463         set(CPACK_DMG_VOLUME_NAME "${scappbundlename}")
464         set(CPACK_SYSTEM_NAME "OSX")
465 #       set(CPACK_PACKAGE_FILE_NAME "${scappbundlename}-${PROJECT_VERSION}")
466         set(CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/package/ds_store")
467         set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/package/background.png")
468         set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/platform/mac/Resources/SCcube.icns")
469 elseif(WIN32)
470         set(CPACK_MONOLITHIC_INSTALL 1)
471 endif()
472 include(CPack)
474 #############################################
475 # hide advanced variables
476 mark_as_advanced(AVAHI_LIBRARIES AVAHI_INCLUDE_DIRS AVAHI_INCLUDE_DIR AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT)
477 mark_as_advanced(DL)
478 mark_as_advanced(EMACS_EXECUTABLE)
479 mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY)
480 mark_as_advanced(JACK JACK_INCLUDE_DIR JACK_LIBRARY)
481 mark_as_advanced(MATH_LIBRARY)
482 mark_as_advanced(QT_QMAKE_EXECUTABLE)
483 mark_as_advanced(SNDFILE)