forked from janelia-flyem/buildem
-
Notifications
You must be signed in to change notification settings - Fork 1
/
numpy.cmake
76 lines (64 loc) · 2.8 KB
/
numpy.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#
# Install numpy from source
#
if (NOT numpy_NAME)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
include (ExternalProject)
include (ExternalSource)
include (BuildSupport)
include (FortranSupport)
include (EasyInstall)
include (TemplateSupport)
include (PatchSupport)
include (python)
include (nose)
include (blas)
external_source (numpy
1.7.0 # When we upgrade to 1.8, patch step 2 is no longer needed (see below). Remove it.
numpy-1.7.0.tar.gz
4fa54e40b6a243416f0248123b6ec332
http://downloads.sourceforge.net/project/numpy/NumPy/1.7.0)
# Select FORTRAN ABI
if (Fortran_COMPILER_NAME STREQUAL "gfortran")
set (fortran_abi "gnu95")
elseif (Fortran_COMPILER_NAME STREQUAL "g77")
set (fortran_abi "gnu")
else ()
message (FATAL_ERROR "Unable to set FORTRAN ABI for numpy. Does not support ${Fortran_COMPILER_NAME}!")
endif ()
# Two "patch" steps:
# (1) Create a site.cfg (from a template) to ensure that the correct library search paths are provided.
# (2) Patch numpy/distutils/system_info.py for a Mac OS X fix (don't let built-in Accelerate library shadow ATLAS).
# (This patch will not be needed after we upgrade to 1.8, which is not released at the time of this writing.)
# Patch 1: Generate site.cfg from a template
if(NOT WITH_ATLAS)
# Use a special site-cfg to
configure_file(${BUILDEM_REPO_DIR}/templates/numpy-site-cfg-with-openblas.template ${BUILDEM_DIR}/tmp/numpy-site-with-openblas.cfg @ONLY)
set(NUMPY_REPLACE_SITE_CFG cp ${BUILDEM_DIR}/tmp/numpy-site-with-openblas.cfg ${numpy_SRC_DIR}/site.cfg)
else()
configure_file(${BUILDEM_REPO_DIR}/templates/numpy-site-cfg.template ${BUILDEM_DIR}/tmp/numpy-site.cfg @ONLY)
set(NUMPY_REPLACE_SITE_CFG cp ${BUILDEM_DIR}/tmp/numpy-site.cfg ${numpy_SRC_DIR}/site.cfg)
endif()
# Patch 2: system info (see above)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(NUMPY_PATCH_SYSTEM_INFO_PY ${PATCH_EXE} ${numpy_SRC_DIR}/numpy/distutils/system_info.py ${PATCH_DIR}/numpy.patch)
set(NUMPY_PATCH_COMMAND ${NUMPY_REPLACE_SITE_CFG} && ${NUMPY_PATCH_SYSTEM_INFO_PY})
else()
set(NUMPY_PATCH_COMMAND ${NUMPY_REPLACE_SITE_CFG})
endif()
# Download and install numpy
message ("Installing ${numpy_NAME} into FlyEM build area: ${BUILDEM_DIR} ...")
ExternalProject_Add(${numpy_NAME}
DEPENDS ${python_NAME} ${nose_NAME} ${blas_NAME}
PREFIX ${BUILDEM_DIR}
URL ${numpy_URL}
URL_MD5 ${numpy_MD5}
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
PATCH_COMMAND ${BUILDEM_ENV_STRING} ${NUMPY_PATCH_COMMAND}
BUILD_IN_SOURCE 1
BUILD_COMMAND ${BUILDEM_ENV_STRING} ${PYTHON_EXE} setup.py build --fcompiler=${fortran_abi}
INSTALL_COMMAND ${BUILDEM_ENV_STRING} ${PYTHON_EXE} setup.py install
)
set_target_properties(${numpy_NAME} PROPERTIES EXCLUDE_FROM_ALL ON)
endif (NOT numpy_NAME)