-
Notifications
You must be signed in to change notification settings - Fork 25
/
FindNumPy.cmake
40 lines (29 loc) · 999 Bytes
/
FindNumPy.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
# - Try to find NumPy
# Once done, this will define
#
# NUMPY_FOUND - system has numpy
# NUMPY_INCLUDE_DIRS - the numpy include directories
find_package(PythonInterp 3.2)
find_package(PythonLibs 3.2)
set(_NUMPY_SEARCH_DIRECTORIES)
if(PYTHONLIBS_FOUND)
list(APPEND _NUMPY_SEARCH_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
endif()
if(PYTHONINTERP_FOUND)
execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import numpy; print(numpy.get_include(), end='')"
OUTPUT_VARIABLE _PYTHON_NUMPY_PATH
RESULT_VARIABLE _ERROR_FINDING_NUMPY)
if(${_ERROR_FINDING_NUMPY} EQUAL 0)
list(APPEND _NUMPY_SEARCH_DIRECTORIES ${_PYTHON_NUMPY_PATH})
endif()
endif()
find_path(NUMPY_INCLUDE_DIR
NAMES numpy/ndarrayobject.h
PATHS ${_NUMPY_SEARCH_DIRECTORIES}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NumPy DEFAULT_MSG NUMPY_INCLUDE_DIR)
if(NUMPY_FOUND)
set(NUMPY_INCLUDE_DIRS ${NUMPY_INCLUDE_DIR})
endif()
mark_as_advanced(NUMPY_INCLUDE_DIR NUMPY_INCLUDE_DIRS)