Reputation: 400
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 -B
behavior inside the CMakeLists.txt?
Upvotes: -1
Views: 93
Reputation: 1
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)
Upvotes: 0
Reputation: 19826
You don't define it inside CMakeLists.txt and in fact you cannot because it is already determined before CMake code starts running.
The usual way to save preferred configure command line options is via presets: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
Upvotes: 2