CMake
ParaViewFindPythonModules.cmake
Go to the documentation of this file.
1
2
# Check whether a Python module is available by name, and if it is,
3
# define a variable in the internal cache.
4
function
(
_find_python_module_internal
module_name)
5
# Check
for
presence of the module. Even though we don
't use all the
6
# variable names set here, assigning them suppresses their output in CMake.
7
execute_process(COMMAND "${Python3_EXECUTABLE}" -c "import ${module_name}"
8
RESULT_VARIABLE IMPORT_${module_name}_EXITCODE
9
OUTPUT_VARIABLE IMPORT_${module_name}_OUTPUT
10
ERROR_VARIABLE IMPORT_${module_name}_ERROR
11
)
12
if(${IMPORT_${module_name}_EXITCODE} EQUAL 0)
13
set(PYTHON_MODULE_${module_name}_FOUND TRUE PARENT_SCOPE)
14
else()
15
set(PYTHON_MODULE_${module_name}_FOUND FALSE PARENT_SCOPE)
16
endif()
17
endfunction()
18
19
# Function to simplify checking if a Python module is available
20
function(find_python_module module_name result)
21
if(NOT PYTHON_MODULE_${module_name}_FOUND)
22
_find_python_module_internal(${module_name})
23
endif()
24
set(${result} ${PYTHON_MODULE_${module_name}_FOUND} PARENT_SCOPE)
25
endfunction()
_find_python_module_internal
function _find_python_module_internal(module_name)
Definition:
ParaViewFindPythonModules.cmake:4
Generated by
1.8.13 on Sat May 18 2024