summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerome Soumagne <jsoumagne@hdfgroup.org>2013-12-10 17:05:44 (GMT)
committerJerome Soumagne <jsoumagne@hdfgroup.org>2013-12-10 17:05:44 (GMT)
commit32650995eb862992401310e14168c23dfa8043c2 (patch)
treed5068b3a4860722236cf7839afe68c7ecf7dcbe4
parentcb7a1cb7dddb8035fcb67bd6ca5489c7cd080157 (diff)
downloadhdf5-32650995eb862992401310e14168c23dfa8043c2.zip
hdf5-32650995eb862992401310e14168c23dfa8043c2.tar.gz
hdf5-32650995eb862992401310e14168c23dfa8043c2.tar.bz2
[svn-r24523] Add FindPythonNumPy.cmake to properly get numpy headers
-rw-r--r--CMakeLists.txt6
-rw-r--r--config/cmake/FindPythonNumPy.cmake28
2 files changed, 34 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 425aa3a..299c6fc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -711,6 +711,12 @@ IF (HDF5_ENABLE_PARALLEL)
ELSE (PYTHONLIBS_FOUND)
MESSAGE (FATAL_ERROR "Could not find Python Libraries, please check PYTHON_INCLUDE_DIR.")
ENDIF (PYTHONLIBS_FOUND)
+ FIND_PACKAGE(PythonNumPy REQUIRED)
+ IF (PYTHON_NUMPY_FOUND)
+ INCLUDE_DIRECTORIES (${PYTHON_NUMPY_INCLUDE_DIR})
+ ELSE (PYTHON_NUMPY_FOUND)
+ MESSAGE (FATAL_ERROR "Could not find NumPy headers, please check PYTHON_EXECUTABLE.")
+ ENDIF (PYTHON_NUMPY_FOUND)
ENDIF (HDF5_ENABLE_PYTHON)
ENDIF (HDF5_ENABLE_EFF)
ENDIF (HDF5_ENABLE_PARALLEL)
diff --git a/config/cmake/FindPythonNumPy.cmake b/config/cmake/FindPythonNumPy.cmake
new file mode 100644
index 0000000..77099a8
--- /dev/null
+++ b/config/cmake/FindPythonNumPy.cmake
@@ -0,0 +1,28 @@
+# - Find NumPy
+# Find the native numpy includes
+# This module defines
+# PYTHON_NUMPY_INCLUDE_DIR, where to find numpy/arrayobject.h, etc.
+# PYTHON_NUMPY_FOUND, If false, do not try to use numpy headers.
+
+IF (PYTHON_NUMPY_INCLUDE_DIR)
+ # in cache already
+ SET (PYTHON_NUMPY_FIND_QUIETLY TRUE)
+ENDIF (PYTHON_NUMPY_INCLUDE_DIR)
+
+INCLUDE (FindPythonInterp)
+
+IF (PYTHON_EXECUTABLE)
+ EXEC_PROGRAM ("${PYTHON_EXECUTABLE}"
+ ARGS "-c \"import numpy; print numpy.get_include()\""
+ OUTPUT_VARIABLE PYTHON_NUMPY_INCLUDE_PATH
+ RETURN_VALUE PYTHON_NUMPY_NOT_FOUND)
+
+ IF (NOT ${PYTHON_NUMPY_INCLUDE_PATH} MATCHES "Traceback")
+ SET (PYTHON_NUMPY_INCLUDE_DIR ${PYTHON_NUMPY_INCLUDE_PATH} CACHE STRING "Numpy include path.")
+ ENDIF (NOT ${PYTHON_NUMPY_INCLUDE_PATH} MATCHES "Traceback")
+ENDIF(PYTHON_EXECUTABLE)
+
+INCLUDE (FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS (PYTHON_NUMPY DEFAULT_MSG PYTHON_NUMPY_INCLUDE_DIR)
+
+MARK_AS_ADVANCED (PYTHON_NUMPY_INCLUDE_DIR)