On 21.08.2014 22:27, Braden McDaniel wrote:
I have the following code that executes in a top-level CMakeLists.txt
*after* having recursed into subdirectories:
get_target_property(TARGET_NAME ${EXPORT_TARGET} NAME)
message(STATUS "${EXPORT_TARGET} NAME = ${TARGET_NAME}")
add_custom_command(
TARGET ${EXPORT_TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_FILE> >
${CMAKE_BINARY_DIR}/${LIB_PATHS}/${EXPORT_TARGET}_$<CONFIG>
)
EXPORT_TARGET is a library target defined in a subdirectory. This
results in the following output from CMake:
my_target NAME = my_target
CMake Warning (dev) at CMakeLists.txt:965 (add_custom_command):
Policy CMP0040 is not set: The target in the TARGET signature of
add_custom_command() must exist. Run "cmake --help-policy CMP0040" for
policy details. Use the cmake_policy command to set the policy and
suppress this warning.
The target name "my_target" is unknown in this context.
How come get_target_property knows about the target but
add_custom_command does not?
I am using CMake 3.0.1.
Custom commands can only be attached to targets defined in the current
directory.
Nils
--
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