Skip to content

binary build dir in CMakePresets.json #106

@davidhunter22

Description

@davidhunter22

Currently the CMakePresets.json contains the following

    {
      "name": "ci-build",
      "binaryDir": "${sourceDir}/build",
      "hidden": true
    },

The binaryDir here forces the build to go into the directory build in the source tree. I think this is a very bad idea.
Maybe for CI builds this is OK as you may spin up a totally new environment for every build but if you are building local copies
they can clash. For instance you use WSL and want to build a GCC and a VS build using the same source tree. This is how I ran
into this.

It is noticeable that in BUILDING.md all the examples contain the -B flag

cmake -B build --preset=test-msvc

So the -B is used to override the binaryDir in the CMakePresets.json.
I suspect the binaryDir in the CMakePresets.json is there because it used to be a required field.
I would suggest removing the binaryDir which means by default the build tree goes into the directory where you are running cmake which is what most people probably expect. You can always still override this on the command line using -B.

An alternative would be to add CMakePresets.json items for command line builders that don't inherit ci-build. The downside of this is that they might drift apart, say by flags, from the ci-* presets which are used by CI build.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions