#adapted from vigra source code


IF(PYTHONINTERP_FOUND)
    IF(NOT PYTHON_NUMPY_INCLUDE_DIR)
        execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c
                            "import numpy; print(numpy.get_include())"
                            RESULT_VARIABLE PYTHON_NUMPY_NOT_FOUND
                            OUTPUT_VARIABLE PYTHON_NUMPY_INCLUDE_DIR
                            OUTPUT_STRIP_TRAILING_WHITESPACE)
        IF(NOT PYTHON_NUMPY_NOT_FOUND)
            FILE(TO_CMAKE_PATH ${PYTHON_NUMPY_INCLUDE_DIR} PYTHON_NUMPY_INCLUDE_DIR)
        ELSE()
            SET(PYTHON_NUMPY_INCLUDE_DIR "PYTHON_NUMPY_INCLUDE_DIR-NOTFOUND")
        ENDIF()
    ENDIF()
ELSE()
    SET(PYTHON_NUMPY_INCLUDE_DIR "PYTHON_NUMPY_INCLUDE_DIR-NOTFOUND")
ENDIF()

SET(PYTHON_NUMPY_INCLUDE_DIR ${PYTHON_NUMPY_INCLUDE_DIR}
    CACHE PATH "Path to numpy include files" FORCE)

IF(PYTHON_NUMPY_INCLUDE_DIR)
    MESSAGE(STATUS "Found Numpy")
    MESSAGE(STATUS "  > includes:      ${PYTHON_NUMPY_INCLUDE_DIR}")
ELSE()
    MESSAGE(FATAL_ERROR "Could not find Numpy")
ENDIF()


MARK_AS_ADVANCED(PYTHON_NUMPY_INCLUDE_DIR)
