[CMake] Help with Policy CMP0026 (disallow LOCATION target property)

Paul Smith paul at mad-scientist.net
Tue Dec 23 16:06:44 EST 2014


Hi all.  I need a pointer or two.

In my environment I need to have my executables and binaries copied to
another location; this has to happen as part of the default "all"
target: it can't be required to run "install" for example (we use the
"install" rule for a "real" install step, for one thing).

What I was doing with 2.8.12 was creating a custom target "stage_<foo>"
with a prerequisite of target <foo>, which had a custom command that
copied <foo>.  To do this I need to run get_property(pth TARGET <foo>
PROPERTY LOCATION) so I know where the target file is living, and then I
use "cmake -E copy ${pth} ${DESTDIR}" to copy it to the right place.

In 3.x this use is deprecated and I wonder what to do instead.

If I add a POST_BUILD custom command directly to target <foo> which
copies the file then I can use $<TARGET_FILE:<foo>> in my COMMAND script
and that works...

Except, if someone deletes the copy of the file without touching
anything else, it doesn't get recopied (because cmake doesn't know about
the copy and so doesn't realize something is wrong).

I need this to be recopied because we have a habit of just deleting the
entire destination directory and re-running the build to make a fresh
copy without changing anything else.

I've thought about many ways to do this, but I can't seem to get around
the fact that generator expressions like $<TARGET_FILE...> are only
available within the commands of the target.

Help?
Thx!



More information about the CMake mailing list