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> #
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 ##########################################################################
14 # ccmake BOOST_DIRECTORY #
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 #
22 # run the CMake GNU, load the Boost directory, and generate #
23 # project files or makefiles for your environment. #
25 # For more information about CMake, see http://www.cmake.org #
26 ##########################################################################
27 cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
31 ##########################################################################
32 # Post a warning to those attempting to use the CMake Build system. When #
33 # the build system stabilizes this can be removed. #
34 ##########################################################################
35 message(STATUS "##########################################################################")
37 message(STATUS " Only Boost.Build is officially supported.")
39 message(STATUS " This is not Boost.Build.")
41 message(STATUS " This is an alternate, cmake-based build system that is currently under development.")
43 message(STATUS " For more information on boost-cmake see the wiki:")
44 message(STATUS " https://svn.boost.org/trac/boost/wiki/CMake")
46 message(STATUS " Subscribe to the mailing list:")
47 message(STATUS " http://lists.boost.org/mailman/listinfo.cgi/boost-cmake")
49 message(STATUS " NOTE: Please ask questions about this build system on the boost-cmake list,")
50 message(STATUS " not on other boost lists.")
52 message(STATUS " And/or check the archives:")
53 message(STATUS " http://news.gmane.org/gmane.comp.lib.boost.cmake")
55 message(STATUS "##########################################################################")
57 ##########################################################################
58 # Version information #
59 ##########################################################################
60 set(BOOST_VERSION_MAJOR 1)
61 set(BOOST_VERSION_MINOR 40)
62 set(BOOST_VERSION_SUBMINOR 0)
63 set(BOOST_VERSION "${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_SUBMINOR}")
64 ##########################################################################
66 # Put the libaries and binaries that get built into directories at the
67 # top of the build tree rather than in hard-to-find leaf
68 # directories. This simplifies manual testing and the use of the build
69 # tree rather than installed Boost libraries.
70 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
71 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
72 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
74 ##########################################################################
75 # Boost CMake modules #
76 ##########################################################################
77 list(APPEND CMAKE_MODULE_PATH ${Boost_SOURCE_DIR}/tools/build/CMake)
84 ##########################################################################
86 ##########################################################################
87 # Build Features and Variants #
88 ##########################################################################
90 # Determine default settings for the variable BUILD_feature options
92 set(BUILD_SINGLE_THREADED_DEFAULT OFF)
94 set(BUILD_SINGLE_THREADED_DEFAULT OFF)
97 # User-level options deciding which variants we will build.
98 option(BUILD_STATIC "Whether to build static libraries" ON)
99 option(BUILD_SHARED "Whether to build shared libraries" ON)
100 option(BUILD_DEBUG "Whether to build debugging libraries" ON)
101 option(BUILD_RELEASE "Whether to build release libraries" ON)
102 option(BUILD_SINGLE_THREADED "Whether to build single-threaded libraries"
103 ${BUILD_SINGLE_THREADED_DEFAULT})
104 option(BUILD_MULTI_THREADED "Whether to build multi-threaded libraries" ON)
107 option(BUILD_VERSIONED "Add versioning information to names of built files" OFF)
109 option(BUILD_VERSIONED "Add versioning information to names of built files" ON)
113 # For now, we only actually support static/dynamic run-time variants for
114 # Visual C++. Provide both options for Visual C++ users, but just fix
115 # the values of the variables for all other platforms.
117 option(BUILD_STATIC_RUNTIME "Whether to build libraries linking against the static runtime" ON)
118 option(BUILD_DYNAMIC_RUNTIME "Whether to build libraries linking against the dynamic runtime" ON)
120 set(BUILD_STATIC_RUNTIME OFF)
121 set(BUILD_DYNAMIC_RUNTIME ON)
124 # The default set of library variants that we will be building
125 boost_add_default_variant(RELEASE DEBUG)
126 boost_add_default_variant(STATIC SHARED)
127 boost_add_default_variant(SINGLE_THREADED MULTI_THREADED)
128 boost_add_default_variant(DYNAMIC_RUNTIME STATIC_RUNTIME)
130 # Extra features used by some libraries
131 set(BUILD_PYTHON_NODEBUG ON)
132 boost_add_extra_variant(PYTHON_NODEBUG PYTHON_DEBUG)
133 ##########################################################################
135 ##########################################################################
137 ##########################################################################
140 if(BOOST_VERSION_SUBMINOR GREATER 0)
142 "include/boost-${BOOST_VERSION_MAJOR}_${BOOST_VERSION_MINOR}_${BOOST_VERSION_SUBMINOR}")
143 else(BOOST_VERSION_SUBMINOR GREATER 0)
145 "include/boost-${BOOST_VERSION_MAJOR}_${BOOST_VERSION_MINOR}")
146 endif(BOOST_VERSION_SUBMINOR GREATER 0)
147 else(BUILD_VERSIONED)
148 set(BOOST_HEADER_DIR "include/")
149 endif(BUILD_VERSIONED)
151 install(DIRECTORY boost
152 DESTINATION ${BOOST_HEADER_DIR}
153 PATTERN "CVS" EXCLUDE
154 PATTERN ".svn" EXCLUDE)
156 # TDS 20080526: Getting a segfault here even with the ifs. At r45780, with these lines
158 # 1. cmake the workspace
159 # 2. run ccmake and turn OFF BUILD_MULTI_THREADED and BUILD_SHARED
160 # 3. 'c' to configure
161 # 4. 'g' to generate.... segfault.
162 # 5. run rebuild_cache at the command line: no segfault this time.
164 # With these lines commented out, step 4 above does not segfault.
166 #if (NOT TEST_INSTALLED_TREE)
167 # If I don't have if around this, I get a seg fault
168 # install(EXPORT boost-targets DESTINATION "lib/Boost${BOOST_VERSION}")
169 #endif (NOT TEST_INSTALLED_TREE)
170 ##########################################################################
172 ##########################################################################
174 ##########################################################################
175 set(CPACK_PACKAGE_NAME "Boost")
176 set(CPACK_PACKAGE_VENDOR "Boost.org")
177 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Boost ${BOOST_VERSION}")
178 if (EXISTS "${Boost_SOURCE_DIR}/README.txt")
179 message(STATUS "Using generic cpack package description file.")
180 set(CPACK_PACKAGE_DESCRIPTION_FILE "${Boost_SOURCE_DIR}/README.txt")
181 set(CPACK_RESOURCE_FILE_README "${Boost_SOURCE_DIR}/README.txt")
183 set(CPACK_RESOURCE_FILE_LICENSE "${Boost_SOURCE_DIR}/LICENSE_1_0.txt")
184 if (EXISTS "${Boost_SOURCE_DIR}/Welcome.txt")
185 message(STATUS "Using generic cpack welcome file.")
186 set(CPACK_RESOURCE_FILE_WELCOME "${Boost_SOURCE_DIR}/Welcome.txt")
189 set(CPACK_PACKAGE_VERSION "${BOOST_VERSION}")
190 set(CPACK_PACKAGE_VERSION_MAJOR "${BOOST_VERSION_MAJOR}")
191 set(CPACK_PACKAGE_VERSION_MINOR "${BOOST_VERSION_MINOR}")
192 set(CPACK_PACKAGE_VERSION_PATCH "${BOOST_VERSION_SUBMINOR}")
193 set(CPACK_PACKAGE_INSTALL_DIRECTORY "Boost")
195 if(WIN32 AND NOT UNIX)
196 # There is a bug in NSI that does not handle full unix paths properly. Make
197 # sure there is at least one set of four (4) backlasshes.
198 # NOTE: No Boost icon yet
199 # set(CPACK_PACKAGE_ICON "${Boost_SOURCE_DIR}/tools/build/CMake\\\\InstallIcon.bmp")
200 # set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
201 set(CPACK_NSIS_DISPLAY_NAME "Boost ${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_SUBMINOR}")
202 set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.boost.org")
203 set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.boost.org")
204 set(CPACK_NSIS_CONTACT "boost-users@lists.boost.org")
205 set(CPACK_NSIS_MODIFY_PATH ON)
207 # Encode the compiler name in the package
209 set(CPACK_PACKAGE_FILE_NAME "Boost-${BOOST_VERSION}-vc6")
210 set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_DISPLAY_NAME} for Microsoft Visual C++ 6")
212 set(CPACK_PACKAGE_FILE_NAME "Boost-${BOOST_VERSION}-vc7")
213 set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_DISPLAY_NAME} for Microsoft Visual Studio 2002")
215 set(CPACK_PACKAGE_FILE_NAME "Boost-${BOOST_VERSION}-vc71")
216 set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_DISPLAY_NAME} for Microsoft Visual Studio 2003")
218 set(CPACK_PACKAGE_FILE_NAME "Boost-${BOOST_VERSION}-vc8")
219 set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_DISPLAY_NAME} for Microsoft Visual Studio 2005")
221 set(CPACK_PACKAGE_FILE_NAME "Boost-${BOOST_VERSION}-vc9")
222 set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_DISPLAY_NAME} for Microsoft Visual Studio 2008")
224 set(CPACK_PACKAGE_FILE_NAME "Boost-${BOOST_VERSION}-borland")
225 set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_DISPLAY_NAME} for Borland C++ Builder")
227 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_NSIS_DISPLAY_NAME}")
228 endif(WIN32 AND NOT UNIX)
231 option(BOOST_INSTALLER_ON_THE_FLY
232 "Whether to build installers that download components on-the-fly" OFF)
234 if (BOOST_INSTALLER_ON_THE_FLY)
235 if(COMMAND cpack_configure_downloads)
236 cpack_configure_downloads(
237 "http://www.osl.iu.edu/~dgregor/Boost-CMake/${BOOST_VERSION}/"
242 ##########################################################################
244 ##########################################################################
245 # Building Boost libraries #
246 ##########################################################################
247 # Always include the directory where Boost's include files will be.
248 if (TEST_INSTALLED_TREE)
249 # Use the headers from the installation directory
250 include_directories("${CMAKE_INSTALL_PREFIX}/${BOOST_HEADER_DIR}")
251 else (TEST_INSTALLED_TREE)
252 # Use the headers directly from the Boost source tree (in boost/)
253 include_directories(${Boost_SOURCE_DIR})
254 endif (TEST_INSTALLED_TREE)
256 # Boost.Build version 2 does this due to trouble with autolinking
257 # during building and testing.
258 # TODO: See if we can actually use auto-linking in our regression tests.
259 add_definitions(-DBOOST_ALL_NO_LIB=1)
261 # Add build rules for documentation
262 add_subdirectory(doc)
264 # Add build rules for all of the Boost libraries
265 add_subdirectory(libs)
267 # Add build rules for all of the Boost tools
268 # TODO: On hold while I work on the modularity code
269 add_subdirectory(tools)
270 ##########################################################################