On Tue, 2014-12-23 at 16:59 -0500, David Cole wrote:
> Are you sure there's a problem using TARGET_FILE in your original
> context?
> You should be able to use that in a custom command in your custom
> stage_tgt target...
>
> You have to give the name of the target for the TARGET_FILE generator
> expression, so it should work for any target that cmake knows about.
>
> Can you point to a simplified reproducible case where this does not
> work?
>
> Maybe there's some other complication in your real project that is
> making it seem like it's not working.... but I think it should. Can
> you send us any code?
Thanks for the reply David.
The complication is that the rule I'm trying to create that copies files
uses the destination file as the target, so I'm using the target name in
the OUTPUT section of add_custom_command. Basically, my current
implementation is like this:
function(stageobj target dir)
get_property(targetpath TARGET ${target} PROPERTY LOCATION)
get_filename_component(targetname ${targetpath} NAME)
add_custom_command(OUTPUT "${DESTDIR}/${dir}/${targetname}"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DESTDIR}/${dir}"
COMMAND "${CMAKE_COMMAND}" -E copy "${targetpath}" "${DESTDIR}/${dir}"
DEPENDS ${target}
COMMENT "Staging ${target} to ${DESTDIR}/${dir}"
VERBATIM)
add_custom_target("stage_${target}" ALL DEPENDS
"${DESTDIR}/${dir}/${target}")
endfunction()
This has the very nice feature that it's a real rule, and it only fires
if needed (that is, ${target} has been updated since the last time we
copied it).
But, I can't replace "${targetname}" in the OUTPUT section with a
generator expression, because they don't seem to be allowed there:
CMake Error at CMake/Stage.cmake:93 (add_custom_command):
add_custom_command called with OUTPUT containing a "<". This character is
not allowed.
Thoughts or alternatives are welcome...
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake