CMakeLists.txt 13 KB

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