Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QT 14.2 cmake: Cannot find Qt5Widgets et. al.



  • After building and installing 5.14.2 cmake cannot find basic modules like Qt5Core, Qt5Widgets etc. The reason seems simple enough: cmake ĺooks for e. g., FindQt5Widgets.cmake (or Qt5WidgetsConfig.cmake), but this file is nowhere to find, in sources or in the installed tree.

    Details below. I assume I'm doing something really stupid.

    Any hint, out there?

    --alec

    Build and install:

        $ git clone git://code.qt.io/qt/qt5.git
        $ cd qt5
        $ git checkout v5.14.2
        $ ./init-repository --module-subset essential  --branch
        $ ./configure -xplatform android-clang \
            -opensource -confirm-license  \
            -android-abis arm64-v8a \
            -android-ndk $HOME/lib/android-ndk-r21d \
            -android-sdk $HOME/lib/android_sdk \
            -android-ndk-host linux-x86_64 \
            -extprefix $HOME/lib/android-sysroot/usr/Qt5 \
            -prefix /usr/Qt5 \
            -disable-rpath \
            -nomake tests -nomake examples \
            -no-warnings-are-errors
        $ make -j12
        $ rm -rf $HOME/lib/android-sysroot/usr/Qt5
        $ make install
    

    My test cmake snippet which fails:

    cmake_minimum_required(VERSION 3.10)
    project(Foo)
    
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    set(CMAKE_PREFIX_PATH "/home/al/lib/android-sysroot/usr/Qt5")
    set(Qt5_DIR  "/home/al/lib/android-sysroot/usr/Qt5/lib/cmake/Qt5" 
      CACHE STRING "qt5 config dir containing  Qt5Config.cmake"
    )
    find_package(OpenSSL REQUIRED)
    find_package(Qt5Widgets REQUIRED)
    

    Tried QT5_DIR and and CMAKE_PREFIX_PATH separately as well, same resulti. The output (trimmed), fails on QT5Widgets while OpenSSL is fine (just to compare):

    CMake Error at CMakeLists.txt:8 (find_package):
      By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
      has asked CMake to find a package configuration file provided by
      "Qt5Widgets", but CMake did not find one.
    
      Could not find a package configuration file provided by "Qt5Widgets" with
      any of the following names:
    
        Qt5WidgetsConfig.cmake
        qt5widgets-config.cmake
    

    See above: Any input appreciated...


  • Moderators

    Cmake files are normally under <prefix>/lib/cmake



  • @sierdzio: thanks for input. This is a cross-compilation for android, so the cmake files goes into the local sysroot. I'm on Fedora, and certainly don't want to install these cmake files into the normal system-wide host locations.

    That said, this might be a diversion. The core issue as I understand it is that when doing find_package(Qt5Widgets REQUIRED) cmake looks for Qt5WidgetsConfig.cmake or FindQt5Widgets.cmake, and these files are just not installed anywhere by make install.



  • hm... At a closer look, seems to be about configuration. If I run configure without the cross-compilation flags, just a normal build, the missing cmake files seems to be installed.

    So it boils down to convincing configure to produce the cmake files...

    So: rephrasing my question: Has anyone a clue about what configure requires to include the cmake support? Is it just disabled for cross-compilations?


  • Moderators

    @Alec-Leamas said in QT 14.2 cmake: Cannot find Qt5Widgets et. al.:

    So it boils down to convincing configure to produce the cmake files...

    I think you're right. I've checked the Android build made by Qt Company - it does contain cmake files in lib/cmake, same as desktop builds do. So:

    So: rephrasing my question: Has anyone a clue about what configure requires to include the cmake support? Is it just disabled for cross-compilations?

    It's not disabled if official packages contain it. It must be some configure quirk... unfortunately I don't know what it is, sorry.

    I'll try a manual build on my side and report results (if they will be interesting).


  • Moderators

    I think my NDK is too new, it fails every time I try to compile. :-/ Sorry, that's it from me, I don't have time to try it more. I have compared your configure flags with mine and they look OK.



  • Thanks for your efforts!

    For now, I 'll probably need to hack some FindQtXXX.cmake files myself from scratch. Boring, but shouldn't be that complicated (at least as long as I stay away from the COMPONENTS stuff...)

    EDIT: BTW: I'm using the latest ndk (21), no problems besides the one described her.


  • Moderators

    I think you can just take cmake files from prebuilt Qt, they may need a slight modification to trim the number of ABIs but apart from that they should work I think.



  • @sierdzio It's not as simple as 'cmake files'. In particular, is the FindQt5Widgets.cmake and friends there? I also get a bunch of cmake files, but many important ones like this is missing.

    Anyway, I have hacked a FindQt5.cmake script and moved on. It's kind of simple, but does the job.

    If anyone is curious it's here for a while: https://pastebin.com/Tz0hTBTn



  • If anyone is curious it's here for a while: https://pastebin.com/Tz0hTBTn


  • Moderators

    @Alec-Leamas said in QT 14.2 cmake: Cannot find Qt5Widgets et. al.:

    @sierdzio It's not as simple as 'cmake files'. In particular, is the FindQt5Widgets.cmake and friends there?

    You're right, FindQt5x.cmake are not there. But, even without them, cmake works fine with prebuilt Qt - so perhaps these files are not needed at all?



  • @sierdzio I was too quick, it's about other files. Here is the situation, comparing the "normal" installation with a cross-compile, focusing on the Widgets stuff :

    $ find /opt/dont-use-qt5/ -name \*.cmake | grep Widgets
    /opt/dont-use-qt5/lib/cmake/Qt5Widgets/Qt5WidgetsMacros.cmake
    /opt/dont-use-qt5/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake
    /opt/dont-use-qt5/lib/cmake/Qt5Widgets/Qt5WidgetsConfigVersion.cmake
    /opt/dont-use-qt5/lib/cmake/Qt5Widgets/Qt5WidgetsConfigExtras.cmake
    /opt/dont-use-qt5/lib/cmake/Qt5QuickWidgets/Qt5QuickWidgetsConfig.cmake
    /opt/dont-use-qt5/lib/cmake/Qt5QuickWidgets/Qt5QuickWidgetsConfigVersion.cmake
    /opt/dont-use-qt5/lib/cmake/Qt5MultimediaWidgets/Qt5MultimediaWidgetsConfigVersion.cmake
    /opt/dont-use-qt5/lib/cmake/Qt5MultimediaWidgets/Qt5MultimediaWidgetsConfig.cmake
    
    
    $ find -L ~/lib/android-sysroot/usr/Qt5/  -name \*.cmake | grep Widgets
    $
    

    i. e., the Widgets stuff is just missing. Situation is similar for other modules

    Since I basically trust the qt devs, I assume it's because my usecase isn't supported. This means that I cannot use future versions without checking them.

    Ergo: better use my own stuff...


Log in to reply