View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014929CMakeCMakepublic2014-05-23 06:442014-11-03 08:38
ReporterLars Christensen 
Assigned To 
PrioritylowSeverityminorReproducibilityalways
StatusclosedResolutionnot fixable 
PlatformOSOS Version
Product VersionCMake 2.8.12.2 
Target VersionFixed in Version 
Summary0014929: Dependencies of custom targets are built as part of "Build Solution" in Visual Studio
DescriptionIf a CMakeLists.txt has two add_custom_target()'s where one is a dependency of the other, the dependency gets built every time you "Build Solution" in Visual Studio.

add_custom_target(foo DEPENDS main COMMAND cmd /c echo foo MESSAGE foo)
add_custom_target(bar DEPENDS foo COMMAND cmd /c echo bar MESSAGE bar)

In this case, the 'foo' target is selected for as a project to build every time in the Visual Studio 'Configuration Manager'. 'bar' is NOT selected to build every time, and is only build if built explicitly. If 'bar' is removed from CMakeLists.txt, 'foo' is no longer built every time, and is deselected from Build in the 'Configuration Manager'.

Neither 'foo' nor 'bar' is marked as a dependency of ALL_BUILD (As expected). The problems is in the 'Configuration Manager', which selected which projects are build when you choose 'Build Solution'.

TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0035916)
Nils Gladitz (developer)
2014-05-23 06:53

DEPENDS is used for file dependencies.
Try add_dependencies() for inter-target dependencies.
(0035917)
Lars Christensen (reporter)
2014-05-23 07:07
edited on: 2014-05-23 07:11

Good point - i forgot about this! I tried this:

add_custom_target(foo COMMAND cmd /c echo foo COMMENT "Building foo")
add_custom_target(bar COMMAND cmd /c echo bar COMMENT "Building bar")
add_dependencies(bar foo)

But the problem persist. foo is built every time, bar is not. If I remove add_dependencies(bar foo)", neither foo or bar is built.

Edit: MESSAGE => COMMENT

(0035918)
Brad King (manager)
2014-05-23 08:46

I think this behavior was introduced intentionally here:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b0bc59f70 [^]

One can see it in the modern sources here:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmGlobalVisualStudio7Generator.cxx;hb=v3.0.0-rc6#l976 [^]

IIRC, if foo is not marked for the current configuration then it will be skipped when bar is built even though the dependency is recorded.
(0035921)
Lars Christensen (reporter)
2014-05-23 09:41

Thanks for the rapid response, you guys are awesome. I think you are right. I tried removing the 'Build' flag in the Configuration Manager, so that 'foo' isn't built. When manually building 'bar', 'foo' isn't build either (as Brad expected), even though dependencies are correct in under 'Project Dependencies'.

In my case, I have a rather big InnoSetup build job in the target that was built, which I certainly don't want to build every time. I have worked around the problem by having the two targets depends on a file from an add_custom_command() instead of each other.
(0035922)
Brad King (manager)
2014-05-23 09:52

Okay, thanks for verifying my explanation (and memory). I'm glad you have a workaround. I'll resolve this as not fixable.
(0037140)
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-05-23 06:44 Lars Christensen New Issue
2014-05-23 06:53 Nils Gladitz Note Added: 0035916
2014-05-23 07:07 Lars Christensen Note Added: 0035917
2014-05-23 07:11 Lars Christensen Note Edited: 0035917
2014-05-23 08:46 Brad King Note Added: 0035918
2014-05-23 09:41 Lars Christensen Note Added: 0035921
2014-05-23 09:52 Brad King Note Added: 0035922
2014-05-23 09:52 Brad King Status new => resolved
2014-05-23 09:52 Brad King Resolution open => not fixable
2014-11-03 08:38 Robert Maynard Note Added: 0037140
2014-11-03 08:38 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team