Qt World Summit: Submit your Presentation


QT Creator cannot set cmake parameters



  • I have a bigger project which is managed by cmake. There are libraries (internal and imported etc.)

    To run cmake properly, a number of arguments/defines need to be given.

    For example a direct CMake run without parameters will always fail, because I need to select an OS and architecture.
    I can load the project with QT Creator and give the needed parameters, but they don't seem to apply.

    On the command line, this works fine with:

    john@doe:~/MY_PROJECT/build/arm64$cmake -DCMAKE_BUILD_TYPE=debug -DMY_PROJECT_OS=linux -DMY_PROJECT_ARCHITECTURE=arm64 ../..
    -- Adding directory: (...)
    -- Adding library: (...)
    (...)
    -- Configuring done
    -- Generating done
    -- Build files have been written to: (...)
    (...)
    john@doe:~/MY_PROJECT/build/arm64$make -j
    [  1%] Built target (...)
    (...)
    [100%] Built target MY_PROJECT
    

    In QT Creator I hit "File -> Open File or Project" and navigate to my main CMakeLists.txt.
    In "Configure Project" i select the Desktop kit with checked "Debug" and "Release" boxes.
    In the label beneath I set a path like
    "~/MY_PROJECT/build/debug"

    I then go with CTRL+5 to "Projects"
    There it directly gives me a yellow "!" and "The project was not parsed successfully."

    I proceed to add my arguments, like clicking "Add->String" and set all my arguments like that:

    KEY                          VALUE
    MY_PROJECT_OS                linux
    MY_PROJECT_ARCHITECTURE      arm64
    

    Clicking "Apply Configuration Changes" makes some bar appear in the bot right. It is too fast to read the text, but it is coloured in red.
    The Tab "1 Issues (1)" tells me "CMake process exited with exit code 1"
    The Tab "6 General Messages" tells me

    Running /usr/bin/cmake -S /home/john/MY_PROJECT -B /home/john/MY_PROJECT/build/debug in /home/john/MY_PROJECT/build/debug.
    CMake Error at CMakeLists.txt:20 (message):
      MY_PROJECT_OS not set!
    -- Configuring incomplete, errors occurred!
    CMake process exited with exit code 1.
    Elapsed time: 00:00.
    

    I repeated this multiple times, also with not clicking the "Apply Configuration Changes" button. Clearing all CMakeCache.txt, CMakeLists.txt.user* and CMakeFiles folder and repeating this did not help.
    Outcome is still the same - it looks like it does simply not give the parameters.

    I started Qt Creator from command line and this output occurs repeatedly:

    "Invalid codemodel file generated by CMake."
    SOFT ASSERT: "!task.description().isEmpty()" in file /build/qtcreator-sxgQ2x/qtcreator-4.13.1/src/plugins/projectexplorer/taskhub.cpp, line 155
    QFSFileEngine::open: No file name specified
    QIODevice::read (QFile, ""): device not open
    QFSFileEngine::open: No file name specified
    

    I am on Ubuntu 20.04 and have QT Creator 4.13.1 from the snap store.
    My Kit is more or less standard - did not change or set up anything (it still is labelled "Manual").
    It uses Qt 5.12.8 and system Cmake from /usr/bin/cmake (3.16.3)

    Can you guys help me set parameters for CMake?


  • Moderators

    Try adding your args to "Initial CMake parameters" line edit, it's just above the config list you are modifying in Qt Creator UI.



  • @sierdzio I have added my parameters in the above config like

    -DMY_PROJECT_OS:STRING=linux
    -DMY_PROJECT_ARCHITECTURE:STRING=arm64
    

    But output is exactly the same.
    I double checked spelling and copied every variable name


  • Moderators

    That's very weird! Try removing the build directory completely, then check build settings and re-run CMake in Qt Creator.

    If that fails, please report it on Qt bug tracker.



  • @sierdzio Thanks for your answer.
    I have closed QT-Creator. Deleted the debug and release directories in ~/MY_PROJECT/build and reopened QT-Creator.
    The variables set like above are still in the "Initial CMake parameters", however, the type changed from STRING to INTERNAL.

    If I run "Build -> Rescan Project" or "Build -> Run CMake" it both fails with telling me, I did not set the parameters.

    I will open a bug report
    Edit: It is here https://bugreports.qt.io/browse/QTCREATORBUG-24796


Log in to reply