-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61b5660
commit 8260b92
Showing
2 changed files
with
51 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
|
||
if(NOT PYTHON_EXECUTABLE) | ||
find_package(PythonInterp QUIET) | ||
endif() | ||
|
||
if (PYTHON_EXECUTABLE) | ||
# Find out the include path | ||
execute_process( | ||
COMMAND "${PYTHON_EXECUTABLE}" -c | ||
"from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept:pass\n" | ||
RESULT_VARIABLE _NUMPY_RESULT | ||
OUTPUT_VARIABLE py_ilmbase_numpy_path | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
if(NOT _NUMPY_RESULT MATCHES 0) | ||
set(NumPy_FOUND 0 CACHE INTERNAL "Python numpy not found") | ||
return() | ||
endif() | ||
|
||
# And the version | ||
execute_process( | ||
COMMAND "${PYTHON_EXECUTABLE}" -c | ||
"from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept:pass\n" | ||
RESULT_VARIABLE _NUMPY_RESULT | ||
OUTPUT_VARIABLE py_ilmbase_numpy_version | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
if(NOT _NUMPY_RESULT MATCHES 0) | ||
set(NumPy_FOUND 0 CACHE INTERNAL "Python numpy not found") | ||
return() | ||
endif() | ||
|
||
find_path(NUMPY_INCLUDE_DIRS numpy/arrayobject.h | ||
HINTS "${py_ilmbase_numpy_path}" "${PYTHON_INCLUDE_PATH}" NO_DEFAULT_PATH) | ||
|
||
if(NUMPY_INCLUDE_DIRS) | ||
set(NumPy_FOUND 1 CACHE INTERNAL "Python numpy found") | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(NumPy REQUIRED_VARS NUMPY_INCLUDE_DIRS | ||
VERSION_VAR py_ilmbase_numpy_version) | ||
else() | ||
set(NumPy_FOUND 0 CACHE INTERNAL "Python numpy not found") | ||
message(WARNING "Numpy not found, PyImathNumpy will not be built") | ||
endif() | ||
|
||
else () | ||
message(WARNING "Numpy not found, PyImathNumpy will not be built") | ||
set(NumPy_FOUND 0 CACHE INTERNAL "Python numpy not found") | ||
endif() |