How to place all files generated by CMake in a directory

Viewed 30

Although I have been searching for this answer online for quite some time, I could not find a single answer to this question. When i run cmake on a CMakeLists.txt file I have, all the generated files are created next to the project file.

If i add a -B arg, the generated files are created within the specified directory. What is the best way to define that -Bbehavior inside the CMakeLists.txt?

2 Answers

I use that

add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_directory
    ${CMAKE_SOURCE_DIR}/res $<TARGET_FILE_DIR:${PROJECT_NAME}>/res)
Related