[build_deps/Windows] Add numpy headers to the python include folder on windows, requi...
[blender-staging.git] / build_files / build_environment / cmake / numpy.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(MSVC)
20         if(BUILD_MODE STREQUAL Debug)
21                 set(NUMPY_DIR_POSTFIX -pydebug)
22                 set(NUMPY_ARCHIVE_POSTFIX d)
23                 set(NUMPY_BUILD_OPTION --debug)
24         else()
25                 set(NUMPY_DIR_POSTFIX)
26                 set(NUMPY_ARCHIVE_POSTFIX)
27                 set(NUMPY_BUILD_OPTION)
28         endif(BUILD_MODE STREQUAL Debug)
29 endif()
30
31 set(NUMPY_POSTFIX)
32
33 if(WIN32)
34         set(NUMPY_INSTALL
35                 ${CMAKE_COMMAND} -E copy_directory "${BUILD_DIR}/python/src/external_python/run/lib/site-packages/numpy/core/include/numpy" "${LIBDIR}/python/include/python3.5/numpy" &&
36                 ${CMAKE_COMMAND} -E chdir "${BUILD_DIR}/numpy/src/external_numpy/build/lib.${PYTHON_ARCH2}-3.5${NUMPY_DIR_POSTFIX}" 
37                 ${CMAKE_COMMAND} -E tar "cfvz" "${LIBDIR}/python35_numpy_${NUMPY_SHORT_VERSION}${NUMPY_ARCHIVE_POSTFIX}.tar.gz" "." 
38         )
39 else()
40         set(NUMPY_INSTALL
41                 ${CMAKE_COMMAND} -E copy_directory "${BUILD_DIR}/numpy/src/external_numpy/build/lib.${PYTHON_ARCH2}-3.5/numpy/" "${LIBDIR}/numpy/"
42         )
43 endif()
44
45 ExternalProject_Add(external_numpy
46         URL ${NUMPY_URI}
47         DOWNLOAD_DIR ${DOWNLOAD_DIR}
48         URL_HASH MD5=${NUMPY_HASH}
49         PREFIX ${BUILD_DIR}/numpy
50         PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/numpy/src/external_numpy < ${PATCH_DIR}/numpy.diff
51         CONFIGURE_COMMAND ""
52         LOG_BUILD 1
53         BUILD_COMMAND ${PYTHON_BINARY} ${BUILD_DIR}/numpy/src/external_numpy/setup.py build ${NUMPY_BUILD_OPTION} install
54         INSTALL_COMMAND ${NUMPY_INSTALL}
55 )
56
57 add_dependencies(external_numpy Make_Python_Environment)