build_environment: buildfixes for boost
[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 set(BOOST_ADDRESS_MODEL 64)
20
21 if(WIN32)
22         if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
23                 set(PYTHON_ARCH x64)
24                 set(PYTHON_ARCH2 win-AMD64)
25                 set(PYTHON_OUTPUTDIR ${BUILD_DIR}/python/src/external_python/pcbuild/amd64/)
26         else()
27                 set(PYTHON_ARCH x86)
28                 set(PYTHON_ARCH2 win32)
29                 set(PYTHON_OUTPUTDIR ${BUILD_DIR}/python/src/external_python/pcbuild/win32/)
30                 set(BOOST_ADDRESS_MODEL 32)
31         endif()
32         if(MSVC14)
33                 set(BOOST_TOOLSET toolset=msvc-14.0)
34                 set(BOOST_COMPILER_STRING -vc140)
35         endif()
36         set(JAM_FILE ${BUILD_DIR}/boost/src/external_boost/user-config.jam)
37         set(semi_path "${PATCH_DIR}/semi.txt")
38         FILE(TO_NATIVE_PATH ${semi_path} semi_path)
39         set(BOOST_CONFIGURE_COMMAND bootstrap.bat &&
40                                                                 echo using python : ${PYTHON_OUTPUTDIR}\\python.exe > "${JAM_FILE}" &&
41                                                                 echo.   : ${BUILD_DIR}/python/src/external_python/include ${BUILD_DIR}/python/src/external_python/pc >> "${JAM_FILE}" &&
42                                                                 echo.   : ${BUILD_DIR}/python/src/external_python/pcbuild >> "${JAM_FILE}" &&
43                                                                 type ${semi_path} >> "${JAM_FILE}"
44         )
45         set(BOOST_BUILD_COMMAND bjam)
46         #--user-config=user-config.jam
47         set(BOOST_BUILD_OPTIONS runtime-link=static )
48         #set(BOOST_WITH_PYTHON --with-python)
49         set(BOOST_HARVEST_CMD   ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/lib/ ${HARVEST_TARGET}/boost/lib/ )
50         if(BUILD_MODE STREQUAL Release)
51                 set(BOOST_HARVEST_CMD ${BOOST_HARVEST_CMD} && ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/include/boost-1_68/ ${HARVEST_TARGET}/boost/include/)
52         endif()
53
54 elseif(APPLE)
55         set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
56         set(BOOST_BUILD_COMMAND ./b2)
57         set(BOOST_BUILD_OPTIONS toolset=darwin cxxflags=${PLATFORM_CXXFLAGS} linkflags=${PLATFORM_LDFLAGS} --disable-icu boost.locale.icu=off)
58         set(BOOST_HARVEST_CMD echo .)
59         set(BOOST_PATCH_COMMAND echo .)
60 else()
61         set(BOOST_HARVEST_CMD echo .)
62         set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
63         set(BOOST_BUILD_COMMAND ./b2)
64         set(BOOST_BUILD_OPTIONS cxxflags=${PLATFORM_CXXFLAGS} --disable-icu boost.locale.icu=off)
65         set(BOOST_PATCH_COMMAND echo .)
66 endif()
67
68 set(BOOST_OPTIONS
69         --with-filesystem
70         --with-locale
71         --with-thread
72         --with-regex
73         --with-system
74         --with-date_time
75         --with-wave
76         --with-atomic
77         --with-serialization
78         --with-program_options
79         --with-iostreams
80         ${BOOST_WITH_PYTHON}
81         ${BOOST_TOOLSET}
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()