CMakeLists.txt 12 KB

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