51cb30799a7714ab973cd91bba092635fdb8c9b6
[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 chdir "${BUILD_DIR}/numpy/src/external_numpy/build/lib.${PYTHON_ARCH2}-3.5${NUMPY_DIR_POSTFIX}"
36                 ${CMAKE_COMMAND} -E tar "cfvz" "${LIBDIR}/python35_numpy_${NUMPY_SHORT_VERSION}${NUMPY_ARCHIVE_POSTFIX}.tar.gz" "."
37         )
38 else()
39         set(NUMPY_INSTALL
40                 ${CMAKE_COMMAND} -E copy_directory "${BUILD_DIR}/numpy/src/external_numpy/build/lib.${PYTHON_ARCH2}-3.5/numpy/" "${LIBDIR}/numpy/"
41         )
42 endif()
43
44 ExternalProject_Add(external_numpy
45         URL ${NUMPY_URI}
46         DOWNLOAD_DIR ${DOWNLOAD_DIR}
47         URL_HASH MD5=${NUMPY_HASH}
48         PREFIX ${BUILD_DIR}/numpy
49         PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/numpy/src/external_numpy < ${PATCH_DIR}/numpy.diff
50         CONFIGURE_COMMAND ""
51         LOG_BUILD 1
52         BUILD_COMMAND ${PYTHON_BINARY} ${BUILD_DIR}/numpy/src/external_numpy/setup.py build ${NUMPY_BUILD_OPTION}
53         INSTALL_COMMAND ${NUMPY_INSTALL}
54 )
55
56 add_dependencies(external_numpy Make_Python_Environment)