9be6ea9f01198b4aa8104c2d8c58c0274bd6b41d
[blender.git] / build_files / build_environment / cmake / boost.cmake
1 # ***** BEGIN GPL LICENSE BLOCK *****
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ***** END GPL LICENSE BLOCK *****
18
19 if(WIN32)
20         if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
21                 set(PYTHON_ARCH x64)
22                 set(PYTHON_ARCH2 win-AMD64)
23                 set(PYTHON_OUTPUTDIR ${BUILD_DIR}/python/src/external_python/pcbuild/amd64/)
24         else()
25                 set(PYTHON_ARCH x86)
26                 set(PYTHON_ARCH2 win32)
27                 set(PYTHON_OUTPUTDIR ${BUILD_DIR}/python/src/external_python/pcbuild/win32/)
28         endif()
29         if(MSVC14)
30                 set(BOOST_TOOLSET toolset=msvc-14.0)
31                 set(BOOST_COMPILER_STRING -vc140)
32         endif()
33         set(JAM_FILE ${BUILD_DIR}/boost/src/external_boost/user-config.jam)
34         set(semi_path "${PATCH_DIR}/semi.txt")
35         FILE(TO_NATIVE_PATH ${semi_path} semi_path)
36         set(BOOST_CONFIGURE_COMMAND bootstrap.bat &&
37                                                                 echo using python : ${PYTHON_OUTPUTDIR}\\python.exe > "${JAM_FILE}" &&
38                                                                 echo.   : ${BUILD_DIR}/python/src/external_python/include ${BUILD_DIR}/python/src/external_python/pc >> "${JAM_FILE}" &&
39                                                                 echo.   : ${BUILD_DIR}/python/src/external_python/pcbuild >> "${JAM_FILE}" &&
40                                                                 type ${semi_path} >> "${JAM_FILE}"
41         )
42         set(BOOST_BUILD_COMMAND bjam)
43         #--user-config=user-config.jam
44         set(BOOST_BUILD_OPTIONS runtime-link=static )
45         #set(BOOST_WITH_PYTHON --with-python)
46         set(BOOST_HARVEST_CMD   ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/lib/ ${HARVEST_TARGET}/boost/lib/ )
47         if(BUILD_MODE STREQUAL Release)
48                 set(BOOST_HARVEST_CMD ${BOOST_HARVEST_CMD} && ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/include/boost-1_60/ ${HARVEST_TARGET}/boost/include/)
49         endif()
50
51 elseif(APPLE)
52         set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
53         set(BOOST_BUILD_COMMAND ./b2)
54         set(BOOST_BUILD_OPTIONS toolset=darwin cxxflags=${PLATFORM_CXXFLAGS} linkflags=${PLATFORM_LDFLAGS} --disable-icu boost.locale.icu=off)
55         set(BOOST_HARVEST_CMD echo .)
56         set(BOOST_PATCH_COMMAND echo .)
57 else()
58         set(BOOST_HARVEST_CMD echo .)
59         set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
60         set(BOOST_BUILD_COMMAND ./b2)
61         set(BOOST_BUILD_OPTIONS cxxflags=${PLATFORM_CXXFLAGS} --disable-icu boost.locale.icu=off)
62         set(BOOST_PATCH_COMMAND echo .)
63 endif()
64
65 set(BOOST_OPTIONS
66         --with-filesystem
67         --with-locale
68         --with-thread
69         --with-regex
70         --with-system
71         --with-date_time
72         --with-wave
73         --with-atomic
74         --with-serialization
75         --with-program_options
76         --with-iostreams
77         ${BOOST_WITH_PYTHON}
78         ${BOOST_TOOLSET}
79 )
80
81         set(BOOST_ADDRESS_MODEL 64)
82
83
84 string(TOLOWER ${BUILD_MODE} BOOST_BUILD_TYPE)
85
86 ExternalProject_Add(external_boost
87         URL ${BOOST_URI}
88         DOWNLOAD_DIR ${DOWNLOAD_DIR}
89         URL_HASH MD5=${BOOST_HASH}
90         PREFIX ${BUILD_DIR}/boost
91         UPDATE_COMMAND  ""
92         PATCH_COMMAND ${BOOST_PATCH_COMMAND}
93         CONFIGURE_COMMAND ${BOOST_CONFIGURE_COMMAND}
94         BUILD_COMMAND ${BOOST_BUILD_COMMAND} ${BOOST_BUILD_OPTIONS} -j${MAKE_THREADS} architecture=x86 address-model=${BOOST_ADDRESS_MODEL} link=static threading=multi ${BOOST_OPTIONS}        --prefix=${LIBDIR}/boost install
95         BUILD_IN_SOURCE 1
96         INSTALL_COMMAND "${BOOST_HARVEST_CMD}"
97 )
98
99 if(WIN32)
100         add_dependencies(
101                 external_boost
102                 Make_Python_Environment
103         )
104 endif()