Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake import non-compiled files into build directory

Tags:

copy

build

cmake

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?

like image 232
GlinesMome Avatar asked Apr 01 '13 11:04

GlinesMome


Video Answer


2 Answers

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

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.

like image 199
Fraser Avatar answered Oct 20 '22 00:10

Fraser


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

file(COPY "datasets" DESTINATION "${CMAKE_BINARY_DIR}")
like image 42
Johannes Luong Avatar answered Oct 20 '22 00:10

Johannes Luong