MantisBT - CMake
View Issue Details
0015434CMakeCMakepublic2015-03-06 10:382015-11-02 09:13
Ben Boeckel 
Nils Gladitz 
normalminorhave not tried
closedfixed 
CMake 3.2 
CMake 3.3 
0015434: Multiple add_custom_command with the same MAIN_DEPENDENCY causes duplicate rule invokations
Latest report: https://bugzilla.redhat.com/show_bug.cgi?id=1199360 [^]

AFAIK, I've only heard of this with the Unix Makefiles generator. Minimal test case wanted.
No tags attached.
related to 0014550closed James Bigler FindCUDA: source files shared between multiple targets results in linker using objects from both targets 
Issue History
2015-03-06 10:38Ben BoeckelNew Issue
2015-03-06 10:46Nils GladitzNote Added: 0038160
2015-03-06 11:41Ben BoeckelNote Added: 0038162
2015-03-06 11:42Ben BoeckelNote Added: 0038163
2015-03-06 11:46Brad KingNote Added: 0038164
2015-03-06 11:47Nils GladitzRelationship addedrelated to 0014550
2015-03-06 11:50Nils GladitzNote Added: 0038165
2015-03-06 11:53Brad KingNote Added: 0038166
2015-03-09 07:14Nils GladitzNote Added: 0038180
2015-03-27 09:39Nils GladitzNote Added: 0038349
2015-03-27 09:39Nils GladitzStatusnew => resolved
2015-03-27 09:39Nils GladitzFixed in Version => CMake 3.3
2015-03-27 09:39Nils GladitzResolutionopen => fixed
2015-03-27 09:39Nils GladitzAssigned To => Nils Gladitz
2015-11-02 09:13Robert MaynardNote Added: 0039749
2015-11-02 09:13Robert MaynardStatusresolved => closed

Notes
(0038160)
Nils Gladitz   
2015-03-06 10:46   
Could the linked issue be related to http://public.kitware.com/pipermail/cmake-developers/2015-March/024634.html [^] instead?

I see multiple outputs.
(0038162)
Ben Boeckel   
2015-03-06 11:41   
Possibly. The case I heard about previously (I asked him to report here) had something along the lines of:

add_custom_command(OUTPUT a MAIN_DEPENDENCY dep ...)
add_custom_command(OUTPUT b MAIN_DEPENDENCY dep ...)
add_custom_target(tgt-a DEPENDS a)
add_custom_target(tgt-b DEPENDS b)

which, apparently, added some sort of dependency between a and b due to MAIN_DEPENDENCY.
(0038163)
Ben Boeckel   
2015-03-06 11:42   
That report was also in November probably with a release version of CMake (likely 3.0).
(0038164)
Brad King   
2015-03-06 11:46   
The add_custom_command documentation says that a given MAIN_DEPENDENCY can be used for at most one command:

 http://www.cmake.org/cmake/help/v3.2/command/add_custom_command.html [^]
(0038165)
Nils Gladitz   
2015-03-06 11:50   
I also had issues with MAIN_DEPENDENCY itself before (I linked 0014550) and the consensus was that FindCUDA.cmake might diagnose this.

Could CMake itself perhaps diagnose this instead?
E.g. new policy that makes it a fatal error when two commands reference the same MAIN_DEPENDENCY?
(0038166)
Brad King   
2015-03-06 11:53   
Re 0015434:0038165: Yes, having CMake diagnose it would be good. Make it a policy so that it warns now and can be an error later.
(0038180)
Nils Gladitz   
2015-03-09 07:14   
I pushed the "main_dependency_diagnostic" topic for review and merged it to next for testing.
(0038349)
Nils Gladitz   
2015-03-27 09:39   
Reusing the same MAIN_DEPENDENCY is now diagnosed by:

http://www.cmake.org/gitweb?p=cmake.git;a=commit;h=242c396656783b1b3d542b14bc62710a46a87518 [^]
(0039749)
Robert Maynard   
2015-11-02 09:13   
Closing resolved issues that have not been updated in more than 4 months.