Skip to content
Snippets Groups Projects
  • Studer Gabriel's avatar
    5f9ab1dc
    Fix cmake findnumpy · 5f9ab1dc
    Studer Gabriel authored
    - Fix python code that is injected into python interpreter
    - Proper error handling => fatal_error to stop cmake run if numpy not found
    5f9ab1dc
    History
    Fix cmake findnumpy
    Studer Gabriel authored
    - Fix python code that is injected into python interpreter
    - Proper error handling => fatal_error to stop cmake run if numpy not found
FindNumpy.cmake 993 B
if (PYTHON_NUMPY_INCLUDE_DIR)
  # in cache already
  set (PYTHON_NUMPY_FIND_QUIETLY TRUE)
endif (PYTHON_NUMPY_INCLUDE_DIR)

#INCLUDE(FindPython)

IF(PYTHON_BINARY)
    EXEC_PROGRAM ("${PYTHON_BINARY}"
      ARGS "-c 'import numpy; print(numpy.get_include())'"
      OUTPUT_VARIABLE PYTHON_NUMPY_INCLUDE_DIR
      RETURN_VALUE PYTHON_NUMPY_NOT_FOUND)
    if (PYTHON_NUMPY_NOT_FOUND)
      set(PYTHON_NUMPY_FOUND FALSE)
    else (PYTHON_NUMPY_NOT_FOUND)
      set (PYTHON_NUMPY_FOUND TRUE)
      set (PYTHON_NUMPY_INCLUDE_DIR ${PYTHON_NUMPY_INCLUDE_DIR} CACHE STRING "Numpy include path")
    endif (PYTHON_NUMPY_NOT_FOUND)
ENDIF(PYTHON_BINARY)

if (PYTHON_NUMPY_FOUND)
  if (NOT PYTHON_NUMPY_FIND_QUIETLY)
    message (STATUS "Numpy headers found")
  endif (NOT PYTHON_NUMPY_FIND_QUIETLY)
else (PYTHON_NUMPY_FOUND)
  if (Numpy_FIND_REQUIRED)
    message (FATAL_ERROR "Numpy headers missing")
  endif (Numpy_FIND_REQUIRED)
endif (PYTHON_NUMPY_FOUND)

MARK_AS_ADVANCED (PYTHON_NUMPY_INCLUDE_DIR)