[CMake] recommended way to disable a package ?

Alexander Neundorf a.neundorf-work at gmx.net
Mon Jan 30 02:31:31 EST 2006


Hi, 
 
> Von: Filipe Sousa <filipe at ipb.pt> 
... 
> > is used with FIND_PACKAGE(AGG).  
> > But let's say the user doesn't want libagg support althoug it is  
> > installed.  
> > cmake . -DAGG_FOUND:BOOL=FALSE  
> > doesn't seem to work, since AGG_FOUND is no cache variable. Can it be  
> > turned into a cache variable ?  
> > If not, currently the user could start ccmake and set AGG_INCLUDE_DIR  
> > empty, this would make AGG_FOUND false during cmake time. But the 
> > usual user won't know that setting AGG_INCLUDE_DIR will make 
> > AGG_FOUND false.  
> >   
> > So, should this be wrapped into an OPTION() or is there another way ?  
> >   
> > Bye  
> > Alex  
>  
> If the user don't want AGG feature in his project then I think the 
> OPTION is the write way 
>  
> FIND_PACKAGE(AGG) 
> IF(AGG_FOUND) 
>   OPTION(USE_AGG "AGG Support" ON) 
>   IF(USE_AGG) 
>     ADD_DEFINITIONS(-DUSE_AGG) 
>   ENDIF(USE_AGG) 
> ENDIF(AGG_FOUND) 
 
Ok, then I think I'll do 
 
OPTION(USE_AGG "AGG SUpport" ON) 
IF( USE_AGG) 
   FIND_PACKAGE(AGG) 
ENDIF( USE_AGG) 
 
 
and later on use AGG_FOUND just as usual. This could even be wrapped into 
a small macro: 
 
MACRO(optional_package name) 
   OPTION(USE_${name} "Enable ${name} support" ON) 
   IF(${USE_${name}}) 
      FIND_PACKAGE(${name}) 
   ENDIF(${USE_${name}}) 
ENDMACRO(optional_package) 
 
Is there actually a cmake module where such macros could be collected, 
like "CMakeTools.cmake", "CMakeUtilities.cmake" or something like this ? 
 
Bye 
Alex 
 
 

-- 
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner


More information about the CMake mailing list