diff --git a/CMakeLists.txt b/CMakeLists.txt index 49328f8..a9bcfdd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,18 @@ if (NOT Qt6Core_FOUND) find_package(Qt5 COMPONENTS Core QUIET) endif() +# Qt versions installed by conda packages include some extra dependencies +if(QT_LIBINFIX STREQUAL "_conda") + message("Found Qt installed by conda package. Getting specific extra dependencies...") + # Qt5 and Qt6 dependencies + sofa_find_package(ZSTD REQUIRED) # required by Qt5::Core_conda + sofa_find_package(PCRE2 COMPONENTS 16BIT REQUIRED) # required by Qt5::Core_conda + sofa_find_package(PNG REQUIRED) # required by Qt5::Gui_conda + if(SOFA_BUILD_RELEASE_PACKAGE AND CMAKE_SYSTEM_NAME STREQUAL Windows) + sofa_install_libraries(TARGETS ZSTD::ZSTD PNG::PNG PCRE2::16BIT) + endif() +endif() + if (Qt6Core_FOUND) message("${PROJECT_NAME}: will use Qt6") find_package(Qt6 COMPONENTS Gui GuiTools Widgets WidgetsTools OpenGLWidgets REQUIRED) @@ -89,7 +101,18 @@ if(Sofa.GL_FOUND) if(SOFA_QT_ENABLE_QGLVIEWER) find_package(QGLViewer QUIET) - if(NOT QGLViewer_FOUND AND SOFA_ALLOW_FETCH_DEPENDENCIES) + if(QGLViewer_FOUND) + # NOTE @olivier-roussel : Don't get why we don't have to force Qt Xml installation on windows + # when QGLViewer is fetched + if(SOFA_BUILD_RELEASE_PACKAGE AND CMAKE_SYSTEM_NAME STREQUAL Windows) + sofa_install_libraries(TARGETS QGLViewer) + if (Qt5Core_FOUND) + sofa_install_libraries(TARGETS Qt5::Xml) + elseif (Qt6Core_FOUND) + sofa_install_libraries(TARGETS Qt::Xml) + endif() + endif() + elseif(NOT QGLViewer_FOUND AND SOFA_ALLOW_FETCH_DEPENDENCIES) message("Sofa.Qt: DEPENDENCY QGLViewer NOT FOUND. SOFA_ALLOW_FETCH_DEPENDENCIES is ON, fetching QGLViewer...") sofa_fetch_dependency(QGLViewer GIT_REPOSITORY https://github.com/sofa-framework/libQGLViewer/ diff --git a/Sofa.QtConfig.cmake.in b/Sofa.QtConfig.cmake.in index dd46d2c..4b755f4 100644 --- a/Sofa.QtConfig.cmake.in +++ b/Sofa.QtConfig.cmake.in @@ -35,6 +35,7 @@ if(SOFA_QT_HAVE_QT5) find_package(Qt5 QUIET REQUIRED WebEngine WebEngineWidgets) endif() if(SOFA_QT_ENABLE_QGLVIEWER) + find_package(Qt5 QUIET REQUIRED Xml) find_package(QGLViewer QUIET REQUIRED) endif() elseif(SOFA_QT_HAVE_QT6) @@ -46,6 +47,7 @@ elseif(SOFA_QT_HAVE_QT6) find_package(Qt6 QUIET REQUIRED Positioning WebChannel WebEngineCore WebEngineWidgets) endif() if(SOFA_QT_ENABLE_QGLVIEWER) + find_package(Qt6 QUIET REQUIRED Xml) find_package(QGLViewer QUIET REQUIRED) endif() endif() diff --git a/cmake/Modules/FindQGLViewer.cmake b/cmake/Modules/FindQGLViewer.cmake deleted file mode 100644 index 3a1e7f9..0000000 --- a/cmake/Modules/FindQGLViewer.cmake +++ /dev/null @@ -1,67 +0,0 @@ -# Find the QGLViewer headers and libraries -# Behavior is to first look for config files. -# If no config files were found, tries to find -# the library by looking at headers / lib file. -# -# Defines: -# QGLViewer_FOUND : True if QGLViewer is found -# -# Provides target QGLViewer. - -find_package(QGLViewer NO_MODULE QUIET) - -if(NOT TARGET QGLViewer) - - if(NOT QGLViewer_INCLUDE_DIR) - find_path(QGLViewer_INCLUDE_DIR - NAMES QGLViewer/qglviewer.h - PATH_SUFFIXES include Headers - ) - endif() - - if(NOT QGLViewer_LIBRARY) - find_library(QGLViewer_LIBRARY - NAMES QGLViewer QGLViewer2 QGLViewer-qt5 QGLViewer-qt6 - PATH_SUFFIXES lib - ) - endif() - - if(QGLViewer_INCLUDE_DIR AND QGLViewer_LIBRARY) - set(QGLViewer_FOUND TRUE) - else() - if(QGLViewer_FIND_REQUIRED) - message(FATAL_ERROR "Cannot find QGLViewer") - endif() - endif() - - # Same checks as Sofa.Qt - # i.e find Qt6, then if not, Qt5, then if not error - find_package(Qt6 COMPONENTS Core CoreTools QUIET) - if (NOT Qt6Core_FOUND) - find_package(Qt5 COMPONENTS Core QUIET) - endif() - - if (Qt5Core_FOUND) - find_package(Qt5 COMPONENTS Core Gui Xml OpenGL Widgets REQUIRED) - set(QT_TARGETS Qt5::Core Qt5::Gui Qt5::Xml Qt5::OpenGL Qt5::Widgets) - elseif (Qt6Core_FOUND) - find_package(Qt6 COMPONENTS Gui GuiTools Widgets WidgetsTools OpenGLWidgets Xml REQUIRED) - set(QT_TARGETS ${QT_TARGETS} Qt::Core Qt::Gui Qt::Widgets Qt::OpenGLWidgets Qt::Xml) - endif() - - if(QGLViewer_FOUND) - set(QGLViewer_LIBRARIES ${QGLViewer_LIBRARY}) - set(QGLViewer_INCLUDE_DIRS ${QGLViewer_INCLUDE_DIR}) - - if(NOT QGLViewer_FIND_QUIETLY) - message(STATUS "Found QGLViewer: ${QGLVIEWER_LIBRARIES}") - endif(NOT QGLViewer_FIND_QUIETLY) - - if(NOT TARGET QGLViewer) - add_library(QGLViewer INTERFACE IMPORTED) - set_property(TARGET QGLViewer PROPERTY INTERFACE_LINK_LIBRARIES "${QGLViewer_LIBRARIES}" ${QT_TARGETS}) - set_property(TARGET QGLViewer PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${QGLViewer_INCLUDE_DIR}") - endif() - endif() - mark_as_advanced(QGLViewer_INCLUDE_DIR QGLViewer_LIBRARY) -endif()