Feature Request: Set <build-tool-options> programmatically
Background: https://discourse.cmake.org/t/how-to-set-build-tool-options-via-cmakelists-txt/6925
It is possible to pass arguments to the underlying build-tool via
cmake --build --preset <preset> [<options>] [-- <build-tool-options>]
For example, with ninja
you can run
cmake --build --preset my_favorite_preset -- -d explain
which forwards -d explain
as arguments to ninja
.
It would be handy if a variable BUILD_TOOL_OPTIONS="-d explain"
could be set in cache, so that calling
cmake --build --preset my_favorite_preset
is effectively the same as calling
cmake --build --preset my_favorite_preset -- -d explain
This would be allow for controlling build-tool arguments via cmake-options. In my particular case, having an custom option NINJA_EXPLAIN
that controls whether or not -d explain
is written to cached variable BUILD_TOOL_OPTIONS
would be very helpful when debugging why some .cpp
-files are rebuilt, since I would just be able to tick this option and then build from within Visual Studio via my presets.
if BUILD_TOOL_OPTIONS="-d explain"
is set in cache and some user invokes this:
cmake --build --preset my_favorite_preset -- <something else>
then I think the consistent & expected behavior is that the cached variable is ignored and whatever passed to ninja
via command-line takes priority.