set(${_append_to} ${${_append_to}} PARENT_SCOPE)
endif()
endmacro()
+
+# Check if given Python module is installed and raises a FATAL_ERROR error
+# if the module cannot be found.
+function(check_python_module module)
+ execute_process(
+ COMMAND
+ ${PYTHON_EXECUTABLE} -c "import ${module}"
+ RESULT_VARIABLE
+ RET_MODULE_TEST
+ ERROR_QUIET
+ )
+
+ if(RET_MODULE_TEST)
+ message(FATAL_ERROR
+ "Could not find module ${module} for Python "
+ "version ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}. "
+ "Make sure to install ${module} for this Python version "
+ "via \n`${PYTHON_EXECUTABLE} -m pip install ${module}'.\n"
+ "Note: You need to have pip installed for this Python version.")
+ endif()
+endfunction()
## directory for licensing information.
##
# Check if the toml Python module is installed.
-execute_process(
- COMMAND
- ${PYTHON_EXECUTABLE} -c "import toml"
- RESULT_VARIABLE
- RET_TOML
- ERROR_QUIET
-)
-if(RET_TOML)
- message(FATAL_ERROR
- "Could not find toml for Python "
- "version ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}. "
- "Make sure to install toml for this Python version "
- "via \n`${PYTHON_EXECUTABLE} -m pip install toml'.\nNote: You need to "
- "have pip installed for this Python version.")
-endif()
+check_python_module("toml")
libcvc4_add_sources(
base_handlers.h
# Add Python bindings API tests
# Check if the pytest Python module is installed.
-execute_process(
- COMMAND
- ${PYTHON_EXECUTABLE} -c "import pytest"
- RESULT_VARIABLE
- RET_PYTEST
- ERROR_QUIET
-)
-
-if(RET_PYTEST)
- message(FATAL_ERROR
- "Could not find pytest for Python "
- "version ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}. "
- "Make sure to install pytest for this Python version "
- "via \n`${PYTHON_EXECUTABLE} -m pip install pytest'.\nNote: You need to "
- "have pip installed for this Python version.")
-endif()
+check_python_module("pytest")
macro(cvc4_add_python_api_test name filename)