[cmake-developers] Adding automatic checks for required targets in target-export files ?

Alexander Neundorf neundorf at kde.org
Mon Feb 11 13:52:55 EST 2013


On Monday 11 February 2013, Stephen Kelly wrote:
> Alexander Neundorf wrote:
> > On Monday 11 February 2013, Brad King wrote:
> >> On 02/10/2013 10:14 AM, Alexander Neundorf wrote:
> >> > 1) either put a check for the required targets in the generated
> >> > targets file, and make find_package() fail by setting foo_FOUND to
> >> > FALSE. This should be relatively straightforward to implement, and
> >> > needs only code in the generated targets file. This is good.
> >> 
> >> I like this approach better than the second one also.
> >> 
> >> > On the downside, this will probably make the cmake
> >> > run fail for (some ?) projects where it currently succeeds, although
> >> > they do not take the dependency order into account when searching
> >> > packages.
> >> 
> >> I think we can add a policy for this.  If not set, warn and use OLD.
> >> If OLD, silently accept the missing targets.  If NEW, error.
> > 
> > So the exported targets file should do something like the following ?
> > 
> > set(failWithError FALSE)
> > cmake_policy(GET CMP00xy POLICY_SET_TO_NEW)
> > if("${POLICY_SET_TO_NEW}" STREQUAL "NEW")
> > 
> >    set(Foo_FOUND FALSE);
> >    set(Foo_NOT_FOUND_MESSAGE "Foo not found because some target is
> >    missing")
> > 
> > else()
> > 
> >    message(STATUS "Foo may not work because some imported target is
> >    
> >                    currently still missing")
> > 
> > endif()
> 
> You may also want to cherry-pick 3c84b519260398adef95a0e08f268e93430ccaf9
> from my clone to get the policy warning in the cmake language.

so I branch away from master, pick the patch you mention, and then merge into 
next, and everything will be fine still for 2.8.11 ?

Alex



More information about the cmake-developers mailing list