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

Using CMake (was "fake Qt installation")



  • Hi all -

    I asked about this some time ago, but it never went anywhere. Hopefully some fresh eyes might have an idea.

    I'm trying to use Creator to build a (non-Qt) app for an embedded device (an ESP32 board). I created a new kit, but Creator won't let me use it, saying it's "unsuitable" because there's no Qt version for it (which is true).

    In the docs, it says:

    However, if the device does not have Qt libraries, you need a fake Qt installation.

    But it doesn't elaborate, and I have no idea what a "fake Qt" might be. I've tried a creating dummy qmake.exe file (this is on Windows 10), but Creator is too smart for that; telling me it's not valid.

    Any suggestions on this? I want to use Creator mostly because it's such an outstanding editor and code browser, but I'd like to be able to build with it as well. Eventually, I'll figure out how to debug with it as well, but for now, I'd be very happy if I could get the build working.

    Thanks...


  • Moderators

    You have probably seen it, but some hints are mentioned in an old Mailing List thread. Plus a longer one here.

    Looks like you only need fake Qt when using qmake. Both QBS and cmake should work fine, without a need for fake Qt.



  • Thank you...so, I've tried to set up the project for CMake (a first for me). I get an untitled folder under my project directory. When I open the project, I get this:

    Running "C:\esp32-toolchain\.espressif\tools\cmake\3.13.4\bin\cmake.exe -E server "--pipe=\\.\pipe\{c5f30b1f-ced0-4313-935c-83bd5872c4df}" --experimental" in C:\Users\mzimmers\AppData\Local\Temp\QtCreator-cKHiFU\qtc-cmake-YjObqBra.
    Running "C:\esp32-toolchain\.espressif\tools\cmake\3.13.4\bin\cmake.exe -E server "--pipe=\\.\pipe\{be3679ab-1dcf-4147-8abe-eecb55e086b7}" --experimental" in C:\Users\mzimmers\AppData\Local\Temp\QtCreator-cKHiFU\qtc-cmake-OMdFObmW.
    Running "C:\esp32-toolchain\.espressif\tools\cmake\3.13.4\bin\cmake.exe -E server "--pipe=\\.\pipe\{2df6a5be-e389-4fa0-b0d8-4df8a8ace822}" --experimental" in C:\Users\mzimmers\AppData\Local\Temp\QtCreator-cKHiFU\qtc-cmake-ldSxNodR.
    Running "C:\esp32-toolchain\.espressif\tools\cmake\3.13.4\bin\cmake.exe -E server "--pipe=\\.\pipe\{bddc1a3b-8705-4966-b0dd-dd2cc300714e}" --experimental" in C:\Users\mzimmers\AppData\Local\Temp\QtCreator-cKHiFU\qtc-cmake-VKpGXbrm.
    Parsing of CMake project failed: Connection to CMake server lost.
    Parsing of CMake project failed: Connection to CMake server lost.
    Parsing of CMake project failed: Connection to CMake server lost.
    Parsing of CMake project failed: Connection to CMake server lost.
    

    I'm totally new to this, but when I see words like "--pipe" I think Linux (I'm on Windows 10), and I'm not sure of what to make of "--experimental."

    It would be really cool to get this working, but if it's going to be too much trouble, I'll just give up on it.


  • Moderators

    I think Qt Creator requires newer version of cmake. Currently you can download 3.17 using Qt Online installer.



  • OK, I installed a newer version through the maintenance tool. Now I get this error:

    C:\Qt\Tools\CMake_32\share\cmake-3.17\Modules\CMakeTestCCompiler.cmake:60: error: The C compiler "C:/esp32-toolchain/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: C:/Users/mzimmers/AppData/Local/Temp/QtCreator-gFJIIs/qtc-cmake-PihZJImV/CMakeFiles/CMakeTmp Run Build Command(s):jom /nologo cmTC_69f0c\fast && jom: parallel job execution disabled for Makefile C:\Qt\Tools\QtCreator\bin\jom.exe  -f CMakeFiles\cmTC_69f0c.dir\build.make /nologo -L CMakeFiles\cmTC_69f0c.dir\build Building C object CMakeFiles/cmTC_69f0c.dir/testCCompiler.c.obj C:\esp32-toolchain\tools\xtensa-esp32-elf\esp-2019r2-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe    -o CMakeFiles\cmTC_69f0c.dir\testCCompiler.c.obj   -c C:\Users\mzimmers\AppData\Local\Temp\QtCreator-gFJIIs\qtc-cmake-PihZJImV\CMakeFiles\CMakeTmp\testCCompiler.c Linking C executable cmTC_69f0c.exe C:\Qt\Tools\CMake_32\bin\cmake.exe -E rm -f CMakeFiles\cmTC_69f0c.dir/objects.a C:\Qt\Tools\mingw810_32\bin\ar.exe cr CMakeFiles\cmTC_69f0c.dir/objects.a @CMakeFiles\cmTC_69f0c.dir\objects1.rsp C:\esp32-toolchain\tools\xtensa-esp32-elf\esp-2019r2-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe      -Wl,--whole-archive CMakeFiles\cmTC_69f0c.dir/objects.a -Wl,--no-whole-archive  -o cmTC_69f0c.exe -Wl,--out-implib,libcmTC_69f0c.dll.a -Wl,--major-image-version,0,--minor-image-version,0 c:/esp32-toolchain/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: unrecognized option '--major-image-version' c:/esp32-toolchain/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: use the --help option for usage information collect2.exe: error: ld returned 1 exit status jom: C:\Users\mzimmers\AppData\Local\Temp\QtCreator-gFJIIs\qtc-cmake-PihZJImV\CMakeFiles\CMakeTmp\CMakeFiles\cmTC_69f0c.dir\build.make [cmTC_69f0c.exe] Error 1 jom: C:\Users\mzimmers\AppData\Local\Temp\QtCreator-gFJIIs\qtc-cmake-PihZJImV\CMakeFiles\CMakeTmp\Makefile [cmTC_69f0c\fast] Error 2
    

    I have NO idea what I'm even looking at here. Can you decode this?

    Thanks...


  • Qt Champions 2019

    @mzimmers It tells you that xtensa-esp32-elf-gcc.exe compiler can't compile a simple program. Is this the compiler you want to use?



  • @jsulm yes it is; that's in the toolchain for the ESP-IDF.


  • Qt Champions 2019

    @mzimmers Actually it is not compiler failing, but linker: xtensa-esp32-elf/bin/ld.exe: unrecognized option '--major-image-version'



  • @jsulm I see. So, whereabouts should I look for that option? I don't see it in any of my Creator options.


  • Qt Champions 2019

    @mzimmers I don't know.
    What is actually the compiler version?



  • @jsulm presumably 8.2.0:
    toolchain.PNG



  • I found this which seems to do a pretty good job of describing how to translate a qmake file into a CMake file. But what it doesn't say is how to "tell" Creator that a particular project to use CMake instead of qmake. How do I do that?

    Thanks...


  • Moderators

    You need to close your (qmake) project and then open your new CMakeLists.txt in Qt Creator.



  • Thanks, sierdzio. I also resolved the problem with that TARGET_VERSION_MAJOR -- it turns out that it's just a symbol that the ESP32 toolchain expects to have. I just defined them in my CMakeLists.txt file:

    SET(TARGET_VERSION_MAJOR 0)
    SET(TARGET_VERSION_MINOR 0)
    

    And that eliminated that error.

    So now, how do I inform CMake that my sources are in a directory main under the root-level directory?


  • Moderators

    https://doc.qt.io/qt-5/cmake-get-started.html

    You specify the sources in add_executable call (if you are building an executable).



  • @sierdzio thank you for the link. I understand that there needs to be an entry for every source file somewhere. The CMakeLists.txt file in the main directory has that already. So, what is the correct entry in the CMakeLists.txt file for the top-level (above main/) to tell the build to look in main for these sources? Surely I don't need a SET_SOURCES to re-list those files? So, what's the second argument to add_executable()?

    Thank you.


  • Moderators

    @mzimmers said in Using CMake (was "fake Qt installation"):

    @sierdzio thank you for the link. I understand that there needs to be an entry for every source file somewhere. The CMakeLists.txt file in the main directory has that already. So, what is the correct entry in the CMakeLists.txt file for the top-level (above main/) to tell the build to look in main for these sources?

    include or add_subdirectory, depending on your needs.

    Surely I don't need a SET_SOURCES to re-list those files? So, what's the second argument to add_executable()?

    First argument is the executable name. All subsequent arguments are files which cmake should consider during build.



  • Try QBS instead of CMake and do not suffer (if no any special requirements). In this case you don't need in this hard manipulations (with CMake you need in a custom toolchain file, in a separate Make or Ninja utilities and so on)...

    PS: F.e. I use QBS with ESP8266 && non-os-sdk and all fine. :)


  • Qt Champions 2019

    @kuzulis Isn't QBS dying and CMake will be default in Qt6?



  • QBS is still not dead, it is now being actively developed by the open source community and has a many changes.

    For QBS, it’s not a problem that CMake is the default Qt build system, it still supports in QtCreator. QBS is not only for Qt, but for everything else, especially for a bare metal programming (especially it is a best choose for a DIY projects, because it support a lot of architectures and toolchains).


  • Qt Champions 2019

    @kuzulis OK, didn't know QBS is actively developed





  • @kuzulis thank you for the suggestion. The application I've written makes full use of the ESP IDF, which I believe is exclusively CMake. I don't think converting the entire build system to QBS is the right way to go. I'll continue to plod ahead with the CMake effort, since it appears to be the wave of the future. I do appreciate the suggestion, though.


Log in to reply