Copy generator's rule name when cloning
[boost.git] / CMakeLists.txt
blob99c76aeaf26b4684173d09da09c7f9fc4a3117d9
1 ##########################################################################
2 # CMake Build Rules for Boost                                            #
3 ##########################################################################
4 # Copyright (C) 2007, 2008 Douglas Gregor <doug.gregor@gmail.com>        #
5 # Copyright (C) 2007 Troy Straszheim                                     #
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)
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 "##########################################################################")
37 message(STATUS " THE CMAKE BUILD SYSTEM IS CURRENTLY UNDER DEVELOPMENT. PLEASE USE THE    ")
38 message(STATUS " BJAM BASED SYSTEM INSTEAD TO BUILD A PRODUCTION VERSION OF BOOST. IF YOU ")
39 message(STATUS " STILL WANT TO TRY IT OUT INVOKE CMake WITH '-DCMAKE_IS_EXPERIMENTAL:boolean=TRUE'")
40 message(STATUS " ARGUMENT. After this first run of cmake you will no longer have to supply")
41 message(STATUS " the argument unless you need to run a cmake on a clean build directory.")
42 message(STATUS "##########################################################################")
43 message(FATAL_ERROR "")
44 endif (NOT CMAKE_IS_EXPERIMENTAL)
46 ##########################################################################
47 # Version information                                                    #
48 ##########################################################################
49 set(BOOST_VERSION_MAJOR 1)
50 set(BOOST_VERSION_MINOR 37)
51 set(BOOST_VERSION_SUBMINOR 0)
52 set(BOOST_VERSION "${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_SUBMINOR}")
53 ##########################################################################
55 # Put the libaries and binaries that get built into directories at the
56 # top of the build tree rather than in hard-to-find leaf
57 # directories. This simplifies manual testing and the use of the build
58 # tree rather than installed Boost libraries.
59 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
60 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
61 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
63 ##########################################################################
64 # Boost CMake modules                                                    #
65 ##########################################################################
66 list(APPEND CMAKE_MODULE_PATH ${Boost_SOURCE_DIR}/tools/build/CMake)
67 include(BoostUtils)
68 include(BoostConfig)
69 include(BoostBuildSlave)
70 include(BoostCore)
71 include(BoostDocs)
72 include(BoostTesting)
73 ##########################################################################
75 ##########################################################################
76 # Build Features and Variants                                            #
77 ##########################################################################
79 # Determine default settings for the variable BUILD_feature options
80 if (MSVC)
81   set(BUILD_SINGLE_THREADED_DEFAULT OFF)
82 else ()
83   set(BUILD_SINGLE_THREADED_DEFAULT OFF)
84 endif ()
86 # User-level options deciding which variants we will build. 
87 option(BUILD_STATIC "Whether to build static libraries" ON)
88 option(BUILD_SHARED "Whether to build shared libraries" ON)
89 option(BUILD_DEBUG "Whether to build debugging libraries" ON)
90 option(BUILD_RELEASE "Whether to build release libraries" ON)
91 option(BUILD_SINGLE_THREADED "Whether to build single-threaded libraries" 
92        ${BUILD_SINGLE_THREADED_DEFAULT})
93 option(BUILD_MULTI_THREADED "Whether to build multi-threaded libraries" ON)
95 # For now, we only actually support static/dynamic run-time variants for 
96 # Visual C++. Provide both options for Visual C++ users, but just fix
97 # the values of the variables for all other platforms.
98 if(MSVC)
99   option(BUILD_STATIC_RUNTIME "Whether to build libraries linking against the static runtime" ON)
100   option(BUILD_DYNAMIC_RUNTIME "Whether to build libraries linking against the dynamic runtime" ON)
101 else(MSVC)
102   set(BUILD_STATIC_RUNTIME OFF)
103   set(BUILD_DYNAMIC_RUNTIME ON)
104 endif(MSVC)
106 # The default set of library variants that we will be building
107 boost_add_default_variant(RELEASE DEBUG)
108 boost_add_default_variant(STATIC SHARED)
109 boost_add_default_variant(SINGLE_THREADED MULTI_THREADED)
110 boost_add_default_variant(DYNAMIC_RUNTIME STATIC_RUNTIME)
112 # Extra features used by some libraries
113 set(BUILD_PYTHON_NODEBUG ON)
114 boost_add_extra_variant(PYTHON_NODEBUG PYTHON_DEBUG)
115 ##########################################################################
117 ##########################################################################
118 # Installation                                                           #
119 ##########################################################################
120 if(BOOST_VERSION_SUBMINOR GREATER 0)
121   set(BOOST_HEADER_DIR 
122       "include/boost-${BOOST_VERSION_MAJOR}_${BOOST_VERSION_MINOR}_${BOOST_VERSION_SUBMINOR}")
123 else(BOOST_VERSION_SUBMINOR GREATER 0)
124   set(BOOST_HEADER_DIR 
125       "include/boost-${BOOST_VERSION_MAJOR}_${BOOST_VERSION_MINOR}")  
126 endif(BOOST_VERSION_SUBMINOR GREATER 0)
127 install(DIRECTORY boost 
128         DESTINATION ${BOOST_HEADER_DIR}
129         PATTERN "CVS" EXCLUDE
130         PATTERN ".svn" EXCLUDE)
132 # TDS 20080526:  Getting a segfault here even with the ifs.   At r45780, with these lines 
133 # uncommented:
134 # 1. cmake the workspace
135 # 2. run ccmake and turn OFF BUILD_MULTI_THREADED and BUILD_SHARED
136 # 3. 'c' to configure
137 # 4. 'g' to generate.... segfault.
138 # 5. run rebuild_cache at the command line:  no segfault this time.
140 # With these lines commented out, step 4 above does not segfault.
142 #if (NOT TEST_INSTALLED_TREE)
143   # If I don't have if around this, I get a seg fault
144 #  install(EXPORT boost-targets DESTINATION "lib/Boost${BOOST_VERSION}")
145 #endif (NOT TEST_INSTALLED_TREE)
146 ##########################################################################
148 ##########################################################################
149 # Binary packages                                                        #
150 ##########################################################################
151 set(CPACK_PACKAGE_NAME "Boost")
152 set(CPACK_PACKAGE_VENDOR "Boost.org")
153 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Boost ${BOOST_VERSION}")
154 set(CPACK_PACKAGE_DESCRIPTION_FILE "${Boost_SOURCE_DIR}/README.txt")
155 set(CPACK_RESOURCE_FILE_README "${Boost_SOURCE_DIR}/README.txt")
156 set(CPACK_RESOURCE_FILE_LICENSE "${Boost_SOURCE_DIR}/LICENSE_1_0.txt")
157 set(CPACK_RESOURCE_FILE_WELCOME "${Boost_SOURCE_DIR}/Welcome.txt")
158 set(CPACK_PACKAGE_VERSION "${BOOST_VERSION}")
159 set(CPACK_PACKAGE_VERSION_MAJOR "${BOOST_VERSION_MAJOR}")
160 set(CPACK_PACKAGE_VERSION_MINOR "${BOOST_VERSION_MINOR}")
161 set(CPACK_PACKAGE_VERSION_PATCH "${BOOST_VERSION_SUBMINOR}")
162 set(CPACK_PACKAGE_INSTALL_DIRECTORY "Boost")
164 if(WIN32 AND NOT UNIX)
165   # There is a bug in NSI that does not handle full unix paths properly. Make
166   # sure there is at least one set of four (4) backlasshes.
167   # NOTE: No Boost icon yet
168 #  set(CPACK_PACKAGE_ICON "${Boost_SOURCE_DIR}/tools/build/CMake\\\\InstallIcon.bmp")
169 #  set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
170   set(CPACK_NSIS_DISPLAY_NAME "Boost ${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_SUBMINOR}")
171   set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.boost.org")
172   set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.boost.org")
173   set(CPACK_NSIS_CONTACT "boost-users@lists.boost.org")
174   set(CPACK_NSIS_MODIFY_PATH ON)
175   
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)
200 if(COMMAND cpack_configure_downloads)
201   cpack_configure_downloads(
202   "http://www.osl.iu.edu/~dgregor/Boost-CMake/${BOOST_VERSION}/"
203     ALL ADD_REMOVE)
204 endif()
205 ##########################################################################
207 ##########################################################################
208 # Building Boost libraries                                               #
209 ##########################################################################
210 # Always include the directory where Boost's include files will be.
211 if (TEST_INSTALLED_TREE)
212   # Use the headers from the installation directory
213   include_directories("${CMAKE_INSTALL_PREFIX}/${BOOST_HEADER_DIR}")
214 else (TEST_INSTALLED_TREE)
215   # Use the headers directly from the Boost source tree (in boost/)
216   include_directories(${Boost_SOURCE_DIR})
217 endif (TEST_INSTALLED_TREE)
219 # Boost.Build version 2 does this due to trouble with autolinking
220 # during building and testing.  
221 # TODO: See if we can actually use auto-linking in our regression tests.
222 add_definitions(-DBOOST_ALL_NO_LIB=1)
224 # Add build rules for documentation
225 add_subdirectory(doc)
227 # Add build rules for all of the Boost libraries
228 add_subdirectory(${BOOST_LIBS_DIR})
230 # Add build rules for all of the Boost tools
231 # TODO: On hold while I work on the modularity code
232 add_subdirectory(tools)
233 ##########################################################################