Qt: QUserView: add animation support
[supercollider.git] / CMakeLists.txt
blob39fb4949daf22ab54ca93465013f661873862e31
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(FATAL_ERROR "Rejecting in-place build. 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         if (${_gcc_version} VERSION_GREATER 4.0.99)
70                 add_definitions("-ffast-math")
71         endif()
73         if (${_gcc_version} VERSION_GREATER 4.5.99)
74                 add_definitions("-fpermissive") # boost.atomic is using a deprecated syntax
75         endif()
77         option(DSO_VISIBILITY "DSO visibility support for gcc" OFF)
79         if (DSO_VISIBILITY)
80                 add_definitions(-fvisibility=hidden)
81         endif()
83         if(APPLE)
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.")
88                 endif()
89                 if ("${_gcc_version_info}" MATCHES "Apple")
90                         add_definitions("-fpascal-strings")
91                 endif()
92                 add_definitions("-D_REENTRANT")
93         elseif(NOT (WIN32 AND NOT CYGWIN))
94                 add_definitions("-pthread")
95         endif()
96 endif ()
98 if (${CMAKE_CXX_COMPILER} MATCHES icpc)
99         set(CMAKE_COMPILER_IS_INTEL 1)
100         add_definitions(-Wno-unknown-pragmas)
101         add_definitions(-simd)
102 endif()
104 if(APPLE)
105         set_property(DIRECTORY
106                 APPEND
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")
114 endif()
116 if(WIN32)
117     set_property(DIRECTORY
118                  APPEND
119                  PROPERTY COMPILE_DEFINITIONS SC_WIN32 NOMINMAX _WINSOCKAPI_)
121     if(MSVC)
122         SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} /MTd")
123         SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} /MT")
124     endif()
125 endif()
128 #############################################
129 # some default libraries
131 find_package(Pthreads)
133 if (NOT PTHREADS_FOUND)
134     message(SEND_ERROR "cannot find libpthreads")
135 endif()
136 include_directories(${PTHREADS_INCLUDE_DIR})
138 if (MSVC OR MINGW)
139     set(MATH_LIBRARY "")
140 else()
141     find_library(MATH_LIBRARY m)
142 endif()
144 if(CURL)
145         find_package(CURL)
146         if(CURL_FOUND)
147                 add_definitions("-DHAVE_LIBCURL")
148                 include_directories(${CURL_INCLUDE_DIRS})
149         endif()
150 endif()
152 #############################################
153 # Options
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)
171 elseif()
172     option(SUPERNOVA "Build with supernova as optional audio synthesis server" OFF)
173 endif()
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)
182 if(NOT WIN32)
183         option(SCLANG_SERVER "Build with internal server." ON)
184 endif()
186 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
187         option(SC_WII "Build sclang with WII support" ON)
188 endif()
190 option(SC_QT "Build SuperCollider with Qt GUI" ON)
192 if(WIN32)
193         option(SC_PSYCOLLIDER "Build PsyCollider" ON)
194 else()
195         option(SC_PSYCOLLIDER "Build PsyCollider" OFF)
196 endif()
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).")
201 endif()
203 #############################################
204 # some preprocessor flags
205 if (CMAKE_COMPILER_IS_GNUCXX)
206         if (SSE)
207                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -mfpmath=sse")
208                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -mfpmath=sse")
209         endif()
210         if (SSE41)
211                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
212                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
213         endif()
214         if (SSE42)
215                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
216                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
217         endif()
218         if (NATIVE)
219                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
220                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
221         endif()
222 endif()
224 if (CMAKE_COMPILER_IS_INTEL AND NOT WIN32)
225         if (SSE42)
226                 add_definitions(-xSSE4.2)
227         elseif (SSE41)
228                 add_definitions(-xSSE4.1)
229         elseif (SSE)
230                 add_definitions(-mia32)
231         endif()
232 endif()
234 if (SC_MEMORY_DEBUGGING)
235         add_definitions(-DDISABLE_MEMORY_POOLS)
236 endif()
238 #############################################
239 # subdirectories
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)
247 if (SC_QT)
248   message( STATUS "Compiling with Qt GUI" )
249   add_subdirectory(QtCollider)
250 endif (SC_QT)
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"
256     )
257 endif()
259 if(APPLE)
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}
268         )
269         install(FILES COPYING AUTHORS
270                 DESTINATION ${scappdir}
271         )
272 elseif (WIN32)
273         set(auxresourcesdir "SuperCollider")
274 else()
275         set(auxresourcesdir "share/SuperCollider")
276 endif()
278 if(NOT SC_QT)
279         set(SCCLASSLIB_EXCLUDE_REGEX "QtCollider")
280 else()
281         set(SCCLASSLIB_EXCLUDE_REGEX "IGNOREME")
282 endif()
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")
309 endforeach()
311 configure_file(build_sclang.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg)
313 if(SC_DOC_RENDER)
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})
324 endif()
326 set_directory_properties(
327         PROPERTIES
328         ADDITIONAL_MAKE_CLEAN_FILES "RenderedHelp")
330 #############################################
332 # testsuite
334 add_subdirectory(testsuite)
336 #############################################
337 # win32 install support
339 if(WIN32)
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)
343 endif()
345 #############################################
346 # CPack support
348 set(CPACK_PACKAGE_VERSION_MAJOR 3)
349 set(CPACK_PACKAGE_VERSION_MINOR 5)
350 set(CPACK_PACKAGE_VERSION_PATCH dev)
351 include(CPack)
352 if(WIN32)
353         set(CPACK_MONOLITHIC_INSTALL 1)
354 endif()
356 #############################################
357 # hide advanced variables
358 mark_as_advanced(AVAHI_LIBRARIES AVAHI_INCLUDE_DIRS AVAHI_INCLUDE_DIR AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT)
359 mark_as_advanced(DL)
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)