qt gui: QMultiSliderView: add forgotten property corresponding to 'size'
[supercollider.git] / CMakeLists.txt
blob5915083674db6642cd78191bb931426cad85f077
1 cmake_minimum_required (VERSION 2.8)
2 project (SuperCollider)
4 include(CTest)
5 enable_testing()
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")
12 endif()
14 if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
15         message(WARNING "WARNING: IN-PLACE BUILDS ARE NOT RECOMMENDED - PLEASE USE A BUILD DIRECTORY")
16 endif()
19 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules
20                       ${CMAKE_MODULE_PATH})
22 CONFIGURE_FILE(
23   "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/cmake_uninstall.cmake.in"
24   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
25   IMMEDIATE @ONLY)
27 ADD_CUSTOM_TARGET(uninstall
28   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
30 if(NOT WIN32)
31         ADD_CUSTOM_TARGET(setMainVersion ALL
32                 sh ${CMAKE_CURRENT_SOURCE_DIR}/setMainVersion.sh
33                 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
34                 VERBATIM
35                 )
36 endif()
38 if(APPLE)
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")
44                 else()
45                         set(HID_UTIL_DIR "HID_Utilities_10_4")
46                 endif()
47         else()
48                 if (${MAC_OSX_SDK_VERSION} GREATER 4)
49                         set(HID_UTIL_DIR "HID_Utilities")
50                 else()
51                         set(HID_UTIL_DIR "HID_Utilities_10_4")
52                 endif()
53         endif()
54         MESSAGE( STATUS "Using HID Utilities from folder '${HID_UTIL_DIR}'")
55 endif()
57 if (CMAKE_SYSTEM_NAME MATCHES "Linux")
58         set(LINUX 1)
59 endif()
61 #############################################
62 # Compiler flags etc
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         add_definitions("-Wreturn-type")
71         if (${_gcc_version} VERSION_GREATER 4.0.99)
72                 add_definitions("-ffast-math")
73         endif()
75         option(DSO_VISIBILITY "DSO visibility support for gcc" OFF)
77         if (DSO_VISIBILITY)
78                 add_definitions(-fvisibility=hidden)
79         endif()
81         if(APPLE)
82                 exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info)
84                 if ("${_gcc_version_info}" MATCHES "darwin10-llvm-g..-4.2")
85                         message(FATAL_ERROR "llvm-gcc-4.2 was reported to be broken. please use another compiler.")
86                 endif()
87                 if ("${_gcc_version_info}" MATCHES "Apple")
88                         add_definitions("-fpascal-strings")
89                 endif()
90                 add_definitions("-D_REENTRANT")
91         elseif(NOT (WIN32 AND NOT CYGWIN))
92                 add_definitions("-pthread")
93         endif()
94 endif ()
96 if (${CMAKE_CXX_COMPILER} MATCHES icpc)
97         set(CMAKE_COMPILER_IS_INTEL 1)
98         add_definitions(-Wno-unknown-pragmas)
99         add_definitions(-simd)
100 endif()
102 if (${CMAKE_CXX_COMPILER} MATCHES clang)
103         set(CMAKE_COMPILER_IS_CLANG 1)
104 endif()
106 if(APPLE)
107         set_property(DIRECTORY
108                 APPEND
109                 PROPERTY COMPILE_DEFINITIONS SC_DARWIN)
110 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
111         add_definitions("-DSC_LINUX")
112         add_definitions(-DSC_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/SuperCollider")
113 elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
114         add_definitions("-DSC_FREEBSD")
115         add_definitions(-DSC_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/SuperCollider")
116 endif()
118 if(WIN32)
119     set_property(DIRECTORY
120                  APPEND
121                  PROPERTY COMPILE_DEFINITIONS SC_WIN32 NOMINMAX _WINSOCKAPI_)
123     if(MSVC)
124         SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} /MTd")
125         SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} /MT")
126     endif()
127 endif()
130 #############################################
131 # some default libraries
133 find_package(Pthreads)
135 if (NOT PTHREADS_FOUND)
136     message(SEND_ERROR "cannot find libpthreads")
137 endif()
138 include_directories(${PTHREADS_INCLUDE_DIR})
140 if (MSVC OR MINGW)
141     set(MATH_LIBRARY "")
142 else()
143     find_library(MATH_LIBRARY m)
144 endif()
146 if(CURL)
147         find_package(CURL)
148         if(CURL_FOUND)
149                 add_definitions("-DHAVE_LIBCURL")
150                 include_directories(${CURL_INCLUDE_DIRS})
151         endif()
152 endif()
154 #############################################
155 # Options
156 option(NOVA_SIMD "Build with nova-simd support." ON)
157 option(FINAL_BUILD "Build as single source file." OFF)
159 option(CURL "Build with curl for remote file download." ON)
161 option(FFT_GREEN "Use internal 'Green' FFT lib rather than FFTW. (Not recommended.)" OFF)
162 mark_as_advanced(FFT_GREEN)
164 option(SSE "Compile with support for SSE instructions.")
165 option(SSE41 "Compile with support for SSE4.1 instructions.")
166 option(SSE42 "Compile with support for SSE4.2 instructions.")
169 option(INSTALL_HELP "Install help docs and examples along with the software" ON)
170 option(INSTALL_OLD_HELP "Install old and deprecated help files" ON)
171 option(SC_DOC_RENDER "Pre-render SCDoc documentation. (For putting online, etc)" OFF)
173 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
174     option(SUPERNOVA "Build with supernova as optional audio synthesis server" ON)
175 elseif()
176     option(SUPERNOVA "Build with supernova as optional audio synthesis server" OFF)
177 endif()
179 option(SN_MEMORY_DEBUGGING "Build supernova for memory debugging (disable memory pools).")
180 option(SC_MEMORY_DEBUGGING "Build sclang&scsynth for memory debugging (disable memory pools).")
181 option(GC_SANITYCHECK "Enable sanity checks in the sclang garbage collector.")
183 option(NO_LIBSNDFILE "Disable soundfile functionality. (Not recommended.)" OFF)
184 mark_as_advanced(NO_LIBSNDFILE)
186 if(NOT WIN32)
187         option(SCLANG_SERVER "Build with internal server." ON)
188 endif()
190 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
191         option(SC_WII "Build sclang with WII support" ON)
192 endif()
194 option(SC_QT "Build SuperCollider with Qt GUI" ON)
196 if(WIN32)
197         option(SC_PSYCOLLIDER "Build PsyCollider" ON)
198 else()
199         option(SC_PSYCOLLIDER "Build PsyCollider" OFF)
200 endif()
202 if(CMAKE_COMPILER_IS_GNUCXX)
203     option(NATIVE "Optimize binary for this architecture (binaries may not run on other machines, requires gcc-4.3 or higher).")
204     option(LTO "Use GCC's link time optimizer' (experimental).")
205 endif()
207 option(SC_SYMLINK_CLASSLIB "Place a symlink of SCCLassLibrary instead of copying" OFF)
208 option(SC_OX "Try to compile with support for C++0x (experimental, mainly related to supernova)" OFF)
210 #############################################
211 # some preprocessor flags
212 if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
213         if (SSE)
214                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -mfpmath=sse")
215                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -mfpmath=sse")
216         endif()
217         if (SSE41)
218                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
219                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
220         endif()
221         if (SSE42)
222                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
223                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
224         endif()
225         if (NATIVE)
226                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
227                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
228         endif()
230         if (SC_OX)
231                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
232         endif()
233 endif()
235 if (CMAKE_COMPILER_IS_INTEL AND NOT WIN32)
236         if (SSE42)
237                 add_definitions(-xSSE4.2)
238         elseif (SSE41)
239                 add_definitions(-xSSE4.1)
240         elseif (SSE)
241                 add_definitions(-mia32)
242         endif()
243         if (SC_OX)
244                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
245         endif()
247         # disable warnings
248         add_definitions(-diag-disable 170) # pointer points outside of underlying object ... used heavily in sclang
249         add_definitions(-diag-disable 279) # controlling expression is constant
251 endif()
253 if (SC_MEMORY_DEBUGGING)
254         add_definitions(-DDISABLE_MEMORY_POOLS)
255 endif()
257 #############################################
258 # subdirectories
259 add_subdirectory(external_libraries)
260 add_subdirectory(server)
261 add_subdirectory(lang)
262 add_subdirectory(bindings)
263 add_subdirectory(platform)
264 add_subdirectory(editors)
266 if (SC_QT)
267   message( STATUS "Compiling with Qt GUI" )
268   add_subdirectory(QtCollider)
269 endif (SC_QT)
271 if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
272     install(DIRECTORY include/common include/plugin_interface include/server include/lang
273         DESTINATION ${CMAKE_INSTALL_PREFIX}/include/SuperCollider
274         FILES_MATCHING PATTERN "*.h"
275     )
276 endif()
278 if(APPLE)
279         # determines the app name and app install location (scappbundlename, scappdir):
280         include (cmake_modules/MacAppFolder.cmake)
282         set(auxresourcesdir ${scappauxresourcesdir})
284         # Some aux files which go in the app's folder
285         install(FILES README.txt ChangeLog
286                 DESTINATION ${auxresourcesdir}
287         )
288         install(FILES COPYING AUTHORS
289                 DESTINATION ${scappdir}
290         )
291 elseif (WIN32)
292         set(auxresourcesdir "SuperCollider")
293 else()
294         set(auxresourcesdir "share/SuperCollider")
295 endif()
297 if(NOT SC_QT)
298         set(SCCLASSLIB_EXCLUDE_REGEX "QtCollider")
299 else()
300         set(SCCLASSLIB_EXCLUDE_REGEX "IGNOREME")
301 endif()
303 if(APPLE)
304         #if directory contains symlinks, unlink them.
305         if(EXISTS "${auxresourcesdir}/SCClassLibrary")
306                 file(GLOB classlibraryfolders "${auxresourcesdir}/SCClassLibrary/[^.]*")
307                 foreach(onedirectory ${classlibraryfolders})
308                         if(IS_SYMLINK "${onedirectory}")
309                                 install( CODE "EXECUTE_PROCESS(COMMAND unlink ${onedirectory} )" )
310                         endif()
311                 endforeach(onedirectory)
312         endif()
314         if(SC_SYMLINK_CLASSLIB)
316                 #if there are folders inside SCCLassLibrary abort cmake.
317                 file(GLOB classlibraryfolders "${auxresourcesdir}/SCClassLibrary/[^.]*")
318                 foreach(onedirectory ${classlibraryfolders})
319                         if(NOT IS_SYMLINK "${onedirectory}")
320                                 message(FATAL_ERROR "Symlinking will fail ! SCClassLibrary folder already exists and has directories inside, please delete it first." )
321                         endif()
322                 endforeach(onedirectory)
324                 message(STATUS "Will create symlink of SCClassLibrary to ${auxresourcesdir}/SCClassLibrary" )
325                 if(NOT EXISTS "${auxresourcesdir}/SCClassLibrary")
326                         install( CODE "EXECUTE_PROCESS(COMMAND mkdir ${auxresourcesdir}/SCClassLibrary)" )
327                 endif()
328                 #symlink the folders inside SCCLassLibrary. Check if QtCollider folder should be symlinked or not.
329                 file(GLOB classlibraryfolders RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary" "SCClassLibrary/[^.]*")
330                 foreach(onedirectory ${classlibraryfolders})
331                         if(NOT "${onedirectory}" MATCHES "${SCCLASSLIB_EXCLUDE_REGEX}")
332                                 install( CODE
333                                         "EXECUTE_PROCESS(COMMAND ln -s ${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/${onedirectory} ${auxresourcesdir}/SCClassLibrary/${onedirectory} )" )
334                         endif()
335                 endforeach(onedirectory)
336         else()
337                 message(STATUS "Will copy SCCLassLibrary to ${auxresourcesdir}")
338                 install(DIRECTORY SCClassLibrary
339                         DESTINATION ${auxresourcesdir}
340                         REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
341                 )
342         endif()
343 else()
344         install(DIRECTORY SCClassLibrary
345                 DESTINATION ${auxresourcesdir}
346                 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
347                 PATTERN "*~" EXCLUDE
348                 PATTERN "*#" EXCLUDE
349         )
350 endif()
353 install(DIRECTORY sounds
354         DESTINATION ${auxresourcesdir}
357 if(INSTALL_OLD_HELP)
358         install(DIRECTORY Help
359                 DESTINATION ${auxresourcesdir}
360         )
361 endif()
363 if(INSTALL_HELP)
364         install(DIRECTORY examples HelpSource
365                 DESTINATION ${auxresourcesdir}
366                 PATTERN "*~" EXCLUDE
367                 PATTERN "*#" EXCLUDE
368         )
369 endif()
371 #############################################
373 # build scdoc help files
375 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Common")
376 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Platform")
377 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/SCDoc")
378 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/DefaultLibrary")
379 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/JITLib")
380 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/backwards_compatibility")
382 # this folder has an extension to Platform that disables the loadStartupFiles method
383 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/platform/disable_startup_files")
385 foreach(arg ${BUILD_CLASSLIBRARIES})
386         set(BUILD_CLASSLIBRARYPATH "${BUILD_CLASSLIBRARYPATH}+${arg}\n")
387 endforeach()
389 configure_file(build_sclang.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg)
391 if(SC_DOC_RENDER)
392         file(GLOB_RECURSE SCDocSources RELATIVE HelpSource .*[^~])
393         file(GLOB_RECURSE SCDocClasses RELATIVE SCClassLibrary/SCDoc *.sc)
395         add_custom_target(doc ALL
396                                         COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lang/sclang${CMAKE_EXECUTABLE_SUFFIX}
397                                                         -l ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg
398                                                         platform/renderAllHelp.scd ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_CURRENT_BINARY_DIR}/RenderedHelp
399                                         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
400                                         DEPENDS sclang ${SCDocSources} ${SCDocClasses})
402 endif()
404 set_directory_properties(
405         PROPERTIES
406         ADDITIONAL_MAKE_CLEAN_FILES "RenderedHelp")
408 #############################################
410 # testsuite
412 add_subdirectory(testsuite)
414 #############################################
415 # win32 install support
417 if(WIN32)
418         install(FILES ${FFTW3F_LIBRARY} ${SNDFILE_LIBRARY} ${PTHREADS_LIBRARY} ${PORTAUDIO_LIBRARIES}
419                 DESTINATION "SuperCollider"
420                 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
421 endif()
423 #############################################
424 # CPack support
426 set(CPACK_PACKAGE_VERSION_MAJOR 3)
427 set(CPACK_PACKAGE_VERSION_MINOR 5)
428 set(CPACK_PACKAGE_VERSION_PATCH dev)
429 include(CPack)
430 if(WIN32)
431         set(CPACK_MONOLITHIC_INSTALL 1)
432 endif()
434 #############################################
435 # hide advanced variables
436 mark_as_advanced(AVAHI_LIBRARIES AVAHI_INCLUDE_DIRS AVAHI_INCLUDE_DIR AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT)
437 mark_as_advanced(DL)
438 mark_as_advanced(EMACS_EXECUTABLE)
439 mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY)
440 mark_as_advanced(JACK JACK_INCLUDE_DIR JACK_LIBRARY)
441 mark_as_advanced(MATH_LIBRARY)
442 mark_as_advanced(QT_QMAKE_EXECUTABLE)
443 mark_as_advanced(SNDFILE)