When we define a CMake presets file in an application folder and try to load a preset from it in the "Add Build configuration" tab created by the nRF Connect Extension for VSCode, the CMake preset macro ${presetName} is not expanded correctly by the extension so the build-dir passed in the West command line becomes invalid
resulting in a build error like this:CMake Error at /home/nicolaslebedenco/foobar/external/zephyr/cmake/modules/kconfig.cmake:327 (message):
File not found:
/home/nicolaslebedenco/foobar/app/example/build//_sysbuild/empty.conf
This is an example of CMake preset (fragment) that I used:
},
}
In which case the VSCode extension invokes West with the wrong build dir like this:
west build --build-dir /home/nicolaslebedenco/foobar/app/example/build/${presetName} /home/nicolaslebedenco/foobar/app/example --pristine --board [email protected]/nrf9160 -- -DCMAKE_BUILD_TYPE=Debug
The expected command line was:
Note CMake DOES create a binary folder literally named `/home/nicolaslebedenco/foobar/app/example/build/${presetName}/` but in Linux, identifiers starting with a $ sign are interpreted as env variables by the shell and ${presetName} not being defined in env expands to empty so invocations passing by a shell end-up with no folder name (hence the double slash) in the build error reported.
The nRF Connect Extension for VSCode should expand all preset macros in accordance to at least the specification provided in the minimum CMake version required by Zephyr which is 3.20. For your convenience, the macros in question are described here: https://cmake.org/cmake/help/v3.21/manual/cmake-presets.7.html#macro-expansion