From c80754bea120411e281b700b08f97e0a8b2c0463 Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 9 Feb 2022 13:27:51 +0300 Subject: [PATCH] bos #26347 [CEA 26325] qtwebengine5-dev and GUI conflict: rewrite Qt 5 detection procedure --- cmake/FindSalomeQt5.cmake | 86 ++++++++++++--------------------------- cmake/UseQtExt.cmake | 4 +- 2 files changed, 28 insertions(+), 62 deletions(-) diff --git a/cmake/FindSalomeQt5.cmake b/cmake/FindSalomeQt5.cmake index fe05688..63dcd3d 100644 --- a/cmake/FindSalomeQt5.cmake +++ b/cmake/FindSalomeQt5.cmake @@ -16,84 +16,50 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# Author: Adrien Bruneton -# - # Qt5 detection for Salome -# -# !! Please read the generic detection procedure in SalomeMacros.cmake !! -# -# Qt5_FIND_COMPONENTS variable is set here to prevent ParaView to reset list of Qt5 modules, +# NOTE: Qt5_FIND_COMPONENTS variable is set here to prevent ParaView to reset list of Qt5 modules, # just to avoid extra dependencies SET(QT_INCLUDES) SET(QT_DEFINITIONS) SET(QT_LIBRARIES) -# Find Qt5Core to get Qt version -SET(Qt5_FIND_COMPONENTS QtCore) -SET(Qt5_OPTIONAL_COMPONENTS) -FIND_PACKAGE(Qt5Core) -IF(Qt5Core_FOUND) - LIST(APPEND QT_INCLUDES ${Qt5Core_INCLUDE_DIRS}) - LIST(APPEND QT_DEFINITIONS ${Qt5Core_DEFINITIONS}) - LIST(APPEND QT_LIBRARIES ${Qt5Core_LIBRARIES}) - SET(QT_VERSION "${Qt5Core_VERSION}") -ENDIF() - -# Add mandatory Qt 5 components below -SET(Qt5_FIND_COMPONENTS Gui Widgets Network Xml OpenGL PrintSupport Help Test) -# Add optional Qt 5 components below -SET(Qt5_OPTIONAL_COMPONENTS) - -IF ("${QT_VERSION}" VERSION_LESS "5.6.0") - # QtWebKit package is used with Qt < 5.6 - LIST(APPEND Qt5_FIND_COMPONENTS WebKit WebKitWidgets) -ELSE() - # QtWebEngine package is (optionally) used with Qt >= 5.6 - # Anyway, not available with Python 3 - LIST(APPEND Qt5_OPTIONAL_COMPONENTS WebEngineCore WebEngine WebEngineWidgets) -ENDIF() +# Detect mandatory Qt 5 components +SET(Qt5_FIND_COMPONENTS Core Gui Widgets Network Xml OpenGL PrintSupport Help Test LinguistTools) IF(NOT WIN32) - ## QtX11Extras package is used on Linux only LIST(APPEND Qt5_FIND_COMPONENTS X11Extras) ENDIF() +FIND_PACKAGE(Qt5 5.8 REQUIRED COMPONENTS ${Qt5_FIND_COMPONENTS}) +FOREACH(_Qt5_COMPONENT ${Qt5_FIND_COMPONENTS}) + MESSAGE(STATUS "Qt5${_Qt5_COMPONENT} found in ${Qt5${_Qt5_COMPONENT}_DIR}") + LIST(APPEND QT_INCLUDES ${Qt5${_Qt5_COMPONENT}_INCLUDE_DIRS}) + LIST(APPEND QT_DEFINITIONS ${Qt5${_Qt5_COMPONENT}_DEFINITIONS}) + LIST(APPEND QT_LIBRARIES ${Qt5${_Qt5_COMPONENT}_LIBRARIES}) +ENDFOREACH() -FOREACH(_Qt5_COMPONENT_ ${Qt5_FIND_COMPONENTS} ${Qt5_OPTIONAL_COMPONENTS}) - SET(_Qt5_COMPONENT Qt5${_Qt5_COMPONENT_}) - LIST(FIND Qt5_OPTIONAL_COMPONENTS ${_Qt5_COMPONENT_} idx) - IF(${idx} GREATER -1) - SET(Salome${_Qt5_COMPONENT}_FIND_QUIETLY TRUE) +# Detect optional Qt 5 components +SET(Qt5_OPTIONAL_COMPONENTS WebEngineCore WebEngine WebEngineWidgets) +FIND_PACKAGE(Qt5 5.8 QUIET COMPONENTS ${Qt5_OPTIONAL_COMPONENTS}) +FOREACH(_Qt5_COMPONENT ${Qt5_OPTIONAL_COMPONENTS}) + IF(Qt5${_Qt5_COMPONENT}_FOUND) + MESSAGE(STATUS "Qt5${_Qt5_COMPONENT} found in ${Qt5${_Qt5_COMPONENT}_DIR}") + LIST(APPEND QT_INCLUDES ${Qt5${_Qt5_COMPONENT}_INCLUDE_DIRS}) + LIST(APPEND QT_DEFINITIONS ${Qt5${_Qt5_COMPONENT}_DEFINITIONS}) + LIST(APPEND QT_LIBRARIES ${Qt5${_Qt5_COMPONENT}_LIBRARIES}) + ELSE() + MESSAGE(STATUS "Optional Qt5${_Qt5_COMPONENT} is not found.") ENDIF() - FIND_PACKAGE(${_Qt5_COMPONENT}) - LIST(APPEND QT_INCLUDES ${${_Qt5_COMPONENT}_INCLUDE_DIRS}) - LIST(APPEND QT_DEFINITIONS ${${_Qt5_COMPONENT}_DEFINITIONS}) - LIST(APPEND QT_LIBRARIES ${${_Qt5_COMPONENT}_LIBRARIES}) ENDFOREACH() -FIND_PACKAGE(Qt5LinguistTools) -GET_TARGET_PROPERTY(QT_LRELEASE_EXECUTABLE Qt5::lrelease LOCATION) -MARK_AS_ADVANCED(QT_LRELEASE_EXECUTABLE) - -GET_FILENAME_COMPONENT(QT_BINARY_DIR ${QT_LRELEASE_EXECUTABLE} DIRECTORY) -MARK_AS_ADVANCED(QT_BINARY_DIR) - -# This is only needed to correctly detect Qt help generator tool, to workaround an error -# coming from ParaView detection procedure -FIND_PROGRAM(QT_HELP_GENERATOR - qhelpgenerator - PATHS "${QT_BINARY_DIR}" - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - DOC "qhelpgenerator used to compile Qt help project files") -MARK_AS_ADVANCED(QT_HELP_GENERATOR) +SET(QT_VERSION "${Qt5Core_VERSION}") +LIST(REMOVE_DUPLICATES QT_INCLUDES) +LIST(REMOVE_DUPLICATES QT_DEFINITIONS) +LIST(REMOVE_DUPLICATES QT_LIBRARIES) IF(Qt5Core_FOUND) SALOME_ACCUMULATE_HEADERS(QT_INCLUDES) - SALOME_ACCUMULATE_ENVIRONMENT(PATH ${LINGUIST_PATH}) SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${Qt5Core_LIBRARIES}) - GET_FILENAME_COMPONENT(Qt5_DIR ${Qt5Core_DIR} PATH) - FILE(TO_NATIVE_PATH "${Qt5_DIR}/Qt5" Qt5_DIR) SET(SalomeQt5_COMPONENTS ${Qt5_FIND_COMPONENTS}) - MESSAGE(STATUS "Qt version is ${QT_VERSION}") + MESSAGE(STATUS "Found Qt version ${QT_VERSION}") ENDIF() diff --git a/cmake/UseQtExt.cmake b/cmake/UseQtExt.cmake index aebb122..09eeaf4 100644 --- a/cmake/UseQtExt.cmake +++ b/cmake/UseQtExt.cmake @@ -22,7 +22,7 @@ IF (QT_VERSION VERSION_LESS "5.0") ENDIF() # This MACRO uses the following vars -# - QT_LRELEASE_EXECUTABLE : (given by default by FindQT.cmake) +# - Qt5_LRELEASE_EXECUTABLE : (given by default by FindSalomeQt5.cmake) # # tsfiles containing all ts files to be compiled. # installdir contains directory (relative to install_prefix) where to install files after compilation of ts files too qm. @@ -30,7 +30,7 @@ MACRO(QT_INSTALL_TS_RESOURCES tsfiles installdir) FOREACH(_input ${tsfiles}) GET_FILENAME_COMPONENT(_name ${_input} NAME_WE) SET(_output ${CMAKE_CURRENT_BINARY_DIR}/${_name}.qm) - SET(_cmd_${_name} ${QT_LRELEASE_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${_input} -qm ${_output}) + SET(_cmd_${_name} ${Qt5_LRELEASE_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${_input} -qm ${_output}) ADD_CUSTOM_TARGET(QT_INSTALL_TS_RESOURCES_${_name} ALL COMMAND ${_cmd_${_name}} DEPENDS ${_input}) INSTALL(FILES ${_output} DESTINATION ${installdir}) ENDFOREACH() -- 2.39.2