SCDoc: limit number of listed subclasses in classdocs
[supercollider.git] / CMakeLists.txt
blobed7e6017c8447d2cfc2de997031bcebad2874185
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 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules
15                       ${CMAKE_MODULE_PATH})
17 CONFIGURE_FILE(
18   "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/cmake_uninstall.cmake.in"
19   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
20   IMMEDIATE @ONLY)
22 ADD_CUSTOM_TARGET(uninstall
23   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
25 if(NOT WIN32)
26         ADD_CUSTOM_TARGET(setMainVersion ALL
27                 sh ${CMAKE_CURRENT_SOURCE_DIR}/setMainVersion.sh
28                 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
29                 VERBATIM
30                 )
31 endif()
33 if(APPLE)
34         STRING(REGEX REPLACE "^.*MacOSX10.([0-9]+).*$" "\\1" MAC_OSX_SDK_VERSION  "${CMAKE_OSX_SYSROOT}")
36         if(CMAKE_OSX_DEPLOYMENT_TARGET)
37                 if (CMAKE_OSX_DEPLOYMENT_TARGET GREATER 10.4)
38                         set(HID_UTIL_DIR "HID_Utilities")
39                 else()
40                         set(HID_UTIL_DIR "HID_Utilities_10_4")
41                 endif()
42         else()
43                 if (${MAC_OSX_SDK_VERSION} GREATER 4)
44                         set(HID_UTIL_DIR "HID_Utilities")
45                 else()
46                         set(HID_UTIL_DIR "HID_Utilities_10_4")
47                 endif()
48         endif()
49         MESSAGE( STATUS "Using HID Utilities from folder '${HID_UTIL_DIR}'")
50 endif()
52 #############################################
53 # Compiler flags etc
55 if (${CMAKE_COMPILER_IS_GNUCXX})
56         exec_program(${CMAKE_CXX_COMPILER} ARGS -dumpversion OUTPUT_VARIABLE _gcc_version)
58         add_definitions("-fschedule-insns2" "-fomit-frame-pointer")
60         if (${_gcc_version} VERSION_GREATER 4.0.99)
61                 add_definitions("-ffast-math")
62         endif()
64         if (${_gcc_version} VERSION_GREATER 4.5.99)
65                 add_definitions("-fpermissive") # boost.atomic is using a deprecated syntax
66         endif()
68         option(DSO_VISIBILITY "DSO visibility support for gcc" OFF)
70         if (DSO_VISIBILITY)
71                 add_definitions(-fvisibility=hidden)
72         endif()
74         if(APPLE)
75                 exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info)
77                 if ("${_gcc_version_info}" MATCHES "darwin10-llvm-g..-4.2")
78                         message(FATAL_ERROR "llvm-gcc-4.2 was reported to be broken. please use another compiler.")
79                 endif()
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(APPLE)
90         set_property(DIRECTORY
91                 APPEND
92                 PROPERTY COMPILE_DEFINITIONS SC_DARWIN)
93 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
94         add_definitions("-DSC_LINUX")
95         add_definitions(-DSC_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/SuperCollider")
96 elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
97         add_definitions("-DSC_FREEBSD")
98         add_definitions(-DSC_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/SuperCollider")
99 endif()
101 if(WIN32)
102     set_property(DIRECTORY
103                  APPEND
104                  PROPERTY COMPILE_DEFINITIONS SC_WIN32 NOMINMAX _WINSOCKAPI_)
106     if(MSVC)
107         SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} /MTd")
108         SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} /MT")
109     endif()
110 endif()
113 #############################################
114 # some default libraries
116 find_package(Pthreads)
118 if (NOT PTHREADS_FOUND)
119     message(SEND_ERROR "cannot find libpthreads")
120 endif()
121 include_directories(${PTHREADS_INCLUDE_DIR})
123 if (MSVC OR MINGW)
124     set(MATH_LIBRARY "")
125 else()
126     find_library(MATH_LIBRARY m)
127 endif()
129 if(CURL)
130         find_package(CURL)
131         if(CURL_FOUND)
132                 add_definitions("-DHAVE_LIBCURL")
133                 include_directories(${CURL_INCLUDE_DIRS})
134         endif()
135 endif()
137 #############################################
138 # Options
139 option(NOVA_SIMD "Build with nova-simd support." ON)
140 option(FINAL_BUILD "Build as single source file." OFF)
142 option(CURL "Build with curl for remote file download." ON)
144 option(FFT_GREEN "Use internal 'Green' FFT lib rather than FFTW. (Not recommended.)" OFF)
145 mark_as_advanced(FFT_GREEN)
147 option(SSE "Compile with support for SSE instructions.")
148 option(SSE41 "Compile with support for SSE4.1 instructions.")
149 option(SSE42 "Compile with support for SSE4.2 instructions.")
152 option(SC_DOC_RENDER "Pre-render SCDoc documentation. (For putting online, etc)" OFF)
154 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
155     option(SUPERNOVA "Build with supernova as optional audio synthesis server" ON)
156 elseif()
157     option(SUPERNOVA "Build with supernova as optional audio synthesis server" OFF)
158 endif()
160 option(SN_MEMORY_DEBUGGING "Build supernova for memory debugging (disable memory pools).")
161 option(SC_MEMORY_DEBUGGING "Build sclang&scsynth for memory debugging (disable memory pools).")
162 option(GC_SANITYCHECK "Enable sanity checks in the sclang garbage collector.")
164 option(NO_LIBSNDFILE "Disable soundfile functionality. (Not recommended.)" OFF)
165 mark_as_advanced(NO_LIBSNDFILE)
167 if(NOT WIN32)
168         option(SCLANG_SERVER "Build with internal server." ON)
169 endif()
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)
177 if(WIN32)
178         option(SC_PSYCOLLIDER "Build PsyCollider" ON)
179 else()
180         option(SC_PSYCOLLIDER "Build PsyCollider" OFF)
181 endif()
183 if(CMAKE_COMPILER_IS_GNUCXX)
184     option(NATIVE "Optimize binary for this architecture (binaries may not run on other machines, requires gcc-4.3 or higher).")
185     option(LTO "Use GCC's link time optimizer' (experimental).")
186 endif()
188 #############################################
189 # some preprocessor flags
190 if(CMAKE_COMPILER_IS_GNUCXX)
191   if(SSE)
192     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -mfpmath=sse")
193     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -mfpmath=sse")
194   endif()
195   if(SSE41)
196     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
197     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
198   endif()
199   if(SSE42)
200     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
201     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
202   endif()
203   if(NATIVE)
204     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
205     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
206   endif()
207 endif()
209 if (SC_MEMORY_DEBUGGING)
210         add_definitions(-DDISABLE_MEMORY_POOLS)
211 endif()
213 #############################################
214 # subdirectories
215 add_subdirectory(server)
216 add_subdirectory(lang)
217 add_subdirectory(bindings)
218 add_subdirectory(platform)
219 add_subdirectory(editors)
220 add_subdirectory(external_libraries)
222 if (SC_QT)
223   message( STATUS "Compiling with Qt GUI" )
224   add_subdirectory(QtCollider)
225 endif (SC_QT)
227 if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
228     install(DIRECTORY include/common include/plugin_interface include/server include/lang
229         DESTINATION ${CMAKE_INSTALL_PREFIX}/include/SuperCollider
230         FILES_MATCHING PATTERN "*.h"
231     )
232 endif()
234 if(APPLE)
235         # determines the app name and app install location (scappbundlename, scappdir):
236         include (cmake_modules/MacAppFolder.cmake)
238         set(auxresourcesdir ${scappauxresourcesdir})
240         # Some aux files which go in the app's folder
241         install(FILES README ChangeLog
242                 DESTINATION ${auxresourcesdir}
243         )
244         install(FILES COPYING AUTHORS
245                 DESTINATION ${scappdir}
246         )
247 elseif (WIN32)
248         set(auxresourcesdir "SuperCollider")
249 else()
250         set(auxresourcesdir "share/SuperCollider")
251 endif()
253 if(NOT SC_QT)
254         set(SCCLASSLIB_EXCLUDE_REGEX "QtCollider")
255 else()
256         set(SCCLASSLIB_EXCLUDE_REGEX "IGNOREME")
257 endif()
259 install(DIRECTORY SCClassLibrary
260         DESTINATION ${auxresourcesdir}
261         REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
264 install(DIRECTORY Help examples sounds HelpSource
265         DESTINATION ${auxresourcesdir}
268 #############################################
270 # build scdoc help files
272 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Common")
273 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/Platform")
274 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/SCDoc")
275 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/DefaultLibrary")
276 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/JITLib")
277 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/backwards_compatibility")
279 # this folder has an extension to Platform that disables the loadStartupFiles method
280 list(APPEND BUILD_CLASSLIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/platform/disable_startup_files")
282 foreach(arg ${BUILD_CLASSLIBRARIES})
283         set(BUILD_CLASSLIBRARYPATH "${BUILD_CLASSLIBRARYPATH}+${arg}\n")
284 endforeach()
286 configure_file(build_sclang.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg)
288 if(SC_DOC_RENDER)
289         file(GLOB_RECURSE SCDocSources RELATIVE HelpSource .*[^~])
290         file(GLOB_RECURSE SCDocClasses RELATIVE SCClassLibrary/SCDoc *.sc)
292         add_custom_target(doc ALL
293                                         COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lang/sclang${CMAKE_EXECUTABLE_SUFFIX}
294                                                         -l ${CMAKE_CURRENT_BINARY_DIR}/build_sclang.cfg
295                                                         platform/renderAllHelp.scd ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_CURRENT_BINARY_DIR}/RenderedHelp
296                                         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
297                                         DEPENDS sclang ${SCDocSources} ${SCDocClasses})
299 endif()
301 set_directory_properties(
302         PROPERTIES
303         ADDITIONAL_MAKE_CLEAN_FILES "RenderedHelp")
305 #############################################
307 # testsuite
309 add_subdirectory(testsuite)
311 #############################################
312 # win32 install support
314 if(WIN32)
315         install(FILES ${FFTW3F_LIBRARY} ${SNDFILE_LIBRARY} ${PTHREADS_LIBRARY} ${PORTAUDIO_LIBRARIES}
316                 DESTINATION "SuperCollider"
317                 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
318 endif()
320 #############################################
321 # CPack support
323 set(CPACK_PACKAGE_VERSION_MAJOR 3)
324 set(CPACK_PACKAGE_VERSION_MINOR 5)
325 set(CPACK_PACKAGE_VERSION_PATCH dev)
326 include(CPack)
327 if(WIN32)
328         set(CPACK_MONOLITHIC_INSTALL 1)
329 endif()
331 #############################################
332 # hide advanced variables
333 mark_as_advanced(AVAHI_LIBRARIES AVAHI_INCLUDE_DIRS AVAHI_INCLUDE_DIR AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT)
334 mark_as_advanced(DL)
335 mark_as_advanced(EMACS_EXECUTABLE)
336 mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY)
337 mark_as_advanced(JACK JACK_INCLUDE_DIR JACK_LIBRARY)
338 mark_as_advanced(MATH_LIBRARY)
339 mark_as_advanced(QT_QMAKE_EXECUTABLE)
340 mark_as_advanced(SNDFILE)