-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
FindNumPy.cmake
30 lines (24 loc) · 1.05 KB
/
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
# Find the Python NumPy package
# PYTHON_NUMPY_INCLUDE_DIR
# PYTHON_NUMPY_FOUND
# will be set by this script
cmake_minimum_required(VERSION 3.7.2)
find_package( PythonInterp ${PSP_PYTHON_VERSION} EXACT REQUIRED )
# Find out the include path
execute_process(
COMMAND "${Python_EXECUTABLE}" -c
"from __future__ import print_function;import numpy;print(numpy.get_include(), end='')"
OUTPUT_VARIABLE __numpy_path)
# And the version
execute_process(
COMMAND "${Python_EXECUTABLE}" -c
"from __future__ import print_function;import numpy;print(numpy.__version__, end='')"
OUTPUT_VARIABLE __numpy_version)
find_path(PYTHON_NUMPY_INCLUDE_DIR numpy/arrayobject.h
HINTS "${__numpy_path}" "${PYTHON_INCLUDE_PATH}" NO_DEFAULT_PATH)
if(PYTHON_NUMPY_INCLUDE_DIR)
set(PYTHON_NUMPY_FOUND 1 CACHE INTERNAL "Python numpy found")
endif(PYTHON_NUMPY_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NumPy REQUIRED_VARS PYTHON_NUMPY_INCLUDE_DIR
VERSION_VAR __numpy_version)