[CMake] How to resolve conflicts between custom and imported targets?

Benedikt Hegner benedikt.hegner at cern.ch
Wed Nov 24 06:17:00 EST 2010


Hello,

I am facing a problem here on conflicts between imported targets and  
custom targets. Basically I want to override an imported target by a  
custom target of the same name. A solution like avoiding clashes  
using NAMESPACE on EXPORT doesn't really work for me as the identical  
naming is more or less intended (*). Still I've been doing some  
gymnastics with using NAMESPACE and then 'importing' single targets  
over into the local 'namespace' . That resulted in a lot of fragile  
parsing-like code and just didn't work...

So I ended up looking into the source code of cmake to see what's  
going on under the hood. And a new policy like  
ALLOW_OVERRIDE_IMPORT_TARGETS in cmMakefile would come handy  
(wouldn't be too different from ALLOW_DUPLICATE_CUSTOM_TARGETS I  
think). Giving it a quick shot it worked like a charm.

Nevertheless I would hope to find a solution using already existing  
functionality. Maybe you have an idea what to do instead.

Thanks,
   Benedikt


(*)
The use case is the following: we have a few hundred particle  
physicists working on a software project with a few MLOC. To  
facilitate the development we provide a hybrid environment - there is  
one central installation with a fully built and installed release.  
And then every user can set up a development area, check out newer  
package-versions from the repository, which override the ones in the  
central area, and do his development. At the moment this is handled  
by a custom build tool which we plan to replace by cmake. For cmake  
my current approach is having the central area as one project that  
exports all its targets. And the development area as another project  
importing these.



More information about the CMake mailing list