I'm currently constructing a project with a plugin structure. I'm using CMake to compile the project. The plugins are compiled in separate directories. My problem is that CMake compiles and saves the binaries and plugins, dynamic libraries, in the directory structure of the source. How do I make CMake save the files in something like a ./bin directory?
C++ – How to make CMake output into a ‘bin’ dir
ccmakeplugins
Related Topic
- Looking for a ‘cmake clean’ command to clear up CMake output
- Difference between CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_LIST_DIR
- C++ – CMake output/build directory
- What use is find_package() when you need to specify CMAKE_MODULE_PATH
- Difference between Cmake, gnu make and manually compiling
- C++ – the idiomatic way in CMAKE to add the -fPIC compiler option
- C++ – How to make cmake output to the “build” directory
Best Answer
As in Oleg's answer, I believe the correct variable to set is CMAKE_RUNTIME_OUTPUT_DIRECTORY. We use the following in our root CMakeLists.txt:
You can also specify the output directories on a per-target basis:
In both cases you can append
_[CONFIG]
to the variable/property name to make the output directory apply to a specific configuration (the standard values for configuration areDEBUG
,RELEASE
,MINSIZEREL
andRELWITHDEBINFO
).