Qt: QSoundFileView: use int for indexes in partial file loading
[supercollider.git] / CMakeLists.txt
blobc6fb90122b69581a0e2a2500708bbd6d81b85a7f
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 option(SC_SYMLINK_CLASSLIB "Place a symlink of SCCLassLibrary instead of copying" OFF)
205 #############################################
206 # some preprocessor flags
207 if (CMAKE_COMPILER_IS_GNUCXX)
208         if (SSE)
209                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -mfpmath=sse")
210                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -mfpmath=sse")
211         endif()
212         if (SSE41)
213                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
214                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
215         endif()
216         if (SSE42)
217                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
218                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
219         endif()
220         if (NATIVE)
221                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
222                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
223         endif()
224 endif()
226 if (CMAKE_COMPILER_IS_INTEL AND NOT WIN32)
227         if (SSE42)
228                 add_definitions(-xSSE4.2)
229         elseif (SSE41)
230                 add_definitions(-xSSE4.1)
231         elseif (SSE)
232                 add_definitions(-mia32)
233         endif()
234 endif()
236 if (SC_MEMORY_DEBUGGING)
237         add_definitions(-DDISABLE_MEMORY_POOLS)
238 endif()
240 #############################################
241 # subdirectories
242 add_subdirectory(server)
243 add_subdirectory(lang)
244 add_subdirectory(bindings)
245 add_subdirectory(platform)
246 add_subdirectory(editors)
247 add_subdirectory(external_libraries)
249 if (SC_QT)
250   message( STATUS "Compiling with Qt GUI" )
251   add_subdirectory(QtCollider)
252 endif (SC_QT)
254 if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
255     install(DIRECTORY include/common include/plugin_interface include/server include/lang
256         DESTINATION ${CMAKE_INSTALL_PREFIX}/include/SuperCollider
257         FILES_MATCHING PATTERN "*.h"
258     )
259 endif()
261 if(APPLE)
262         # determines the app name and app install location (scappbundlename, scappdir):
263         include (cmake_modules/MacAppFolder.cmake)
265         set(auxresourcesdir ${scappauxresourcesdir})
267         # Some aux files which go in the app's folder
268         install(FILES README ChangeLog
269                 DESTINATION ${auxresourcesdir}
270         )
271         install(FILES COPYING AUTHORS
272                 DESTINATION ${scappdir}
273         )
274 elseif (WIN32)
275         set(auxresourcesdir "SuperCollider")
276 else()
277         set(auxresourcesdir "share/SuperCollider")
278 endif()
280 if(NOT SC_QT)
281         set(SCCLASSLIB_EXCLUDE_REGEX "QtCollider")
282 else()
283         set(SCCLASSLIB_EXCLUDE_REGEX "IGNOREME")
284 endif()
286 if(APPLE)
287         #if directory contains symlinks, unlink them.
288         if(EXISTS "${auxresourcesdir}/SCClassLibrary")
289                 file(GLOB classlibraryfolders "${auxresourcesdir}/SCClassLibrary/[^.]*")
290                 foreach(onedirectory ${classlibraryfolders})
291                         if(IS_SYMLINK "${onedirectory}")
292                                 install( CODE "EXECUTE_PROCESS(COMMAND unlink ${onedirectory} )" )
293                         endif()
294                 endforeach(onedirectory)
295         endif()
297         if(SC_SYMLINK_CLASSLIB)
299                 #if there are folders inside SCCLassLibrary abort cmake.
300                 file(GLOB classlibraryfolders "${auxresourcesdir}/SCClassLibrary/[^.]*")
301                 foreach(onedirectory ${classlibraryfolders})
302                         if(NOT IS_SYMLINK "${onedirectory}")
303                                 message(FATAL_ERROR "Symlinking will fail ! SCClassLibrary folder already exists and has directories inside, please delete it first." )
304                         endif()
305                 endforeach(onedirectory)
307                 message(STATUS "Will create symlink of SCClassLibrary to ${auxresourcesdir}/SCClassLibrary" )
308                 if(NOT EXISTS "${auxresourcesdir}/SCClassLibrary")
309                         install( CODE "EXECUTE_PROCESS(COMMAND mkdir ${auxresourcesdir}/SCClassLibrary)" )
310                 endif()
311                 #symlink the folders inside SCCLassLibrary. Check if QtCollider folder should be symlinked or not.
312                 file(GLOB classlibraryfolders RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary" "SCClassLibrary/[^.]*")
313                 foreach(onedirectory ${classlibraryfolders})
314                         if(NOT "${onedirectory}" MATCHES "${SCCLASSLIB_EXCLUDE_REGEX}")
315                                 install( CODE
316                                         "EXECUTE_PROCESS(COMMAND ln -s ${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/${onedirectory} ${auxresourcesdir}/SCClassLibrary/${onedirectory} )" )
317                         endif()
318                 endforeach(onedirectory)
319         else()
320                 message(STATUS "Will copy SCCLassLibrary to ${auxresourcesdir}")
321                 install(DIRECTORY SCClassLibrary
322                         DESTINATION ${auxresourcesdir}
323                         REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
324                 )
325         endif()
326 else()
327         install(DIRECTORY SCClassLibrary
328                 DESTINATION ${auxresourcesdir}
329                 REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
330         )
331 endif()
334 install(DIRECTORY Help examples sounds HelpSource
335         DESTINATION ${auxresourcesdir}
338 #############################################
340 # build scdoc help files
342 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Common")
343 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Platform")
344 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/SCDoc")
345 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/DefaultLibrary")
346 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/JITLib")
347 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/backwards_compatibility")
349 # this folder has an extension to Platform that disables the loadStartupFiles method
350 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/platform/disable_startup_files")
352 foreach(arg ${BUILD_CLASSLIBRARIES})
353         set(BUILD_CLASSLIBRARYPATH "${BUILD_CLASSLIBRARYPATH}+${arg}\n")
354 endforeach()
356 configure_file(build_sclang.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg)
358 if(SC_DOC_RENDER)
359         file(GLOB_RECURSE SCDocSources RELATIVE HelpSource .*[^~])
360         file(GLOB_RECURSE SCDocClasses RELATIVE SCClassLibrary/SCDoc *.sc)
362         add_custom_target(doc ALL
363                                         COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lang/sclang${CMAKE_EXECUTABLE_SUFFIX}
364                                                         -l ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg
365                                                         platform/renderAllHelp.scd ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_CURRENT_BINARY_DIR}/RenderedHelp
366                                         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
367                                         DEPENDS sclang ${SCDocSources} ${SCDocClasses})
369 endif()
371 set_directory_properties(
372         PROPERTIES
373         ADDITIONAL_MAKE_CLEAN_FILES "RenderedHelp")
375 #############################################
377 # testsuite
379 add_subdirectory(testsuite)
381 #############################################
382 # win32 install support
384 if(WIN32)
385         install(FILES ${FFTW3F_LIBRARY} ${SNDFILE_LIBRARY} ${PTHREADS_LIBRARY} ${PORTAUDIO_LIBRARIES}
386                 DESTINATION "SuperCollider"
387                 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
388 endif()
390 #############################################
391 # CPack support
393 set(CPACK_PACKAGE_VERSION_MAJOR 3)
394 set(CPACK_PACKAGE_VERSION_MINOR 5)
395 set(CPACK_PACKAGE_VERSION_PATCH dev)
396 include(CPack)
397 if(WIN32)
398         set(CPACK_MONOLITHIC_INSTALL 1)
399 endif()
401 #############################################
402 # hide advanced variables
403 mark_as_advanced(AVAHI_LIBRARIES AVAHI_INCLUDE_DIRS AVAHI_INCLUDE_DIR AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT)
404 mark_as_advanced(DL)
405 mark_as_advanced(EMACS_EXECUTABLE)
406 mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY)
407 mark_as_advanced(JACK JACK_INCLUDE_DIR JACK_LIBRARY)
408 mark_as_advanced(MATH_LIBRARY)
409 mark_as_advanced(QT_QMAKE_EXECUTABLE)
410 mark_as_advanced(SNDFILE)