build_environment: remove msvc compiler warning from 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 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(MSVC12)
30                 set(BOOST_TOOLSET toolset=msvc-12.0)
31                 set(BOOST_COMPILER_STRING -vc120)
32                 set(PYTHON_COMPILER_STRING v120)
33         endif()
34         if(MSVC14)
35                 set(BOOST_TOOLSET toolset=msvc-14.0)
36                 set(BOOST_COMPILER_STRING -vc140)
37                 set(PYTHON_COMPILER_STRING v140)
38         endif()
39         set(JAM_FILE ${BUILD_DIR}/boost/src/external_boost/user-config.jam)
40         set(semi_path "${PATCH_DIR}/semi.txt")
41         FILE(TO_NATIVE_PATH ${semi_path} semi_path)
42         set(BOOST_CONFIGURE_COMMAND bootstrap.bat &&
43                                                                 echo using python : ${PYTHON_OUTPUTDIR}\\python.exe > "${JAM_FILE}" &&
44                                                                 echo.   : ${BUILD_DIR}/python/src/external_python/include ${BUILD_DIR}/python/src/external_python/pc >> "${JAM_FILE}" &&
45                                                                 echo.   : ${BUILD_DIR}/python/src/external_python/pcbuild >> "${JAM_FILE}" &&
46                                                                 type ${semi_path} >> "${JAM_FILE}"
47         )
48         set(BOOST_BUILD_COMMAND bjam)
49         #--user-config=user-config.jam
50         set(BOOST_BUILD_OPTIONS runtime-link=static )
51         #set(BOOST_WITH_PYTHON --with-python)
52         set(BOOST_HARVEST_CMD   ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/lib/ ${HARVEST_TARGET}/boost/lib/ )
53         if(BUILD_MODE STREQUAL Release)
54                 set(BOOST_HARVEST_CMD ${BOOST_HARVEST_CMD} && ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/include/boost-1_60/ ${HARVEST_TARGET}/boost/include/)
55         endif()
56         set(BOOST_PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/boost/src/external_boost < ${PATCH_DIR}/boost.diff)
57
58 elseif(APPLE)
59         set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
60         set(BOOST_BUILD_COMMAND ./bjam)
61         set(BOOST_BUILD_OPTIONS toolset=clang cxxflags=${PLATFORM_CXXFLAGS} linkflags=${PLATFORM_LDFLAGS} --disable-icu boost.locale.icu=off)
62         set(BOOST_HARVEST_CMD echo .)
63         set(BOOST_PATCH_COMMAND echo .)
64 else()
65         set(BOOST_HARVEST_CMD echo .)
66         set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
67         set(BOOST_BUILD_COMMAND ./bjam)
68         set(BOOST_BUILD_OPTIONS cxxflags=${PLATFORM_CXXFLAGS} --disable-icu boost.locale.icu=off)
69         set(BOOST_PATCH_COMMAND echo .)
70 endif()
71
72 set(BOOST_OPTIONS
73         --with-filesystem
74         --with-locale
75         --with-thread
76         --with-regex
77         --with-system
78         --with-date_time
79         --with-wave
80         --with-atomic
81         --with-serialization
82         --with-program_options
83         --with-iostreams
84         ${BOOST_WITH_PYTHON}
85         ${BOOST_TOOLSET}
86 )
87
88 if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
89         set(BOOST_ADDRESS_MODEL 64)
90 else()
91         set(BOOST_ADDRESS_MODEL 32)
92 endif()
93
94 string(TOLOWER ${BUILD_MODE} BOOST_BUILD_TYPE)
95
96 ExternalProject_Add(external_boost
97         URL ${BOOST_URI}
98         DOWNLOAD_DIR ${DOWNLOAD_DIR}
99         URL_HASH MD5=${BOOST_MD5}
100         PREFIX ${BUILD_DIR}/boost
101         UPDATE_COMMAND  ""
102         PATCH_COMMAND ${BOOST_PATCH_COMMAND}
103         CONFIGURE_COMMAND ${BOOST_CONFIGURE_COMMAND}
104         BUILD_COMMAND ${BOOST_BUILD_COMMAND} ${BOOST_BUILD_OPTIONS} -j${MAKE_THREADS} architecture=x86 address-model=${BOOST_ADDRESS_MODEL} variant=${BOOST_BUILD_TYPE} link=static threading=multi ${BOOST_OPTIONS}    --prefix=${LIBDIR}/boost install
105         BUILD_IN_SOURCE 1
106         INSTALL_COMMAND "${BOOST_HARVEST_CMD}"
107 )
108
109 if(WIN32)
110         add_dependencies(
111                 external_boost
112                 Make_Python_Environment
113         )
114 endif()