MantisBT - CMake
View Issue Details
0008438CMakeCMakepublic2009-01-29 10:402016-06-10 14:30
Hugo Heden 
Kitware Robot 
normalminorN/A
closedmoved 
CMake-2-6 
 
0008438: add_dependencies() for "build-in cmake targets"
Currently, add_dependencies can not be used to create a dependency if one of the specified targets is a cmake "build-in" target, like "test", "install" or "all".

I would like to be able to specify such dependencies.

Use-case currently at hand: We have a large test-suite for checking the *installed* software, and would thusly like to be able to write

ADD_DEPENDENCIES( TestAllPackagesWhenInstalled INSTALL )


No tags attached.
related to 0006348closed Kitware Robot custom global targets (targets which when built from the root build all targets with the same name in subdirs) 
related to 0012960closed Nils Gladitz CMake should reject targets with reserved names like "test" 
related to 0012961closed Kitware Robot CMAKE_INSTALL_BEHAVIOR and allowing users to run INSTALL under Visual Studio by default 
related to 0013170closed Nils Gladitz add_executable(test) & ENABLE_TESTING 
Issue History
2009-01-29 10:40Hugo HedenNew Issue
2009-01-29 14:27Bill HoffmanStatusnew => assigned
2009-01-29 14:27Bill HoffmanAssigned To => Brad King
2009-01-29 14:35Brad KingNote Added: 0014723
2009-01-29 14:35Brad KingRelationship addedrelated to 0006348
2010-11-18 06:48Hugo HedenNote Added: 0023373
2010-11-18 06:49Hugo HedenNote Edited: 0023373bug_revision_view_page.php?bugnote_id=23373#r8
2010-11-18 06:51Hugo HedenNote Added: 0023374
2011-01-13 07:30Eric NOULARDNote Added: 0024642
2011-01-13 07:56Hugo HedenNote Added: 0024643
2011-04-14 14:27David ColeTarget Version => CMake 2.8.5
2011-05-17 15:53Brad KingNote Added: 0026520
2011-05-17 15:53Brad KingAssigned ToBrad King =>
2011-05-17 15:53Brad KingStatusassigned => backlog
2011-05-25 16:54David ColeNote Added: 0026589
2011-05-25 16:54David ColeTarget VersionCMake 2.8.5 =>
2011-08-12 07:51Tomasz MajchrowskiNote Added: 0027192
2011-08-12 08:59David ColeNote Added: 0027193
2011-08-12 09:00David ColeNote Edited: 0027193bug_revision_view_page.php?bugnote_id=27193#r400
2011-10-24 12:48Eric NOULARDNote Added: 0027638
2011-10-24 12:48Eric NOULARDTarget Version => CMake 2.8.7
2011-11-03 12:03David GenestNote Added: 0027717
2011-11-23 10:34Chris ScharverNote Added: 0027852
2011-12-13 19:21David ColeNote Added: 0027967
2011-12-13 19:21David ColeTarget VersionCMake 2.8.7 =>
2012-01-03 16:21David ColeTarget Version => CMake 2.8.8
2012-01-07 10:03David ColeNote Added: 0028212
2012-02-13 09:48Brad KingRelationship addedrelated to 0012960
2012-02-14 10:40Brad KingRelationship addedrelated to 0012961
2012-04-19 08:40David ColeNote Added: 0029232
2012-04-19 08:40David ColeTarget VersionCMake 2.8.8 =>
2012-04-26 08:15Brad KingRelationship addedrelated to 0013170
2013-02-08 10:19franck.boninNote Added: 0032225
2013-06-14 05:40ycolletNote Added: 0033282
2013-11-05 09:48Bjoern ThielNote Added: 0034392
2013-11-13 14:48Tomasz MajchrowskiNote Added: 0034448
2014-09-06 15:32Jean-Bernard JansenNote Added: 0036736
2014-10-20 05:21Pascal BachNote Added: 0037050
2014-10-20 09:35Brad KingNote Added: 0037055
2014-12-03 09:52Josh KlontzNote Added: 0037368
2015-04-07 12:57Tom HughesNote Added: 0038467
2015-05-29 11:22gonzalobg88@gmail.comNote Added: 0038820
2015-09-28 11:12Benoît BleuzéNote Added: 0039488
2015-10-28 01:30Davy DurhamNote Added: 0039691
2015-11-24 10:31Christopher Sean MorrisonNote Added: 0039907
2015-12-03 02:14arufanovNote Added: 0039940
2016-06-10 14:27Kitware RobotNote Added: 0041496
2016-06-10 14:27Kitware RobotStatusbacklog => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:27Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0014723)
Brad King   
2009-01-29 14:35   
This has been on my todo list for a long time. See issue 0006348, my comment at time 2008-02-14 17:14.
(0023373)
Hugo Heden   
2010-11-18 06:48   
(edited on: 2010-11-18 06:49)
Another use-case is this: Somehow invoke a sub-process, "ant clean", whenever the "clean"-target is executed

http://www.mail-archive.com/cmake@cmake.org/msg11588.html [^]

(0023374)
Hugo Heden   
2010-11-18 06:51   
Brad: I'm not completely sure that issue 0006348 is the same as this one, but I guess I'll take your word for it.
(0024642)
Eric NOULARD   
2011-01-13 07:30   
Just to note that the complete need would be
to be able to

1) add dependency TO builtin target like:
   
   add_dependencies(package MyDoxygenCustomTarget)

   which will enforce the "MyDoxygenCustomTarget" to be called
   whenever the builtin target "package" is built.

2) add dependency FROM builtin target like:
  
   add_dependencies(TestAllPackagesWhenInstalled install)
   
   which will enforce the builtin target "install" to
   be built whenever "TestAllPackagesWhenInstalled" is.
(0024643)
Hugo Heden   
2011-01-13 07:56   
Thanks for noting that Eric, I don't think I had thought about that the _two_ directions of dependencies. You're right.
(0026520)
Brad King   
2011-05-17 15:53   
Moving to backlog. I think the approach mentioned in 0006348:0010505 will work but I have no time to work on this.
(0026589)
David Cole   
2011-05-25 16:54   
Not for 2.8.5 - postponing until a future release
(0027192)
Tomasz Majchrowski   
2011-08-12 07:51   
Is there any chance to fix it for coming 2.8.6 ?
(0027193)
David Cole   
2011-08-12 08:59   
(edited on: 2011-08-12 09:00)
Not really a good chance of fixing this for 2.8.6 unless somebody proposes a reasonable patch that works, has tests associated with it, and does not seem too risky or de-stabilizing.

Brad's note from May 17 still stands: "Moving to backlog. I think the approach mentioned in 0006348:0010505 will work but I have no time to work on this."

It's in the "backlog" and it is assigned to nobody. That typically means it's not being actively pursued by anybody.

(0027638)
Eric NOULARD   
2011-10-24 12:48   
Targeting 2.8.7 because it has been raised on the ML request right after 2.8.6
and because I vote for this too :-]
(0027717)
David Genest   
2011-11-03 12:03   
I would like to add a vote to this feature also. We are using cmake in a very Visual Studio Savy workplace. People here do not want to manually add files to the CMakeLists.

For this reason, we have cmake harvest the source tree at generation, and a script to compare the actual source tree files to know if a regeneration is needed. I know it is not the CMake way, but it has worked very well for us.

If we could add a dependency from ZERO_CHECK to our source tree verification command, the integration would be complete. (When the script detects a change, it touches the top-most CMakeLists.txt). Right now, we depend on our top level dependency, and sometimes the re-generation gets caught too late.
(0027852)
Chris Scharver   
2011-11-23 10:34   
I would like this too, as it would allow us to easily build installers through a custom target depending on INSTALL.
(0027967)
David Cole   
2011-12-13 19:21   
Unset target version field; too late for a fix to go into 2.8.7; deferred until a future version.
(0028212)
David Cole   
2012-01-07 10:03   
Repeating/updating my own note: Not really a good chance of fixing this for 2.8.8 unless somebody proposes a reasonable patch that works, has tests associated with it, and does not seem too risky or de-stabilizing.

For more comments, see:

  0008438:0027193

and

  0006348:0010505
(0029232)
David Cole   
2012-04-19 08:40   
Unsetting target version, removing from roadmap, nobody is working on this.

When somebody begins active development work on this issue, I'll put it back on the roadmap. Until then, it's in the backlog...
(0032225)
franck.bonin   
2013-02-08 10:19   
I would like this.
For me it would enabling signing CPack generated installer with a custom post package target. Let me try this :

IF(WIN32 AND NOT UNIX)
   add_custom_target(signpackage package COMMAND signtool.exe ...)
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   add_custom_target(signpackage package COMMAND productsign ...)
ELSE()
   add_custom_target(signpackage package COMMAND echo no signing)
ENDIF()

add_dependencies(signpackage package)
(0033282)
ycollet   
2013-06-14 05:40   
I just vote for this feature.
(0034392)
Bjoern Thiel   
2013-11-05 09:48   
Me too.
(0034448)
Tomasz Majchrowski   
2013-11-13 14:48   
vote++
(0036736)
Jean-Bernard Jansen   
2014-09-06 15:32   
I would definitely like that feature too.
(0037050)
Pascal Bach   
2014-10-20 05:21   
I'm trying to integrate an Ant build with CMake. And it would be nice if I could just add a custom_command that calls ant install and make it a dependency of the built-in install target. So this would be a great help.
(0037055)
Brad King   
2014-10-20 09:35   
Re 0008438:0037050: That is the opposite direction of this issue, which is about making a custom target depend on a builtin target. Do run extra steps during installation, use the install(SCRIPT) or install(CODE) command.
(0037368)
Josh Klontz   
2014-12-03 09:52   
+1
(0038467)
Tom Hughes   
2015-04-07 12:57   
+1
(0038820)
gonzalobg88@gmail.com   
2015-05-29 11:22   
At the very minimum it should be stated in the documentation that this is not possible.

That is: in every single place in the docs were it says "You can add a target here" it should also say "(but remember there are no target names for all, install, test, ...)".

I just wasted an hour of my life trying to find out how to do this and scratching my head about why ALL or CMAKE_PROJECT_NAME do not work.
(0039488)
Benoît Bleuzé   
2015-09-28 11:12   
As everyone else I would like to show my interest for this topic, as I would like to depend on the "package" target.

The ramifications of this particular issue seem to be to extensive for me to work on a first patch for cmake, but is there anything else I can do to push this issue closer to resolution?
(0039691)
Davy Durham   
2015-10-28 01:30   
+1 for me too.

In the mean time, my issue is that I add_subdirectory(.. EXCLUDE_FROM_ALL) on a CMakeLists.txt which defines many targets, but I only want a couple of them built by default.

So my CMakeLists.txt looks like so...
   ...
   add_subdirectory(many_targets EXCLUDE_FROM_ALL)

   add_custom_target(build_anyway ALL)
   add_dependencies(build_anyway
      wanted_target_12
      wanted_target_32
   )


IMO, it would make perfect since to be able to say something like:
   ...
   add_subdirectory(many_targets EXCLUDE_FROM_ALL)

   add_dependencies(ALL
      wanted_target_12
      wanted_target_32
   )

It's just a slightly smaller bit of code, but also doesn't have the problem of having to make up a unique name for a faux target and is conceptually more straight-forward.
(0039907)
Christopher Sean Morrison   
2015-11-24 10:31   
Ditto, need this. :)
(0039940)
arufanov   
2015-12-03 02:14   
Also need this for sign dll & msi package based on package built-in target.
(0041496)
Kitware Robot   
2016-06-10 14:27   
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.