FindOpenSceneGraph¶
Finds OpenSceneGraph (OSG), a 3D graphics application programming interface.
Note
OpenSceneGraph development has largely transitioned to its successor project, VulkanSceneGraph, which should be preferred for new code. Refer to the upstream documentation for guidance on using VulkanSceneGraph with CMake.
This module searches for the OpenSceneGraph core osg library, its dependency OpenThreads, and additional OpenSceneGraph libraries, some of which are also known as NodeKits, if specified.
When working with OpenSceneGraph, its core library headers are intended to be included in C++ project source code as:
example.cxx¶#include <osg/PositionAttitudeTransform>
Headers for the OpenSceneGraph libraries and NodeKits follow a similar inclusion structure, for example:
example.cxx¶#include <osgAnimation/Animation>
#include <osgDB/DatabasePager>
#include <osgFX/BumpMapping>
// ...
Components¶
OpenSceneGraph toolkit consists of the core library osg, and additional
libraries, which can be optionally specified as components with the
find_package() command:
find_package(OpenSceneGraph [COMPONENTS <components>...])
Supported components include:
osgFinds the core osg library (
libosg), required to use OpenSceneGraph. This component is always automatically implied.OpenThreadsFinds the dependent OpenThreads library (
libOpenThreads) via theFindOpenThreadsmodule. This component is always automatically implied as it is required to use OpenSceneGraph.osgAnimationFinds the osgAnimation library, which provides general purpose utility classes for animation.
osgDBFinds the osgDB library for reading and writing scene graphs support.
osgFXFinds the osgFX NodeKit, which provides a framework for implementing special effects.
osgGAFinds the osgGA (GUI Abstraction) library, which provides facilities to work with varying window systems.
osgIntrospectionFinds the osgIntrospection library, which provides a reflection framework for accessing and invoking class properties and methods at runtime without modifying the classes.
Note
The osgIntrospection library has been removed from the OpenSceneGraph toolkit as of OpenSceneGraph version 3.0.
osgManipulatorFinds the osgManipulator NodeKit, which provides support for 3D interactive manipulators.
osgParticleFinds the osgParticle NodeKit, which provides support for particle effects.
osgPresentationFinds the osgPresentation NodeKit, which provides support for 3D scene graph based presentations.
Note
This NodeKit has been added in OpenSceneGraph 3.0.0.
osgProducerFinds the osgProducer utility library, which provides functionality for window management and event handling.
Note
The osgProducer has been removed from early versions of OpenSceneGraph toolkit 1.x, and has been superseded by the osgViewer library.
osgQtFinds the osgQt utility library, which provides various classes to aid the integration of Qt.
Note
As of OpenSceneGraph version 3.6, this library has been moved to its own repository.
osgShadowFinds the osgShadow NodeKit, which provides support for a range of shadow techniques.
osgSimFinds the osgSim NodeKit, which adds support for simulation features like navigation lights and OpenFlight-style movement controls.
osgTerrainFinds the osgTerrain NodeKit, which provides geospecifc terrain rendering support.
osgTextFinds the osgText NodeKit, which provides high quality text support.
osgUtilFinds the osgUtil library, which provides general-purpose utilities like update, cull, and draw traversals, as well as scene graph tools such as optimization, triangle stripping, and tessellation.
osgViewerFinds the osgViewer library, which provides high level viewer functionality.
osgVolumeFinds the osgVolume NodeKit, which provides volume rendering support.
osgWidgetFinds the osgWidget NodeKit, which provides support for 2D and 3D GUI widget sets.
If no components are specified, this module searches for the osg and
OpenThreads components by default.
Result Variables¶
This module defines the following variables:
OpenSceneGraph_FOUNDBoolean indicating whether the (requested version of) OpenSceneGraph with all specified components is found. For backward compatibility, the
OPENSCENEGRAPH_FOUNDvariable is also set to the same value.OPENSCENEGRAPH_VERSIONThe version of the OSG which was found.
OPENSCENEGRAPH_INCLUDE_DIRSInclude directories containing headers needed to use OpenSceneGraph.
OPENSCENEGRAPH_LIBRARIESLibraries needed to link against to use OpenSceneGraph.
Hints¶
This module accepts the following variables:
OpenSceneGraph_DEBUGSet this variable to boolean true to enable debugging output by this module.
OpenSceneGraph_MARK_AS_ADVANCEDSet this variable to boolean true to mark cache variables of this module as advanced automatically.
To help this module find OpenSceneGraph and its various components installed in
custom location, CMAKE_PREFIX_PATH variable can be used.
Additionally, the following variables are also respected:
<COMPONENT>_DIREnvironment or CMake variable that can be set to the root of the OSG common installation, where
<COMPONENT>is the uppercase form of component listed above. For example,OSGVOLUME_DIRto find theosgVolumecomponent.OSG_DIREnvironment or CMake variable that can be set to influence detection of OpenSceneGraph installation root location as a whole.
OSGDIREnvironment variable treated the same as
OSG_DIR.OSG_ROOTEnvironment variable treated the same as
OSG_DIR.
Examples¶
Finding the OpenSceneGraph with osgDB and osgUtil libraries specified as
components and creating an interface imported target
that encapsulates its usage requirements for linking to a project target:
find_package(OpenSceneGraph 2.0.0 REQUIRED COMPONENTS osgDB osgUtil)
if(OpenSceneGraph_FOUND AND NOT TARGET OpenSceneGraph::OpenSceneGraph)
add_library(OpenSceneGraph::OpenSceneGraph INTERFACE IMPORTED)
set_target_properties(
OpenSceneGraph::OpenSceneGraph
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OPENSCENEGRAPH_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${OPENSCENEGRAPH_LIBRARIES}"
)
endif()
add_executable(example example.cxx)
target_link_libraries(example PRIVATE OpenSceneGraph::OpenSceneGraph)
See Also¶
The following OpenSceneGraph-related helper find modules are used internally by
this module when finding specific OpenSceneGraph components. These modules are
not intended to be included or invoked directly by project code during typical
use of find_package(OpenSceneGraph). However, they can be useful for
advanced scenarios where finer control over component detection is needed. For
example, to find them explicitly and override or bypass detection of specific
OpenSceneGraph components:
The
Findosgmodule to find the core osg library.The
FindosgAnimationmodule to find osgAnimation.The
FindosgDBmodule to find osgDB.The
FindosgFXmodule to find osgDB.The
FindosgGAmodule to find osgGA.The
FindosgIntrospectionmodule to find osgIntrospection.The
FindosgManipulatormodule to find osgManipulator.The
FindosgParticlemodule to find osgParticle.The
FindosgPresentationmodule to find osgPresentation.The
FindosgProducermodule to find osgProducer.The
FindosgQtmodule to find osgQt.The
FindosgShadowmodule to find osgShadow.The
FindosgSimmodule to find osgSim.The
FindosgTerrainmodule to find osgTerrain.The
FindosgTextmodule to find osgText.The
FindosgUtilmodule to find osgUtil.The
FindosgViewermodule to find osgViewer.The
FindosgVolumemodule to find osgVolume.The
FindosgWidgetmodule to find osgWidget.