View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014899CMakeCMakepublic2014-04-28 08:222014-11-03 08:38
ReporterKiron 
Assigned ToStephen Kelly 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSWindowsOS Version7
Product VersionCMake 2.8.12.2 
Target VersionCMake 3.1Fixed in VersionCMake 3.1 
Summary0014899: $<TARGET_PROPERTY:prop> with add_custom_target does not work
DescriptionWhen using the $<TARGET_PROPERTY:FOO> generator expression inside an add_custom_target command the following error is produced:

CMake Error at CMakeLists.txt:6 (add_custom_target):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:FOO>

  $<TARGET_PROPERTY:prop> may only be used with targets. It may not be used
  with add_custom_command. Specify the target to read a property from using
  the $<TARGET_PROPERTY:tgt,prop> signature instead.

I would expect that with add_custom_target command the short hand form should work (like error message says already, ... may only be used with targets).
Steps To ReproduceSave this as a CMakeLists.txt and run cmake:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(Foo NONE)

add_custom_target(foo
    COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_PROPERTY:FOO>
)

set_property(TARGET foo PROPERTY FOO "foobar")
Additional InformationProblem exists with cmake version 2.8.12.1, 3.0.20140422-g9f9532, and 3.0.20140424-gb4aa99
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0035802)
Brad King (manager)
2014-04-29 10:46

The wording of the error message is not precise enough. Currently this expression does not work for custom commands at all, even those that are commands in add_custom_target.

I do not think the implicit form $<TARGET_PROPERTY> with no target name makes sense but the expression with an explicit target name as in the example could be made to work. Steve, is there a reason context->HeadTarget is needed when an explicit target name is available? Is that so that the lookup can occur in the right context? Isn't having the current cmMakefile enough?
(0035806)
Stephen Kelly (developer)
2014-04-29 17:08

The long form with the explicit target name does currently work, afaik.
(0035807)
Kiron (reporter)
2014-04-30 04:12

The long form does work indeed. The documentation/error message is confusing, because it says it works only with targets. The add_custom_target command has target it its name. So I expected that the short form work as well.

This is just a minor issue, but I think the error message / documentation should be updated that the short form works with all targets except of targets created by add_custom_target.
(0035961)
Stephen Kelly (developer)
2014-05-28 17:06

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a1d758e9 [^]
(0037150)
Robert Maynard (manager)
2014-11-03 08:38

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2014-04-28 08:22 Kiron New Issue
2014-04-29 10:46 Brad King Note Added: 0035802
2014-04-29 17:08 Stephen Kelly Note Added: 0035806
2014-04-30 04:12 Kiron Note Added: 0035807
2014-04-30 08:34 Brad King Assigned To => Stephen Kelly
2014-04-30 08:34 Brad King Status new => assigned
2014-04-30 08:34 Brad King Target Version => CMake 3.1
2014-05-28 17:06 Stephen Kelly Note Added: 0035961
2014-05-28 17:06 Stephen Kelly Status assigned => resolved
2014-05-28 17:06 Stephen Kelly Fixed in Version => CMake 3.1
2014-05-28 17:06 Stephen Kelly Resolution open => fixed
2014-11-03 08:38 Robert Maynard Note Added: 0037150
2014-11-03 08:38 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team