2

What I want to achieve: A clean build directory generated by CMake for Visual Studio, with build system targets like ALL_BUILD and ZERO_CHECK and additionally created directories like Visual Studio's x64 physically located somewhere else than in the root directory.

What I have tried: As the accepted answer at CMake: How do I change properties on subdirectory project targets? points out, all I have to do is activating the use of folders with the following line.

set_property(GLOBAL PROPERTY USE_FOLDERS TRUE)

The problem: This does only create a folder in the visual studio project structure for CMakePredefinedTargets, not in the physical filesystem. And the x64 directory keeps untouched too!

So what do I have to do?

  • I don't think that this is possible. But if you are looking to separate your created binaries from the other generated files you can use the [`RUNTIME_OUTPUT_DIRECTORY`](https://cmake.org/cmake/help/latest/prop_tgt/RUNTIME_OUTPUT_DIRECTORY.html) property and related target properties to change their location. – Knitschi Oct 05 '19 at 07:03
  • So my messy build directory ... actually is quite common in CMake + Visual Studio? –  Oct 08 '19 at 08:35
  • More or less yes. I assume that you already have the build directory separate from your source tree. Usually the mess in the build-tree does not matter that much, because at least I am usually only interested in the .exe .dll .lib files. You can put these into another location as I described above. If you want to separate the desired build-results from all the other generated files, you can also consider adding install rules and then build the install target to copy all the important files out of your build-tree to a separate location. – Knitschi Oct 09 '19 at 20:21

0 Answers0