MantisBT - CMake
View Issue Details
0009444CMakeCMakepublic2009-08-21 17:472009-08-24 09:56
K. Noel Belcourt 
Brad King 
normalfeatureN/A
closedfixed 
CMake-2-6 
 
0009444: Ability to detect, report and terminate build if cycles exist
Hi,

Do you have a way to disable support for circular dependencies so if,
theoretically, users wanted to eliminate cycles from their dependencies,
they could enable some internal CMAKE variable to detect, report and
terminate the build if a cycle is detected? This would be a very useful
feature for Sierra. Boost Build does not permit circular dependencies
so with our movement to Cmake, and without this feature, we're likely to
introduce circular dependencies back into our code base. We'd really
like to avoid re-introducing them since we spent a good year working to
eliminate them completely from Sierra's code base and we're much happier
without them.

Any chance for this kind of feature?
No tags attached.
Issue History
2009-08-21 17:47K. Noel BelcourtNew Issue
2009-08-24 09:51Brad KingStatusnew => assigned
2009-08-24 09:51Brad KingAssigned To => Brad King
2009-08-24 09:56Brad KingNote Added: 0017184
2009-08-24 09:56Brad KingStatusassigned => closed
2009-08-24 09:56Brad KingResolutionopen => fixed

Notes
(0017184)
Brad King   
2009-08-24 09:56   
CMake already detects and complains about cycles in the inter-target dependency graph that do not consist completely of STATIC libraries. I've created a new GLOBAL_DEPENDS_NO_CYCLES property which simply enables the error message for cycles even among static libraries:

Create GLOBAL_DEPENDS_NO_CYCLES property
/cvsroot/CMake/CMake/Source/cmComputeTargetDepends.cxx,v <-- Source/cmComputeTargetDepends.cxx
new revision: 1.5; previous revision: 1.4
/cvsroot/CMake/CMake/Source/cmComputeTargetDepends.h,v <-- Source/cmComputeTargetDepends.h
new revision: 1.4; previous revision: 1.3
/cvsroot/CMake/CMake/Source/cmake.cxx,v <-- Source/cmake.cxx
new revision: 1.420; previous revision: 1.419

Add a line like this to your project:

  set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_NO_CYCLES 1)

It will be safely ignored by CMake versions too old to know about the property. CMake 2.7.20090824 and later will complain about cycles.


FYI, there is already a property called GLOBAL_DEPENDS_DEBUG_MODE which will print verbose information about inter-target dependencies. It was meant for debugging the CMake implementation of target dependency analysis, but may be useful for individual users also:

http://www.cmake.org/cmake/help/cmake2.6docs.html#prop_global:GLOBAL_DEPENDS_DEBUG_MODE [^]