I'm trying to get different build subfolder using cmake that has the same name as the current branch (on windows 10). I've tried this
set branch=git rev-parse --abbrev-ref HEAD
cmake --build build\%branch% --config Release
but it doesn't evaluate before usage in cmake, it just dumps it there. This makes the whole approach futile because the following is not a valid cmake command:
cmake --build build\git rev-parse --abbrev-ref HEAD --config Release
Error info:
C:\Users\...\repos\proj_name>cmake --build build\%branch% --config Release
Unknown argument rev-parse
Unknown argument --abbrev-ref
Unknown argument HEAD
Usage: cmake --build <dir> [options] [-- [native-options]]
Is there another way to do this? I'm trying to avoid writing a script - which is the proposed solution linked as duplicate - because I need a oneliner. Switch branch and run the build in such a way that the build folder follows this structure build/branch-name/
. Maybe cmake can do this internally, detect the git branch name and then specify the build folder?