MantisBT - CMake
View Issue Details
0014771CMakeCMakepublic2014-02-25 09:502016-06-10 14:31
Brad King 
Kitware Robot 
normalminoralways
closedmoved 
 
 
0014771: Ninja generator does not always honor SYMBOLIC rules with no command
The SYMBOLIC source file property is a mark typically used on a custom command output to say that the file will never actually exist. This can be used to create always-out-of-date rules that run on every build.

When a custom command has no actual command line and a symbolic output the Ninja generator implements this by creating a phony build rule. However, the Ninja documentation states:

 "If a phony build statement is written without any dependencies,
  the target will be considered out of date if it does not exist."

If there are order-only dependencies then Ninja does not consider a phony target to be out of date.
$ cat ../CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(OrderedBuildAlways NONE)
add_custom_target(first)
add_custom_command(
  OUTPUT never-created
  COMMAND
  VERBATIM
  )
add_custom_command(
  OUTPUT always-printed
  COMMAND ${CMAKE_COMMAND} -E echo "always printed"
  COMMAND ${CMAKE_COMMAND} -E touch always-printed
  DEPENDS never-created
  VERBATIM
  )
set_property(SOURCE never-created PROPERTY SYMBOLIC 1)
add_custom_target(drive ALL DEPENDS always-printed)
add_dependencies(drive first)

$ cmake .. -G Ninja
$ ninja
[1/1] Generating always-printed
always printed
$ ninja
ninja: no work to do.
No tags attached.
related to 0014728closed Ben Boeckel [CMake/Ninja] add_dependencies() to objlib's user is ignored. 
related to 0014747closed  Target dependencies do not trigget build on Ninja 
related to 0014963closed Brad King Add explicit specification of custom command side effect outputs 
Issue History
2014-02-25 09:50Brad KingNew Issue
2014-02-25 09:50Brad KingRelationship addedrelated to 0014728
2014-02-25 09:50Brad KingRelationship addedrelated to 0014747
2014-02-25 09:52Brad KingNote Added: 0035191
2014-02-25 09:54Brad KingNote Added: 0035192
2014-02-25 09:56Brad KingNote Deleted: 0035191
2014-06-11 08:35Brad KingRelationship addedrelated to 0014963
2014-07-01 09:28Brad KingStatusnew => backlog
2016-06-10 14:29Kitware RobotNote Added: 0042493
2016-06-10 14:29Kitware RobotStatusbacklog => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0035192)
Brad King   
2014-02-25 09:54   
The build.ninja file generated for the example contains

 build never-created: phony || first

and the order-only dependency on "first" prevents this from being considered always out of date. However, we need to preserve the order-only dependency too. We could fix this by creating a single target

 build cmake-ninja-always-out-of-date: phony

and then update our other phony (SYMBOLIC) rules to be

 build never-created: phony | cmake-ninja-always-out-of-date || first
(0042493)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.