Skip to content

Allow building for Qt5 even if Qt6 was detected. #86

@pasbi

Description

@pasbi

My system provides both Qt5 and Qt6.
Usually I use Qt6, but some projects still require Qt5 (some of which require libQGLViewer, too).

So it seems I wasn't able to build libQGLViewer for Qt5 unless

  • I uninstalled Qt6 from my system (not an option)
  • or made changes to this part of the sources (not nice, I prefer having no local changes for 3rd party source in my environment).
# This will find the Qt files.
find_package(Qt6 COMPONENTS Core Widgets Xml OpenGL OpenGLWidgets)
if (Qt6_FOUND)
    message("Building with Qt6")
    set(QtLibs Qt::Core Qt::Widgets Qt::Xml Qt::OpenGL Qt::OpenGLWidgets)
else()
    find_package(Qt5 5.15 REQUIRED COMPONENTS Core Widgets Xml OpenGL)
    message("Building with Qt5")
    set(QtLibs Qt::Core Qt::Widgets Qt::Xml Qt::OpenGL)
endif()

I guess the intention behind this logic is to "automatically" pick the "right" Qt version without bothering the user.
I suppose libQGLviewer built with Qt6 doesn't work in applications build with Qt5 (if that assumption is wrong, please let me know and close the issue).
Hence, I think it's required to let the user decide explicitly because only the user knows what they're building libQGLViewer for.

One could use -DCMAKE_DISABLE_FIND_PACKAGE_Qt6=On, but that feels more like a hacky workaround and not properly documented.

Feature request: add an option to explicitly chose the Qt to be used for building libQGLViewer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions