Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Cmake finds cross compiled Qt6 config files but Qt6_FOUND is set to FALSE

Cmake finds cross compiled Qt6 config files but Qt6_FOUND is set to FALSE

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 2 Posters 17.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Harlock21
    wrote on 29 Jun 2022, 14:07 last edited by
    #1

    Hi,
    I am experiencing a very annoying issue with cross compiled qt6 for the raspberry arm64 target.
    Qt6 has been deployed by issuing the following command:

    cmake ../../qt-everywhere-src-6.3.1 -GNinja -DCMAKE_BUILD_TYPE=Release -DINPUT_opengl=es2 -DQT_BUILD_EXAMPLES=OFF -DQT_BUILD_TESTS=OFF -DQT_HOST_PATH=/home/michal/Qt/6.3.1/gcc_64 -DCMAKE_STAGING_PREFIX=/home/michal/rpi/qt6-raspi -DCMAKE_INSTALL_PREFIX=/home/michal/rpi/qt6 -DCMAKE_TOOLCHAIN_FILE=/home/michal/rpi/rpi-toolchain.cmake -DQT_QMAKE_TARGET_MKSPEC=devices/linux-rasp-pi4-v3d-g++ -DQT_FEATURE_xcb=ON -DFEATURE_xcb_xlib=ON -DQT_FEATURE_xlib=ON

    After the installation step I have noticed that the staging dir has been used to store all the lib and binaries (/home/micha/rpi/qt6-raspi) instead of the install prefix: /home/michal/rpi/qt6

    When cmake is trying to find the qt packages within the following CMakeLists.txt:

    cmake_minimum_required(VERSION 3.1)

    project(user_interface LANGUAGES C CXX)

    include(cmake/compilation_flags.cmake)

    if(DEFINED ENV{Qt${QT_VERSION}_DIR})
    SET(Qt6_DIR $ENV{Qt${QT_VERSION}_DIR})
    else()
    message(STATUS "not ok")
    endif()

    find_package(Qt${QT_VERSION} COMPONENTS Core Qml Quick QuickControls2 Test Network REQUIRED)
    #find_package(Qt6 HINTS "$ENV{Qt6_DIR}" COMPONENTS Core Qml Quick QuickControls2 Test Network REQUIRED)

    I get the following errors:

    -- Could NOT find Qt6Core (missing: Qt6Core_DIR)
    -- Could NOT find Qt6Qml (missing: Qt6Qml_DIR)
    -- Could NOT find Qt6Quick (missing: Qt6Quick_DIR)
    -- Could NOT find Qt6QuickControls2 (missing: Qt6QuickControls2_DIR)
    -- Could NOT find Qt6Test (missing: Qt6Test_DIR)
    -- Could NOT find Qt6Network (missing: Qt6Network_DIR)
    CMake Error at CMakeLists.txt:17 (find_package):
    Found package configuration file:

    /home/michal/rpi/qt6-raspi/lib/cmake/Qt6/Qt6Config.cmake
    

    but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
    FOUND. Reason given by package:

    Failed to find Qt component "Core".

    Expected Config file at
    "/home/michal/rpi/qt6-raspi/lib/cmake/Qt6Core/Qt6CoreConfig.cmake" exists

    Failed to find Qt component "Qml".

    Expected Config file at
    "/home/michal/rpi/qt6-raspi/lib/cmake/Qt6Qml/Qt6QmlConfig.cmake" exists

    Failed to find Qt component "Quick".

    Expected Config file at
    "/home/michal/rpi/qt6-raspi/lib/cmake/Qt6Quick/Qt6QuickConfig.cmake" exists

    Failed to find Qt component "QuickControls2".

    Expected Config file at
    "/home/michal/rpi/qt6-raspi/lib/cmake/Qt6QuickControls2/Qt6QuickControls2Config.cmake"
    exists

    Failed to find Qt component "Test".

    Expected Config file at
    "/home/michal/rpi/qt6-raspi/lib/cmake/Qt6Test/Qt6TestConfig.cmake" exists

    Failed to find Qt component "Network".

    Expected Config file at
    "/home/michal/rpi/qt6-raspi/lib/cmake/Qt6Network/Qt6NetworkConfig.cmake"
    exists

    All the config files are correctly settled at the paths written above.
    Is the issue related to this:
    https://cmake.org/cmake/help/latest/variable/CMAKE_STAGING_PREFIX.html
    and if yes how it could be addressed?
    Thanks

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Harlock21
      wrote on 29 Jun 2022, 17:02 last edited by
      #2

      Hi, the same problem also happens if I am going to use host linux qt6 deployed libraries (by updating the Qt6_DIR).
      Is there any special version of the FindQt that should be used?
      Thanks

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Harlock21
        wrote on 29 Jun 2022, 17:45 last edited by Harlock21
        #3

        Using this plain cmake file:

        cmake_minimum_required(VERSION 3.10)

        cmake_policy(SET CMP0084 NEW)

        project(test)

        SET(Qt6_DIR "/home/michal/Qt/6.3.1/gcc_64/lib/cmake/Qt6")

        find_package(Qt6 REQUIRED COMPONENTS Core)

        target_link_libraries(test INTERFACE Qt::Core)

        add_executable(test main.cpp)

        I am seeing the same issue as with the cross-compiled arm64 variant, this is the console output:

        -- The C compiler identification is GNU 10.2.1
        -- The CXX compiler identification is GNU 10.2.1
        -- Detecting C compiler ABI info
        -- Detecting C compiler ABI info - done
        -- Check for working C compiler: /usr/bin/cc - skipped
        -- Detecting C compile features
        -- Detecting C compile features - done
        -- Detecting CXX compiler ABI info
        -- Detecting CXX compiler ABI info - done
        -- Check for working CXX compiler: /usr/bin/c++ - skipped
        -- Detecting CXX compile features
        -- Detecting CXX compile features - done
        -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
        -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
        -- Check if compiler accepts -pthread
        -- Check if compiler accepts -pthread - yes
        -- Found Threads: TRUE
        -- Performing Test HAVE_STDATOMIC
        -- Performing Test HAVE_STDATOMIC - Success
        -- Found WrapAtomic: TRUE
        -- Could NOT find Qt6CoreTools (missing: Qt6CoreTools_DIR)
        CMake Warning at /home/michal/Qt/6.3.1/gcc_64/lib/cmake/Qt6/Qt6Config.cmake:213 (find_package):
        Found package configuration file:

        /home/michal/Qt/6.3.1/gcc_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake
        

        but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
        NOT FOUND. Reason given by package:

        Target "Qt6::Core" was not found.

        Call Stack (most recent call first):
        CMakeLists.txt:23 (find_package)

        CMake Error at CMakeLists.txt:23 (find_package):
        Found package configuration file:

        /home/michal/Qt/6.3.1/gcc_64/lib/cmake/Qt6/Qt6Config.cmake
        

        but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
        FOUND. Reason given by package:

        Failed to find Qt component "Core".

        Expected Config file at
        "/home/michal/Qt/6.3.1/gcc_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake" exists

        Thanks in advance.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          Harlock21
          wrote on 29 Jun 2022, 18:00 last edited by Harlock21
          #4

          There is a specular issue opened here:
          https://forum.qt.io/topic/134586/installed-qt6-to-linux-cmake-target-qt6-core-was-not-found/4
          for such cmake lists:

          cmake_minimum_required(VERSION 3.10)

          cmake_policy(SET CMP0084 NEW)

          project(test)

          find_package(Qt6 REQUIRED COMPONENTS Core)

          target_link_libraries(test INTERFACE Qt::Core)

          add_executable(test main.cpp)

          and by invoking:
          cmake .. -DCMAKE_PREFIX_PATH=/home/michal/Qt/6.3.1/gcc_64/lib/cmake/Qt6

          the problem still persists.
          Thanks.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Croitor Alexandru
            wrote on 13 Jul 2022, 17:46 last edited by
            #5

            Finding Qt just by setting Qt6_DIR currently does not work.
            That is tracked in https://bugreports.qt.io/browse/QTBUG-97615 and will be fixed in a future Qt version, but only for desktop platforms.

            Even with the fix proposed in the bug report above, setting Qt6_DIR will not be enough for cross-compilation.
            You would also need to set QT_HOST_PATH to the host Qt installation and adjust CMAKE_FIND_ROOT_PATH to point the cross-compiled Qt installation.

            Rather than doing all that, I suggest you use Qt's cmake wrapper, which is located in $path_to_installed_qt/bin/qt-cmake.
            That passes a Qt generated toolchain file to CMAKE_TOOLCHAIN_FILE when calling CMake, which adjusts CMAKE_PREFIX_PATH and CMAKE_FIND_ROOT_PATH to ensure projects can find a cross-compiled Qt.

            If you don't want to use the qt-cmake wrapper, you can try using the toolchain file directly, by passing -DCMAKE_TOOLCHAIN_FILE=$path_to_installed_qt/lib/cmake/Qt6/qt.toolchain.cmake

            H 1 Reply Last reply 21 Sept 2022, 13:57
            6
            • C Croitor Alexandru
              13 Jul 2022, 17:46

              Finding Qt just by setting Qt6_DIR currently does not work.
              That is tracked in https://bugreports.qt.io/browse/QTBUG-97615 and will be fixed in a future Qt version, but only for desktop platforms.

              Even with the fix proposed in the bug report above, setting Qt6_DIR will not be enough for cross-compilation.
              You would also need to set QT_HOST_PATH to the host Qt installation and adjust CMAKE_FIND_ROOT_PATH to point the cross-compiled Qt installation.

              Rather than doing all that, I suggest you use Qt's cmake wrapper, which is located in $path_to_installed_qt/bin/qt-cmake.
              That passes a Qt generated toolchain file to CMAKE_TOOLCHAIN_FILE when calling CMake, which adjusts CMAKE_PREFIX_PATH and CMAKE_FIND_ROOT_PATH to ensure projects can find a cross-compiled Qt.

              If you don't want to use the qt-cmake wrapper, you can try using the toolchain file directly, by passing -DCMAKE_TOOLCHAIN_FILE=$path_to_installed_qt/lib/cmake/Qt6/qt.toolchain.cmake

              H Offline
              H Offline
              Harlock21
              wrote on 21 Sept 2022, 13:57 last edited by
              #6

              @Croitor-Alexandru thanks a lot :) I did not reply before (my fault) - when I ve realized that passing the toolchain file in the qt6 install dir had solved the issue.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved