"--config" not recognized (quoting issue)
I have a Windows batch script containing this:
SET CMAKE_BIN_DIR=%programfiles%\CMake\bin
"%CMAKE_BIN_DIR%"\cmake.exe --build . --config Release
And this mysteriously fails with the error "CMake Error: Unknown argument --config". When I type the same line into the command prompt with the variables expanded, it actually works as it should.
While trying to get a minimal testcase, I discovered that the error can also be triggered in the command prompt directly. It turns out that the position of the second quote character is significant:
So this works:
"C:\Program Files\CMake\bin\cmake.exe" --build . --config Release
...but this does not:
"C:\Program Files"\CMake\bin\cmake.exe --build . --config Release
After that discovery I was able to fix my batch script by moving everything inside the quotes. The following works correctly:
SET CMAKE_BIN_DIR=%programfiles%\CMake\bin
"%CMAKE_BIN_DIR%\cmake.exe" --build . --config Release
But I am wondering if this could be a bug in how CMake processes command-line arguments. Especially because my batch script also has another CMake line for doing the configure/generate step in the build process, and that line always worked perfectly, even with the second quote in the 'wrong'(?) place.