diff --git a/cmake/FindPythonFull.cmake b/cmake/FindPythonFull.cmake new file mode 100644 index 0000000000000000000000000000000000000000..6b70423eaaf0fef9254c22c1a772569267eeef0a --- /dev/null +++ b/cmake/FindPythonFull.cmake @@ -0,0 +1,56 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# +# +# PythonFull +# ----------- +# +# Try to find various pieces needed for a full python environment including +# python libs, interpreter, and modules +# +# This module defines the following variables: +# +# PythonFull_FOUND +# PYTHONINTERP_FOUND +# PYTHON_EXECUTABLE +# PYTHONLIBS_FOUND +# PYTHON_LIBRARIES +# PythonModule_${module_NAME}_FOUND +# +# This is intented to be called by specifying components for libraries, +# interpreter, and modules. So, for example, if you needed libraries, the +# interpreter, mpi4py, and numpy then you would call: +# +# find_package(PythonFull COMPONENTS Interp Libs mpi4py numpy) +# + +include(CMakeFindDependencyMacro) +set(_req_vars) +foreach(comp IN LISTS PythonFull_FIND_COMPONENTS) + if(comp STREQUAL Interp) + find_package(PythonInterp) + set(PythonFull_${comp}_FOUND ${PYTHONINTERP_FOUND}) + list(APPEND _req_vars PYTHON_EXECUTABLE) + elseif(comp STREQUAL Libs) + find_package(PythonLibsNew) + set(PythonFull_${comp}_FOUND ${PYTHONLIBS_FOUND}) + list(APPEND _req_vars PYTHON_LIBRARIES) + else() + # Parse off any specified headers and libs for a given module + set(_comp ${comp}) + list(GET _comp 0 _mod) + string(REGEX REPLACE "${_mod}\\\;[^;]*" "${_mod}" + PythonFull_FIND_COMPONENTS "${PythonFull_FIND_COMPONENTS}" + ) + set(PythonFull_FIND_REQUIRED_${_mod} TRUE) + find_package(PythonModule COMPONENTS ${_comp}) + set(PythonFull_${_mod}_FOUND ${PythonModule_${_mod}_FOUND}) + endif() +endforeach() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PythonFull + REQUIRED_VARS ${_req_vars} + HANDLE_COMPONENTS +) diff --git a/cmake/FindPythonModule.cmake b/cmake/FindPythonModule.cmake index 492d1d28f4205b856903fae195fa9d9a208f042d..c47f71dbc19c6ae8ddcb3ee8618c69b79487802f 100644 --- a/cmake/FindPythonModule.cmake +++ b/cmake/FindPythonModule.cmake @@ -119,8 +119,9 @@ set( PythonModule_${module_NAME}_PATH endif() include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(PythonModule_${module_NAME} DEFAULT_MSG - ${required_vars} + find_package_handle_standard_args(PythonModule_${module_NAME} + FOUND_VAR PythonModule_${module_NAME}_FOUND + REQUIRED_VARS ${required_vars} ) endif()