From 9e32acb59d3a72ca7acfa8d759ee361fe4e9b729 Mon Sep 17 00:00:00 2001 From: Pierre Gergondet Date: Thu, 15 Dec 2022 12:28:24 +0900 Subject: [PATCH] Fallback to python2 if python is not python 2 --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ec9fa29e54..59f2933b317 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,7 +171,18 @@ endif() execute_process( COMMAND python -c "from distutils import sysconfig; print sysconfig.get_config_var(\"VERSION\")" OUTPUT_VARIABLE PYTHON_VERSION + RESULT_VARIABLE PYTHON_VERSION_SUCCESS OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT PYTHON_VERSION_SUCCESS STREQUAL 0) + execute_process( + COMMAND python2 -c "from distutils import sysconfig; print sysconfig.get_config_var(\"VERSION\")" + OUTPUT_VARIABLE PYTHON_VERSION + RESULT_VARIABLE PYTHON_VERSION_SUCCESS + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT PYTHON_VERSION_SUCCESS STREQUAL 0) + message(FATAL_ERROR "Could not determine Python 2 version, maybe it is not installed?") + endif() +endif() set(python_dist_pkg_dir lib/python${PYTHON_VERSION}/dist-packages) configure_file(hrpsys-base.pc.in ${CMAKE_CURRENT_BINARY_DIR}/hrpsys-base.pc @ONLY)