GlinesMome
GlinesMome

Reputation: 1629

CMake import non-compiled files into build directory

I use CMake like that:

$ mkdir build && cd build
$ cmake .. && make && atf-run | atf-report

But to run atf I need some files (for example /Atffile and test/Atffile), so I'm looking for a way to import in my build directory all that kind file.

I tried this:

file(COPY ${PROJECT_SOURCE_DIR}/.. DESTINATION ${PROJECT_SOURCE_DIR}/..)

But it doesn't work. Is their a simple/cleaner way to do it?

Upvotes: 17

Views: 8589

Answers (2)

Fraser
Fraser

Reputation: 78280

Assuming "/Atffile" and "/test/Atffile" are files and not folders, you can use [configure_file][1]

configure_file(Atffile Atffile COPYONLY)
configure_file(test/Atffile test/Atffile COPYONLY)

Since the commands here use relative paths throughout, the input arg is relative to the current source directory and the output arg is relative to the current binary (i.e. build) directory.

[1]: https://cmake.org/cmake/help/latest/command/configure_file.html "CMake documentation for "configure_file" command"

Upvotes: 28

Johannes Luong
Johannes Luong

Reputation: 584

I use the following to copy a complete directory into the build directory

file(COPY "datasets" DESTINATION "${CMAKE_BINARY_DIR}")

Upvotes: 2

Related Questions