No way to determine build directory in `cmake -C InitialCache.txt -B dir`
In my <initial-cache>
script specified with -C
, I want to set some variables depending on the build path supplied via -B
:
cmake -C foo.txt -S src -B my-build-dir
Problem:
There are no variables that contain my-build-dir
. The obvious variable, $CMAKE_BINARY_DIR
, is set to $PWD
instead of the build directory as I would expect. Later in the configuration process, $CMAKE_BINARY_DIR
is set to my-build-dir
as expected.
I have tried the trick mentioned in here to look at all variables, but none of them contain the directory of interest.
I could make a directory, then cd
there, but I want to take advantage of the fact that -B
creates the directory for you, so the build process can become a single cmake invocation rather than mkdir $x; cd $x; cmake -C ../foo.txt ../src
.