Once you build your code using commands such as cmake --build ., you might want to know where to find the build artifacts. By default, CMake will create them in a directory matching the source directory they were defined in. For instance, if you have a src/CMakeLists.txt file with an add_executable directive, then the binary will land in your build directory's src subdirectory by default. We can override this using code such as the following:  Â
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
This way, the binaries and DLL files will land in the bin subdirectory of your project's build directory, while static and shared Linux libraries will be placed in the lib subdirectory.