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

Cmake generator builds DEBUG version with CMAKE_BUILD_TYPE=Release



  • I am trying to build a project in DEBUG & RELEASE versions. I have set my build settings for cmake generator as follows:

    Annotation 2020-08-25 101817.png

    I have custom INSTALL commands in my CMakeLists.txt file for both Release and Debug versions to pull relevant .dll files. When i generate and build DEBUG type it builds fine. Default path such as path\DEPLOY\bin\Debug is created and projectd.exe inside the Debug folder.

    When i generate for Release mode, it creates a Debug folder exactly like path\DEPLOY\bin\Debug and on building i see, it pulls all the debug versions of .dll and creates a projectd.exe inside the Debug folder.

    To cross check, i built my project with Cmake-GUI and build with VS 2015 everything works fine both in Debug and Release versions. So, nothing wrong with my CMakeLists.txt.

    In my build output i could see this:

    Annotation 2020-08-25 101817.png

    even when my CMAKE_BUILD_TYPE=Release

    It somehow still thinks configuration is set to Debug.

    PS: I recently updated my Qt Creator from 4.2 => 4.12.4 but i still need to use Qt SDK 5.7.1 (not allowed to change this) on Win 10.


  • Lifetime Qt Champion

    This is a problem of msbuild - you have to pass the build configuration to msbuild via '/property:Configuration=Release'



  • @Christian-Ehrlicher and how do i do that? Can i set it in QtCreator? Or do i need to add it in some build step?



  • Understood. I added /property:Configuration=Release in the Tool arguments of release build. Build arguments should look like this cmake.exe --build . --target install -- /property:Configuration=Release.


Log in to reply