0

I wanna using configure_file(<input> <output> COPYONLY) to copy a specific directory files recursive , I used this command:

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/res/* ${CMAKE_CURRENT_BINARY_DIR}/res COPYONLY)

but I got some errors , How I should use this command for this porpuse? (I looked at this question too), the Errors:

CMake Error at CMakeLists.txt:86 (configure_file): configure_file Problem configuring file

I know that I can use it with file(...) too , but I wanna use configure_file(...):

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/res/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/res)
3
  • From the cmake documentation of configure_file (emphasis mine): "Copies an <input> file to an <output> file .." Commented Apr 9, 2022 at 11:39
  • 1
    "I wanna use configure_file(...)" - Then you need to use it for every separate file. You could obtain list of files using file(GLOB) and iterate over this list with foreach. Commented Apr 9, 2022 at 11:39
  • There's execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/res" "${CMAKE_CURRENT_BINARY_DIR}/res") which does seem to achieve what you seem to attempt here btw... Commented Apr 9, 2022 at 11:41

1 Answer 1

2

I don't think it is possible to use configure_file to copy a folder directly. The command is about

copy a file to another location and modify its contents.

It operates on one file only. https://cmake.org/cmake/help/latest/command/configure_file.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.