PageRenderTime 60ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/aqsis-1.8.1/CMakeLists.txt

#
CMake | 363 lines | 213 code | 64 blank | 86 comment | 32 complexity | c2c6a9c7801c99c1cbf3a2ff46572c75 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, MPL-2.0-no-copyleft-exception, GPL-2.0
  1. project(aqsis_all)
  2. cmake_minimum_required(VERSION 2.6.3)
  3. set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
  4. # Disallow in-source build
  5. string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" aqsis_in_source)
  6. if(aqsis_in_source)
  7. message(FATAL_ERROR "Aqsis requires an out of source build. Please clean any cmake-generated files from the source directory, create a separate build directory and run 'cmake path_to_source [options]' there.")
  8. endif()
  9. # Path to aqsis-specific include directories for cmake helper scripts.
  10. set(CMAKE_MODULE_PATH
  11. "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
  12. "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
  13. # Include some helper scripts and macros.
  14. include(UtilMacros)
  15. include(AqsisTesting)
  16. include(FirstCMakeRun)
  17. #-------------------------------------------------------------------------------
  18. # Build-time options which can be set from ccmake or the command line
  19. #--------------------------------------------------------------------
  20. option(AQSIS_USE_TIMERS "Enable performance timers" ON)
  21. option(AQSIS_USE_PDIFF "Build the external pdiff perceptual image difference utility" OFF)
  22. option(AQSIS_USE_QT "Build the aqsis GUI components which rely on the Qt libraries" ON)
  23. option(AQSIS_USE_OPENEXR "Build aqsis with support for the OpenEXR image format" ON)
  24. option(AQSIS_USE_PNG "Build aqsis with support for reading PNG image files" ON)
  25. option(AQSIS_USE_EXTERNAL_TINYXML "Try to find and use an external tinyxml library" OFF)
  26. mark_as_advanced(AQSIS_USE_PDIFF AQSIS_USE_EXTERNAL_TINYXML)
  27. option(aqsis_enable_testing "Enable unit testing" OFF)
  28. option(AQSIS_ENABLE_MPDUMP "Enable micropolygon dumping code" OFF)
  29. option(AQSIS_ENABLE_MASSIVE "Enable Massive support" ON)
  30. option(AQSIS_ENABLE_SIMBIONT "Enable Simbiont(RM) support" ON)
  31. option(AQSIS_ENABLE_THREADING "Enable multi-threading (EXPERIMENTAL)" OFF)
  32. option(AQSIS_ENABLE_DOCS "Enable documentation generation" ON)
  33. mark_as_advanced(AQSIS_ENABLE_MPDUMP AQSIS_ENABLE_MASSIVE AQSIS_ENABLE_SIMBIONT)
  34. option(AQSIS_USE_RPATH "Enable runtime path for installed libs" ON)
  35. mark_as_advanced(AQSIS_USE_RPATH)
  36. if(WIN32)
  37. # Find path to precompiled libs on windows.
  38. set(AQSIS_WIN32LIBS "" CACHE PATH "The location of the win32libs SVN folder")
  39. if(MINGW)
  40. set(AQSIS_DEPENDENCIES "${CMAKE_SOURCE_DIR}/../dependencies" CACHE PATH "The location of the pre-built dependencies")
  41. endif()
  42. endif()
  43. set(AQSIS_MAIN_CONFIG_NAME "aqsisrc"
  44. CACHE STRING "Name of the main aqsis configuration file")
  45. mark_as_advanced(AQSIS_MAIN_CONFIG_NAME)
  46. #-------------------------------------------------------------------------------
  47. # Find necessary library dependencies.
  48. #-------------------------------------
  49. # Required libs
  50. # -------------
  51. find_package(TIFF)
  52. find_package(ZLIB)
  53. # Find boost.
  54. if(WIN32)
  55. set(BOOST_ROOT "${AQSIS_DEPENDENCIES}" CACHE PATH "Root location of the boost install")
  56. if(NOT MINGW)
  57. set(Boost_USE_STATIC_LIBS ON)
  58. endif()
  59. else()
  60. set(BOOST_ROOT "$ENV{BOOST_ROOT}" CACHE PATH "Root location of the Boost install")
  61. endif()
  62. set(Boost_ADDITIONAL_VERSIONS "1.45.0" "1.45" "1.44.0" "1.44"
  63. "1.43.0" "1.43" "1.42.0" "1.42" "1.41.0" "1.41"
  64. "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37")
  65. find_package(Boost 1.34.1)
  66. # The following is a workaround because Boost versions > 1.35.0 need the
  67. # system library. CMake versions >2.6.4 should fix this properly.
  68. set(local_boost_version "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}")
  69. if(local_boost_version VERSION_LESS "1.35")
  70. if(WIN32)
  71. find_package(Boost 1.34.1
  72. COMPONENTS filesystem iostreams wave unit_test_framework thread regex zlib program_options)
  73. else()
  74. find_package(Boost 1.34.1
  75. COMPONENTS filesystem iostreams wave unit_test_framework thread regex program_options)
  76. endif()
  77. else()
  78. if(WIN32)
  79. find_package(Boost 1.34.1
  80. COMPONENTS filesystem iostreams wave unit_test_framework thread regex system zlib program_options)
  81. else()
  82. find_package(Boost 1.34.1
  83. COMPONENTS filesystem iostreams wave unit_test_framework thread regex system program_options)
  84. endif()
  85. endif()
  86. link_directories(${Boost_LIBRARY_DIRS})
  87. # Optional libs
  88. # -------------
  89. # GUI libs
  90. if(AQSIS_USE_QT)
  91. find_package(Qt4 4.6.2 COMPONENTS QtCore QtGui QtOpenGL)
  92. if(NOT QT_FOUND)
  93. message("** Qt4 not found - building without aqsis GUI tools")
  94. set(AQSIS_USE_QT OFF)
  95. endif()
  96. endif()
  97. # OpenEXR
  98. if(AQSIS_USE_OPENEXR)
  99. find_package(OpenEXR)
  100. if(NOT AQSIS_OPENEXR_FOUND)
  101. message("** Cannot find OpenEXR - aqsis will be built without support for the OpenEXR image format")
  102. set(AQSIS_USE_OPENEXR OFF)
  103. endif()
  104. endif()
  105. if(AQSIS_USE_PNG)
  106. find_package(PNG)
  107. if(NOT AQSIS_PNG_FOUND)
  108. message("** Cannot find PNG - aqsis will be built without support for the PNG image format")
  109. set(AQSIS_USE_PNG OFF)
  110. endif()
  111. endif()
  112. ## find tinyxml. If not found we use the version distributed with the aqsis
  113. ## source.
  114. #if(AQSIS_USE_EXTERNAL_TINYXML)
  115. # find_package(TinyXML)
  116. # if(NOT TINYXML_FOUND)
  117. # message("** Cannot find external tinyxml library - using version included with the aqsis source.")
  118. # set(AQSIS_USE_EXTERNAL_TINYXML OFF)
  119. # endif()
  120. #endif()
  121. #-------------------------------------------------------------------------------
  122. # Find build tools
  123. #-----------------
  124. include(FindFlexBison)
  125. if(NOT AQSIS_FLEX_EXECUTABLE_FOUND)
  126. message(FATAL_ERROR "Aqsis requires flex to build")
  127. endif()
  128. if(NOT AQSIS_BISON_EXECUTABLE_FOUND)
  129. message(FATAL_ERROR "Aqsis requires bison to build")
  130. endif()
  131. # Windows-specific build tools:
  132. include(FindNSIS)
  133. # Apple-specific build tools:
  134. include(FindOsacompile)
  135. include(FindXcodebuild)
  136. include(FindResource)
  137. #-------------------------------------------------------------------------------
  138. # Find documentation tools
  139. #-------------------------
  140. if(AQSIS_ENABLE_DOCS)
  141. include(FindSphinx)
  142. find_package(Doxygen)
  143. if(NOT AQSIS_SPHINX_EXECUTABLE_FOUND)
  144. message("** Cannot find Sphinx - building without generating relevant documentation")
  145. endif()
  146. if(NOT DOXYGEN_FOUND)
  147. message("** Cannot find Doxygen - building without generating relevant documentation")
  148. endif()
  149. if(NOT AQSIS_SPHINX_EXECUTABLE_FOUND AND NOT DOXYGEN_FOUND)
  150. set(AQSIS_ENABLE_DOCS OFF)
  151. endif()
  152. endif()
  153. #-------------------------------------------------------------------------------
  154. # Set program version numbers
  155. #----------------------------
  156. # These are needed by version.h, as well as the packaging stuff. Note that
  157. # some packaging variables are set in the platform-specific config files, and
  158. # these version variables are potentially used there.
  159. set(VERSION_MAJOR 1)
  160. set(VERSION_MINOR 8)
  161. set(VERSION_BUILD 1)
  162. set(SCM_REVISION 0) # "?"
  163. #-------------------------------------------------------------------------------
  164. # Set variables which control the build
  165. #--------------------------------------
  166. # Set convenience locations into which libraries and executables will be
  167. # placed during the build. Note: This is irrelevant to the install.
  168. set(RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
  169. set(LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
  170. #set(ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
  171. # Set default build type the first time cmake is run, but only if it's empty
  172. # since an alternative value might have been specified on the command line,
  173. # and we want this to override the default given below.
  174. #
  175. # We need to jump through some hoops here with the set_if_empty() macro, since
  176. # CMAKE_BUILD_TYPE is a system-defined variable which means we can't get to it
  177. # with set() before it's defined.
  178. if(FIRST_CMAKE_RUN)
  179. set_if_empty(CMAKE_BUILD_TYPE "Release" CACHE STRING
  180. "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
  181. FORCE
  182. )
  183. endif()
  184. # Make sure that CMAKE_INSTALL_PREFIX is absolute. If we don't do this, it
  185. # seems that we get relative values for the RPATH (which making
  186. # CMAKE_INSTALL_RPATH absolute doesn't help??), which results in broken
  187. # binaries.
  188. if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_PREFIX})
  189. message(STATUS "Warning: CMAKE_INSTALL_PREFIX relative path interpreted relative to build directory location.")
  190. set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}")
  191. endif()
  192. # Set up the install rpath if desired.
  193. set(CMAKE_SKIP_RPATH OFF CACHE INTERNAL
  194. "Disabled, since we need RPATHS to find aqsl during the build" FORCE)
  195. if(AQSIS_USE_RPATH)
  196. set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBDIR}")
  197. endif()
  198. #-------------------------------------------------------------------------------
  199. # System-specific includes
  200. #-------------------------
  201. # Include setup for system-specific paths, packaging etc
  202. if(WIN32)
  203. include(${CMAKE_SOURCE_DIR}/cmake/platform/windows.cmake)
  204. # Build the .rc files for library and executable version information and icons.
  205. set(INFORES_SRCS "${PROJECT_BINARY_DIR}/info.rc")
  206. set(ICONRES_SRCS "${PROJECT_BINARY_DIR}/icon.rc")
  207. configure_file("${CMAKE_SOURCE_DIR}/distribution/win/info.rc.in.cmake" ${INFORES_SRCS})
  208. configure_file("${CMAKE_SOURCE_DIR}/distribution/win/icon.rc.in.cmake" ${ICONRES_SRCS})
  209. elseif(APPLE)
  210. include(${CMAKE_SOURCE_DIR}/cmake/platform/macosx.cmake)
  211. else()
  212. include(${CMAKE_SOURCE_DIR}/cmake/platform/linux.cmake)
  213. endif()
  214. #-------------------------------------------------------------------------------
  215. # Add directories for all subprojects
  216. #------------------------------------
  217. add_subdirectory(include/aqsis)
  218. include_directories(
  219. "${PROJECT_SOURCE_DIR}/include"
  220. "${PROJECT_BINARY_DIR}/include"
  221. ${Boost_INCLUDE_DIRS}
  222. )
  223. # Thirdparty libs
  224. declare_subproject(thirdparty/tinyxml)
  225. declare_subproject(thirdparty/partio)
  226. declare_subproject(libs/pointrender)
  227. if(AQSIS_USE_PDIFF)
  228. add_subdirectory(thirdparty/pdiff)
  229. endif()
  230. # Build libraries
  231. add_subdirectory(libs/math)
  232. add_subdirectory(libs/util)
  233. get_directory_property(aqsis_util_location DIRECTORY libs/util DEFINITION aqsis_util_location)
  234. add_subdirectory(libs/riutil)
  235. add_subdirectory(libs/slcomp)
  236. get_directory_property(aqsis_slcomp_location DIRECTORY libs/slcomp DEFINITION aqsis_slcomp_location)
  237. add_subdirectory(libs/tex)
  238. add_subdirectory(libs/shadervm)
  239. add_subdirectory(libs/slxargs)
  240. add_subdirectory(libs/ri2rib)
  241. add_subdirectory(libs/core)
  242. # Build executable tools
  243. add_subdirectory(tools/aqsl)
  244. add_subdirectory(tools/aqsltell)
  245. add_subdirectory(tools/aqsis)
  246. add_subdirectory(tools/miqser)
  247. add_subdirectory(tools/teqser)
  248. if(AQSIS_USE_QT)
  249. add_subdirectory(tools/eqsl)
  250. add_subdirectory(tools/piqsl)
  251. add_subdirectory(tools/ptview)
  252. endif()
  253. # Build displays
  254. add_subdirectory(tools/displays)
  255. # Build additional plugins
  256. add_subdirectory(tools/procedurals/hairgen)
  257. #add_subdirectory(tools/shadeops/sci_volumes)
  258. add_subdirectory(tools/neqsus)
  259. # Build shaders & install examples
  260. add_subdirectory(shaders)
  261. add_subdirectory(examples)
  262. # Build documentation
  263. if(AQSIS_ENABLE_DOCS)
  264. add_subdirectory(doc)
  265. endif()
  266. # Packaging
  267. add_subdirectory(distribution)
  268. #-------------------------------------------------------------------------------
  269. # Create aqsisrc
  270. #--------------
  271. get_directory_property(display_DISPLAYLIB DIRECTORY tools/displays DEFINITION file_display_name)
  272. get_directory_property(d_exr_DISPLAYLIB DIRECTORY tools/displays DEFINITION exr_display_name)
  273. get_directory_property(d_bmp_DISPLAYLIB DIRECTORY tools/displays DEFINITION bmp_display_name)
  274. get_directory_property(d_xpm_DISPLAYLIB DIRECTORY tools/displays DEFINITION xpm_display_name)
  275. get_directory_property(piqsl_DISPLAYLIB DIRECTORY tools/displays DEFINITION piqsl_display_name)
  276. # Default search paths.
  277. set(DEFAULT_SHADERPATH ${shader_search_path})
  278. set(DEFAULT_ARCHIVEPATH "${CMAKE_INSTALL_PREFIX}")
  279. set(DEFAULT_TEXTUREPATH "${CMAKE_INSTALL_PREFIX}")
  280. set_with_path_prefix(DEFAULT_DISPLAYPATH "${PLUGINDIR}" "${CMAKE_INSTALL_PREFIX}")
  281. set_with_path_prefix(DEFAULT_PROCEDURALPATH "${PLUGINDIR}" "${CMAKE_INSTALL_PREFIX}")
  282. set(DEFAULT_RESOURCEPATH "${CMAKE_INSTALL_PREFIX}")
  283. # Search paths which are settable from the cmake build.
  284. set(SHADERPATH "${SHADERPATH}" CACHE STRING "Aqsis shader searchpath")
  285. set(ARCHIVEPATH "${ARCHIVEPATH}" CACHE STRING "Aqsis archive searchpath")
  286. set(TEXTUREPATH "${TEXTUREPATH}" CACHE STRING "Aqsis texture searchpath")
  287. set(DISPLAYPATH "${DISPLAYPATH}" CACHE STRING "Aqsis display searchpath")
  288. set(PROCEDURALPATH "${PROCEDURALPATH}" CACHE STRING "Aqsis procedural searchpath")
  289. set(RESOURCEPATH "${RESOURCEPATH}" CACHE STRING "Aqsis resource searchpath")
  290. set(aqsisrc_name ${PROJECT_BINARY_DIR}/aqsisrc)
  291. configure_file(aqsisrc.in.cmake ${aqsisrc_name})
  292. install(FILES ${aqsisrc_name} DESTINATION ${SYSCONFDIR} COMPONENT main)
  293. #-------------------------------------------------------------------------------
  294. # Generate an AqsisConfig.cmake file, for use by projects that want to link
  295. # against in the build tree rather than after installation.
  296. #-------------------------------------------------------------------------------
  297. set(AQSISCONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR}/AqsisConfig.cmake)
  298. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/AqsisConfig.cmake.in ${AQSISCONFIG_PATH})
  299. export(TARGETS aqsis_core aqsis_math aqsis_shadervm aqsis_tex aqsis_util aqsis_riutil APPEND FILE ${AQSISCONFIG_PATH})