From 1324c0c425596cd27078dea1180ea6e8a8a37e34 Mon Sep 17 00:00:00 2001 From: Stefan Bienert <stefan.bienert@unibas.ch> Date: Thu, 20 Feb 2020 12:01:43 +0100 Subject: [PATCH] SCHWED-4635: Changes to make the container work --- CMakeLists.txt | 4 ++-- cmake_support/OST.cmake | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09cde1148..727630fe5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # Author: Marco Biasini #------------------------------------------------------------------------------- -cmake_minimum_required(VERSION 3.12.1 FATAL_ERROR) +cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) # Set CMake policies # Behaviour of target_link_libraries, always link by full path. CMP0060 can @@ -277,8 +277,8 @@ if (ENABLE_GUI) find_package(Qt5Widgets REQUIRED) find_package(Qt5OpenGL REQUIRED) set(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Gui Qt5::Widgets Qt5::Core) - ost_find_python_module(PyQt5.sip) ost_find_python_module(PyQt5) + ost_find_python_module_alt("PyQt5.sip;sip") endif() if (ENABLE_SPNAV) diff --git a/cmake_support/OST.cmake b/cmake_support/OST.cmake index 41e8f7a78..3b6821210 100644 --- a/cmake_support/OST.cmake +++ b/cmake_support/OST.cmake @@ -759,6 +759,34 @@ macro(ost_find_python_module MODULE) endif() endmacro() +#------------------------------------------------------------------------------- +# make sure the previously detected Python interpreter has the given module +# while allowing alternative module names +#------------------------------------------------------------------------------- +macro(ost_find_python_module_alt MODULES) + set(_PY_MODS "") + foreach(py_mod ${MODULES}) + if (NOT PYTHON_MODULE_${py_mod}) + set(_PY_MODS "${_PY_MODS} ${py_mod}") + message(STATUS "Searching for python module ${py_mod} for ${PYTHON_BINARY}") + execute_process(COMMAND ${PYTHON_BINARY} -c "import ${py_mod}" + OUTPUT_QUIET ERROR_QUIET + RESULT_VARIABLE _IMPORT_ERROR) + if (NOT _IMPORT_ERROR) + message(STATUS "Found python module ${py_mod}") + set("PYTHON_MODULE_${py_mod}" FOUND CACHE STRING "" FORCE) + break() + endif (NOT _IMPORT_ERROR) + else () + message(STATUS "Already found python module ${py_mod}") + unset(_IMPORT_ERROR) + break() + endif (NOT PYTHON_MODULE_${py_mod}) + endforeach(py_mod ${MODULES}) + if (_IMPORT_ERROR) + message(FATAL_ERROR "Could not find one of python modules ${_PY_MODS}. Please install one of them.") + endif () +endmacro() #------------------------------------------------------------------------------- # this macro tries to detect a very common problem during configuration stage: -- GitLab