0

I have a CMake solution with ~1.5K C/C++ projects/subdirs and I wanted to use CMake presets. This is my CMakePresets.json:

{
    "version": 3,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 20,
        "patch": 1
    },
    "configurePresets": [
        {
            "name"          : "base"                                ,
            "displayName"   : "Base Config Preset"                  ,
            "description"   : "Base config using VS2019"            ,
            "generator"     : "Visual Studio 16 2019"               ,
            "architecture"  : {"value":"Win32", "strategy":"set"}   ,
            "binaryDir"     : "G:/.bld"                             ,
            "installDir"    : "G:/.dst"
        }
    ],
    "buildPresets": [
        {
            "name"              : "base"                                            ,
            "displayName"       : "Base Build Preset"                               ,
            "description"       : "base build preset"                               ,
            "jobs"              : 0                                                 ,
            "cleanFirst"        : true                                              ,
            "verbose"           : false                                             ,
            "configurePreset"   : "base"
        }
    ]
  }

I observed a significant duration difference (~40%) between the following 2 approaches (both were run in an identical clean context):

  1. Using classic folder syntax to build
cmake --preset=base
cmake --build G:\.bld -j
  1. Using new preset syntax to build
cmake --preset=base
cmake --build --preset=base -j

Both perform similar during CMake config & generate step. The difference appears during build step, after the Microsoft's header is displayed:

Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Approach 1. does not have any delay until it displays the following output lines. Total time is ~14 minutes

Approach 2. has 5-6 minutes delay before showing next lines from output (but the CPU is under load). The Microsoft's header is displayed again then everything continues normally. Total time is ~20 minutes

The duration difference seems to be, more or less, that initial delay, when nothing is displayed

Shouldn't they be identical? Could be a bug in CMake or I do something wrong?

OS: Windows 10 64bit, cmake version 3.21.2

Solo
  • 105
  • 8
  • 2
    I would expect that `"cleanFirst": true` setting in the preset corresponds to additional parameter `--clean-first` for `cmake --build`. Have you tried to run `cmake --build G:\.bld --clean-first -j` for time measurements? – Tsyvarev Nov 19 '21 at 18:26
  • @Tsyvarev: you're right! Without "cleanFirst" in CMakePresets.json there is no delay in the build step. I expected to be nothing to clean because I manually deleted the build dir and the source dir was unchanged in both scenarios... but I misunderstood the meaning of "cleanFirst": it builds a target with all the information necessary to delete generated files after a build (and this generated that initial delay). Please add it as answer, you deserve the points! Thank you! – Solo Nov 21 '21 at 07:10

0 Answers0