I have specified my binary output directory with:
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
Unfortunately, Visual Studio adds Debug
and Release
directories.
I do not want these.
The documentation for CMAKE says:
Multi-configuration generators (VS, Xcode) append a per-configuration subdirectory to the specified directory unless a generator expression is used.
But I am not sure exactly what that means.
How can I get Visual Studio to not add those directories?
To directly answer your question: use a generator expression, as the documentation suggests. Here's an example:
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_SOURCE_DIR}/bin>)
$<1:xxx>
is a genex which expands to xxx
, so that means the final value will be what you want it to be.
However, be aware that this means that when building, binaries from the currently built configuration will overwrite those from the previous build, even if that was a different configuration. Are you sure you want that?
As a side note, that path you've specified is relative to the source directory. That sounds really unusual too, and could easily lead to problems. For example, if you generate multiple buildsystems from the same source (into different binary directories), the .exe
files from them all will be stored in the same location, the last one built overwriting any previous ones. That sounds like a solid can of worms and a future maintenance nightmare.
While I do not know the details of your setup, I urge you to reconsider storing build artefacts in the source tree.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With