[CMake] Non-build output

Eric Noulard eric.noulard at gmail.com
Sun Jun 20 16:31:27 EDT 2010


2010/6/20 Clark Gaebel <cg.wowus.cg at gmail.com>:
> How would I go about placing a text file in the same directory as a
> target's output?
>
> For example, let's say I have a target called "foo", which creates an
> executable. "foo" has a config file called "foo.conf" that should always
> go in the same directory. At the moment, it resides in the src/
> directory for the "foo" target. How would I get it to automatically copy
> into the same directory as the foo executable as part of the build process?
>
> For bonus points, how would this interact with "make install"?

Concerning install:

Your target foo may be installed with
install(TARGETS foo DESTINATION where/you/want)

Your config file with
install(FILE foo.conf DESTINATION where/you/want)

Now if you want to put the foo.conf near to foo **in the build tree**
**and assuming foo.conf is in the same source dir as foo sources**
you may do:
configure_file(foo.conf foo.conf COPYONLY)

this should copy foo.conf from source tree to binary tree.
It may be a problem if you usually do in-source build so you may
a) rename foo.conf to foo.conf.in in the source
b) do
   configure_file(foo.conf.in foo.conf COPYONLY)


-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list