QtCreator 4 and CMake parameters

后端 未结 3 902
旧巷少年郎
旧巷少年郎 2021-02-19 15:08

I used to open a CMake-based C++ project with QtCreator and pass my custom CMake command line parameters when configuring the project. In the recent versions of QtCreator (QtCre

3条回答
  •  面向向阳花
    2021-02-19 15:42

    @Manuel's answer is ideal for me when I have toolkit-specific CMake variables without project-specific variables.

    When you have project-specific CMake variables, the options I have seen/used with recent QtCreator versions (~4+) are:

    From QtCreator

    • Open the project
    • go to Projects (on left) and select Build Settings
    • Under CMake, use the "Add" button to add new settings
    • "Apply Configuration Changes"
    • "Build" menu, "Run CMake"
    • Notes:
      • if your project updates CMake variables (as most do), you may need to "Apply Configuration Changes" again.
      • if you have enabled the feature to automatically run CMake, it may fire off in the background, further confusing things. This can create chicken and egg situations - boo!

    Outside QtCreator

    • Go to the build directory
    • Run CMake with your commands as usual
    • Open QtCreator
    • Open the project
    • Under Projects - Build Settings:
      • Confirm that the "Build directory:" is as expected
      • Confirm that your CMake variables appear in the list of variables

    Sadly, I find both of these profoundly unsatisfying...

提交回复
热议问题