MantisBT - CMake
View Issue Details
0014728CMakeCMakepublic2014-02-02 23:132015-01-05 08:39
NAKAMURA Takumi 
Ben Boeckel 
normalminoralways
closedfixed 
CMake 2.8.12.1 
CMake 3.1CMake 3.1 
0014728: [CMake/Ninja] add_dependencies() to objlib's user is ignored.
See the case below.
foobar doesn't depend on cmd2 with -GNinja.

It seems works with Unix Makefiles.
cmake_minimum_required(VERSION 2.8)

add_custom_target(cmd1 COMMAND echo cmd1)
add_custom_target(cmd2 COMMAND echo cmd2)

add_library(obj.foobar OBJECT foobar.c)
add_executable(foobar $<TARGET_OBJECTS:obj.foobar>)

add_dependencies(obj.foobar cmd1)
add_dependencies(foobar cmd2) # ignored.
No tags attached.
related to 0014747closed  Target dependencies do not trigget build on Ninja 
related to 0014771closed Kitware Robot Ninja generator does not always honor SYMBOLIC rules with no command 
Issue History
2014-02-02 23:13NAKAMURA TakumiNew Issue
2014-02-03 13:54Brad KingAssigned To => Peter Kuemmel
2014-02-03 13:54Brad KingStatusnew => assigned
2014-02-03 13:55Brad KingNote Added: 0035026
2014-02-10 13:40Brad KingRelationship addedrelated to 0014747
2014-02-25 09:50Brad KingRelationship addedrelated to 0014771
2014-04-13 05:44Peter KuemmelAssigned ToPeter Kuemmel =>
2014-04-13 05:47Peter KuemmelStatusassigned => confirmed
2014-05-05 18:28Ben BoeckelAssigned To => Ben Boeckel
2014-05-05 18:28Ben BoeckelStatusconfirmed => assigned
2014-05-05 18:28Ben BoeckelNote Added: 0035820
2014-07-01 10:17Brad KingNote Added: 0036298
2014-07-01 10:17Brad KingTarget Version => CMake 3.1
2014-07-02 09:53Brad KingStatusassigned => resolved
2014-07-02 09:53Brad KingResolutionopen => fixed
2014-07-02 09:53Brad KingFixed in Version => CMake 3.1
2015-01-05 08:39Robert MaynardNote Added: 0037581
2015-01-05 08:39Robert MaynardStatusresolved => closed

Notes
(0035026)
Brad King   
2014-02-03 13:55   
It looks like the inter-target dependency is implemented by adding an order-only dependency of every source compilation rule in the dependent target on the dependency. Since 'foobar' does not have any source files to compile no place every gets the dependency attached.

Peter, I think the link command needs to get the order-only dependencies too.
(0035820)
Ben Boeckel   
2014-05-05 18:28   
I've pushed a branch to stage which should address this: dev/ninja-target-dependencies.
(0036298)
Brad King   
2014-07-01 10:17   
I've revised Ben's change and merged for testing:

 Ninja: Add order-only dependencies to link commands
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ac8879ce [^]
(0037581)
Robert Maynard   
2015-01-05 08:39   
Closing resolved issues that have not been updated in more than 4 months