jahnf / Projecteur

Linux Desktop Application for the Logitech Spotlight device (and similar devices) - Digital Laser Pointer
MIT License
374 stars 33 forks source link

[BUG] Build with Qt6 seems to fail #219

Open ConiKost opened 8 months ago

ConiKost commented 8 months ago

Description If -DPROJECTEUR_QT_VERSION=6 is being used, to build Projecteur with Qt6, it will fail, as it can't find the needed packages. This seems not be an issue with installed packages, but instead, the checks seems not correct.

Even, that -DPROJECTEUR_QT_VERSION=6 is set to Qt6, you can see, that ist still tries to get Qt5 additional.

    -- Detecting CXX compile features - done
    CMake Error at cmake/modules/Translation.cmake:1 (find_package):
      By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
      asked CMake to find a package configuration file provided by "Qt5", but
      CMake did not find one.

Looking further, in modules/Translation.cmake is a check, which is hardcoded for Qt5 and gets also used, when trying to use Qt6.

find_package(Qt5 REQUIRED COMPONENTS Core)

As a result, more further errors happens:

    -- Found WrapVulkanHeaders: /usr/include
    CMake Error at /usr/lib64/cmake/Qt6Qml/Qt6QmlMacros.cmake:2415 (message):
       qt_generate_foreign_qml_types() is only available in Qt 6.

Looking into the code of Qt6QmlMacros clearly shows:

    if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
        if(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
            function(qt_generate_foreign_qml_types)
                qt6_generate_foreign_qml_types(${ARGV})
            endfunction()
        else()
            message(FATAL_ERROR "qt_generate_foreign_qml_types() is only available in Qt 6.")
        endif()
    endif()

So apparently, the "bad" Qt5 check likely set QT_DEFAULT_MAJOR_VERSION to 5 despite trying to use Qt6.

To Reproduce

Expected behavior Compilation works with Qt6

Desktop/Linux Environment (please complete the following information):

jahnf commented 8 months ago

@ConiKost thank you for reporting I will look into it.