[CMake] OpenSceneGraph Find Modules

Hendrik Sattler post at hendrik-sattler.de
Fri Jan 4 16:31:14 EST 2008


Am Freitag 04 Januar 2008 schrieb Pau Garcia i Quiles:
> Quoting "Miguel A. Figueroa-Villanueva" <miguelf at ieee.org>:
> > What I was suggesting is that instead of having the following
> >
> > modules separate:
> >> Findosg.cmake
> >> FindosgDB.cmake
> >> FindosgFX.cmake
> >> FindosgGA.cmake
> >> FindosgIntrospection.cmake
> >> FindosgManipulator.cmake
> >> FindosgParticle.cmake
> >> FindosgProducer.cmake
> >> FindosgShadow.cmake
> >> FindosgSim.cmake
> >> FindosgTerrain.cmake
> >> FindosgText.cmake
> >> FindosgUtil.cmake
> >> FindosgViewer.cmake
> >
> > You should have a single FindOpenSceneGraph.cmake module and provide a
> > mechanism to use (if available) the different components of the
> > library (FX, GA, Introspection, etc.) that the user is interested in.
>
> I'm doing somethink like that for ZeroC ICE.
>
> ICE has several libraries (IceCore, IceBox, IceGrid, IcePatch2,
> IceSSL, IceStorm, IceUtil, IceXML, Freeze, Glacier2 and some
> executables). I have a FindXXXX.cmake for each of them:
>
> FindZeroCIceBox.cmake
> FindZeroCIceCore.cmake
> FindZeroCIceExecutables.cmake
> FindZeroCIceGrid.cmake
> FindZeroCIcePatch2.cmake
> FindZeroCIceSSL.cmake
> FindZeroCIceStorm.cmake
> FindZeroCIceUtil.cmake
> FindZeroCIceXML.cmake
> FindZeroCFreeze.cmake
> FindZeroCGlacier2.cmake
>
> Then I have a FindZeroCIce.cmake which essentially has this code:
>
> [...]
> SET( ZeroCIceCore_FIND_QUIETLY TRUE )
> SET( ZeroCIceBox_FIND_QUIETLY TRUE )
> SET( ZeroCIceGrid_FIND_QUIETLY TRUE )
> SET( ZeroCIcePatch2_FIND_QUIETLY TRUE )
> SET( ZeroCIceSSL_FIND_QUIETLY TRUE )
> SET( ZeroCIceStorm_FIND_QUIETLY TRUE )
> SET( ZeroCIceUtil_FIND_QUIETLY TRUE )
> SET( ZeroCIceXML_FIND_QUIETLY TRUE )
> SET( ZeroCIceExecutables_FIND_QUIETLY TRUE )
> SET( ZeroCIceFreeze_FIND_QUIETLY TRUE )
> SET( ZeroCIceGlacier2_FIND_QUIETLY TRUE )
>
> FIND_PACKAGE( ZeroCIceCore )

or simpler:
foreach ( i Core Box Grid Patch2....)
  set ( ZeroCIce${i}_FIND_QUIETLY TRUE )
  find_package ( ZeroCIce${i} )
endforeach ( i )
That's not really worth a seperate module file.

Maybe a scheme for module subdirectories should be created and added to CMake?
There are probably plenty of such projects that are splitted into numerous 
sub-parts. A
  find_package ( ZeroCIce COMPONENTS Core Box )
could then automatically resolv to the above two parts but for the module 
files:
  FindZeroCIce/Core.cmake and
  FindZeroCIce/Box.cmake

If that cannot be included into CMake, such modules could include the files in 
the subdir and evaluate the COMPONENTS themselves in a FindZeroCIce.cmake.
IMHO using a subdirectory is way better than putting everything in the file 
name because at one point, the directory listing of the modules directory 
will not be readable anymore :-(
OTOH, ask yourself if such modules do more than being a wrapper around 
find_library because there is no need for such (creating a module for every 
lib out there is insane).

HS


More information about the CMake mailing list