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