CMakeLists.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. ##########################################################################
  2. # CMake Build Rules for Boost #
  3. ##########################################################################
  4. # Copyright (C) 2007, 2008 Douglas Gregor <doug.gregor@gmail.com> #
  5. # Copyright (C) 2007, 2009 Troy Straszheim <troy@resophonic.com> #
  6. # #
  7. # Distributed under the Boost Software License, Version 1.0. #
  8. # See accompanying file LICENSE_1_0.txt or copy at #
  9. # http://www.boost.org/LICENSE_1_0.txt #
  10. ##########################################################################
  11. # Basic Usage: #
  12. # #
  13. # On Unix variants: #
  14. # ccmake BOOST_DIRECTORY #
  15. # #
  16. # (c)onfigure options to your liking, then (g)enerate #
  17. # makefiles. Use "make" to build, "make test" to test, "make #
  18. # install" to install, and "make package" to build binary #
  19. # packages. #
  20. # #
  21. # On Windows: #
  22. # run the CMake GNU, load the Boost directory, and generate #
  23. # project files or makefiles for your environment. #
  24. # #
  25. # For more information about CMake, see http://www.cmake.org #
  26. ##########################################################################
  27. cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
  28. project(Boost)
  29. ##########################################################################
  30. # Version information #
  31. ##########################################################################
  32. # We parse the version information from the boost/version.hpp header.
  33. file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/boost/version.hpp BOOST_VERSIONSTR
  34. REGEX "#define[ ]+BOOST_VERSION[ ]+[0-9]+")
  35. string(REGEX MATCH "[0-9]+" BOOST_VERSIONSTR ${BOOST_VERSIONSTR})
  36. if (BOOST_VERSIONSTR)
  37. math(EXPR BOOST_VERSION_MAJOR "${BOOST_VERSIONSTR} / 100000")
  38. math(EXPR BOOST_VERSION_MINOR "${BOOST_VERSIONSTR} / 100 % 1000")
  39. math(EXPR BOOST_VERSION_SUBMINOR "${BOOST_VERSIONSTR} % 100")
  40. set(BOOST_VERSION "${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_SUBMINOR}")
  41. message(STATUS "Boost version ${BOOST_VERSION}")
  42. else()
  43. message(FATAL_ERROR
  44. "Unable to parse Boost version from ${CMAKE_CURRENT_SOURCE_DIR}/boost/version.hpp")
  45. endif()
  46. # Make sure that we reconfigure when boost/version.hpp changes.
  47. configure_file(boost/version.hpp
  48. ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/version.stamp)
  49. ##########################################################################
  50. # Put the libaries and binaries that get built into directories at the
  51. # top of the build tree rather than in hard-to-find leaf
  52. # directories. This simplifies manual testing and the use of the build
  53. # tree rather than installed Boost libraries.
  54. SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
  55. SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
  56. SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
  57. ##########################################################################
  58. # Boost CMake modules #
  59. ##########################################################################
  60. list(APPEND CMAKE_MODULE_PATH ${Boost_SOURCE_DIR}/tools/build/CMake)
  61. include(BoostUtils)
  62. include(BoostConfig)
  63. include(BoostCore)
  64. include(BoostDocs)
  65. include(CTest)
  66. include(BoostTesting)
  67. message(STATUS "Build name: ${BUILDNAME}")
  68. ##########################################################################
  69. ##########################################################################
  70. # Build Features and Variants #
  71. ##########################################################################
  72. # Determine default settings for the variable BUILD_feature options
  73. if (MSVC)
  74. set(BUILD_SINGLE_THREADED_DEFAULT OFF)
  75. else ()
  76. set(BUILD_SINGLE_THREADED_DEFAULT OFF)
  77. endif ()
  78. # User-level options deciding which variants we will build.
  79. option(BUILD_STATIC "Whether to build static libraries" ON)
  80. option(BUILD_SHARED "Whether to build shared libraries" ON)
  81. option(BUILD_DEBUG "Whether to build debugging libraries" ON)
  82. option(BUILD_RELEASE "Whether to build release libraries" ON)
  83. option(BUILD_SINGLE_THREADED "Whether to build single-threaded libraries"
  84. ${BUILD_SINGLE_THREADED_DEFAULT})
  85. option(BUILD_MULTI_THREADED "Whether to build multi-threaded libraries" ON)
  86. if(UNIX)
  87. option(BUILD_VERSIONED "Add versioning information to names of built files" OFF)
  88. else(UNIX)
  89. option(BUILD_VERSIONED "Add versioning information to names of built files" ON)
  90. endif(UNIX)
  91. # For now, we only actually support static/dynamic run-time variants for
  92. # Visual C++. Provide both options for Visual C++ users, but just fix
  93. # the values of the variables for all other platforms.
  94. if(MSVC)
  95. option(BUILD_STATIC_RUNTIME "Whether to build libraries linking against the static runtime" ON)
  96. option(BUILD_DYNAMIC_RUNTIME "Whether to build libraries linking against the dynamic runtime" ON)
  97. else(MSVC)
  98. set(BUILD_STATIC_RUNTIME OFF)
  99. set(BUILD_DYNAMIC_RUNTIME ON)
  100. endif(MSVC)
  101. # The default set of library variants that we will be building
  102. boost_add_default_variant(RELEASE DEBUG)
  103. boost_add_default_variant(STATIC SHARED)
  104. boost_add_default_variant(SINGLE_THREADED MULTI_THREADED)
  105. boost_add_default_variant(DYNAMIC_RUNTIME STATIC_RUNTIME)
  106. # Extra features used by some libraries
  107. set(BUILD_PYTHON_NODEBUG ON)
  108. boost_add_extra_variant(PYTHON_NODEBUG PYTHON_DEBUG)
  109. ##########################################################################
  110. ##########################################################################
  111. # Installation #
  112. ##########################################################################
  113. if(BUILD_VERSIONED)
  114. if(BOOST_VERSION_SUBMINOR GREATER 0)
  115. set(BOOST_HEADER_DIR
  116. "include/boost-${BOOST_VERSION_MAJOR}_${BOOST_VERSION_MINOR}_${BOOST_VERSION_SUBMINOR}")
  117. else(BOOST_VERSION_SUBMINOR GREATER 0)
  118. set(BOOST_HEADER_DIR
  119. "include/boost-${BOOST_VERSION_MAJOR}_${BOOST_VERSION_MINOR}")
  120. endif(BOOST_VERSION_SUBMINOR GREATER 0)
  121. else(BUILD_VERSIONED)
  122. set(BOOST_HEADER_DIR "include/")
  123. endif(BUILD_VERSIONED)
  124. install(DIRECTORY boost
  125. DESTINATION ${BOOST_HEADER_DIR}
  126. PATTERN "CVS" EXCLUDE
  127. PATTERN ".svn" EXCLUDE)
  128. #
  129. # TDS 20080526: Getting a segfault here even with the ifs. At r45780, with these lines
  130. # uncommented:
  131. # 1. cmake the workspace
  132. # 2. run ccmake and turn OFF BUILD_MULTI_THREADED and BUILD_SHARED
  133. # 3. 'c' to configure
  134. # 4. 'g' to generate.... segfault.
  135. # 5. run rebuild_cache at the command line: no segfault this time.
  136. #
  137. # With these lines commented out, step 4 above does not segfault.
  138. #
  139. #if (NOT TEST_INSTALLED_TREE)
  140. # If I don't have if around this, I get a seg fault
  141. # install(EXPORT boost-targets DESTINATION "lib/Boost${BOOST_VERSION}")
  142. #endif (NOT TEST_INSTALLED_TREE)
  143. ##########################################################################
  144. ##########################################################################
  145. # Binary packages #
  146. ##########################################################################
  147. set(CPACK_PACKAGE_NAME "Boost")
  148. set(CPACK_PACKAGE_VENDOR "Boost.org")
  149. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Boost ${BOOST_VERSION}")
  150. if (EXISTS "${Boost_SOURCE_DIR}/README.txt")
  151. message(STATUS "Using generic cpack package description file.")
  152. set(CPACK_PACKAGE_DESCRIPTION_FILE "${Boost_SOURCE_DIR}/README.txt")
  153. set(CPACK_RESOURCE_FILE_README "${Boost_SOURCE_DIR}/README.txt")
  154. endif ()
  155. set(CPACK_RESOURCE_FILE_LICENSE "${Boost_SOURCE_DIR}/LICENSE_1_0.txt")
  156. if (EXISTS "${Boost_SOURCE_DIR}/Welcome.txt")
  157. message(STATUS "Using generic cpack welcome file.")
  158. set(CPACK_RESOURCE_FILE_WELCOME "${Boost_SOURCE_DIR}/Welcome.txt")
  159. endif()
  160. set(CPACK_PACKAGE_VERSION "${BOOST_VERSION}")
  161. set(CPACK_PACKAGE_VERSION_MAJOR "${BOOST_VERSION_MAJOR}")
  162. set(CPACK_PACKAGE_VERSION_MINOR "${BOOST_VERSION_MINOR}")
  163. set(CPACK_PACKAGE_VERSION_PATCH "${BOOST_VERSION_SUBMINOR}")
  164. set(CPACK_PACKAGE_INSTALL_DIRECTORY "Boost")
  165. if(WIN32 AND NOT UNIX)
  166. # There is a bug in NSI that does not handle full unix paths properly. Make
  167. # sure there is at least one set of four (4) backlasshes.
  168. # NOTE: No Boost icon yet
  169. # set(CPACK_PACKAGE_ICON "${Boost_SOURCE_DIR}/tools/build/CMake\\\\InstallIcon.bmp")
  170. # set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
  171. set(CPACK_NSIS_DISPLAY_NAME "Boost ${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_SUBMINOR}")
  172. set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.boost.org")
  173. set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.boost.org")
  174. set(CPACK_NSIS_CONTACT "boost-users@lists.boost.org")
  175. set(CPACK_NSIS_MODIFY_PATH ON)
  176. # Encode the compiler name in the package
  177. if (MSVC60)
  178. set(CPACK_PACKAGE_FILE_NAME "Boost-${BOOST_VERSION}-vc6")
  179. set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_DISPLAY_NAME} for Microsoft Visual C++ 6")
  180. elseif (MSVC70)
  181. set(CPACK_PACKAGE_FILE_NAME "Boost-${BOOST_VERSION}-vc7")
  182. set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_DISPLAY_NAME} for Microsoft Visual Studio 2002")
  183. elseif (MSVC71)
  184. set(CPACK_PACKAGE_FILE_NAME "Boost-${BOOST_VERSION}-vc71")
  185. set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_DISPLAY_NAME} for Microsoft Visual Studio 2003")
  186. elseif (MSVC80)
  187. set(CPACK_PACKAGE_FILE_NAME "Boost-${BOOST_VERSION}-vc8")
  188. set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_DISPLAY_NAME} for Microsoft Visual Studio 2005")
  189. elseif (MSVC90)
  190. set(CPACK_PACKAGE_FILE_NAME "Boost-${BOOST_VERSION}-vc9")
  191. set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_DISPLAY_NAME} for Microsoft Visual Studio 2008")
  192. elseif (BORLAND)
  193. set(CPACK_PACKAGE_FILE_NAME "Boost-${BOOST_VERSION}-borland")
  194. set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_DISPLAY_NAME} for Borland C++ Builder")
  195. endif (MSVC60)
  196. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_NSIS_DISPLAY_NAME}")
  197. endif(WIN32 AND NOT UNIX)
  198. include(CPack)
  199. option(BOOST_INSTALLER_ON_THE_FLY
  200. "Whether to build installers that download components on-the-fly" OFF)
  201. if (BOOST_INSTALLER_ON_THE_FLY)
  202. if(COMMAND cpack_configure_downloads)
  203. cpack_configure_downloads(
  204. "http://www.osl.iu.edu/~dgregor/Boost-CMake/${BOOST_VERSION}/"
  205. ALL ADD_REMOVE)
  206. endif()
  207. endif()
  208. ##########################################################################
  209. ##########################################################################
  210. # Building Boost libraries #
  211. ##########################################################################
  212. # Always include the directory where Boost's include files will be.
  213. if (TEST_INSTALLED_TREE)
  214. # Use the headers from the installation directory
  215. include_directories("${CMAKE_INSTALL_PREFIX}/${BOOST_HEADER_DIR}")
  216. else (TEST_INSTALLED_TREE)
  217. # Use the headers directly from the Boost source tree (in boost/)
  218. include_directories(${Boost_SOURCE_DIR})
  219. endif (TEST_INSTALLED_TREE)
  220. # Boost.Build version 2 does this due to trouble with autolinking
  221. # during building and testing.
  222. # TODO: See if we can actually use auto-linking in our regression tests.
  223. add_definitions(-DBOOST_ALL_NO_LIB=1)
  224. # Add build rules for documentation
  225. add_subdirectory(doc)
  226. # Add build rules for all of the Boost libraries
  227. add_subdirectory(libs)
  228. # Add build rules for all of the Boost tools
  229. # TODO: On hold while I work on the modularity code
  230. add_subdirectory(tools)
  231. ##########################################################################
粤ICP备19079148号