FindosgPresentation

查找 OpenSceneGraph 工具包中的 osgPresentation NodeKit,自 OpenSceneGraph 版本 3.0.0 起可用。

注意

在大多数情况下,建议使用 FindOpenSceneGraph 模块,并将 osgPresentation 列为组件。这将自动处理 OpenThreads 和核心 osg 库等依赖项。

find_package(OpenSceneGraph COMPONENTS osgPresentation)

此模块由 FindOpenSceneGraph 内部使用以查找 osgPresentation NodeKit。在典型使用 find_package() 命令时,不打算直接包含它。但是,它可作为一个独立模块用于需要对检测进行更精细控制的高级用例。例如,显式查找 osgPresentation 或绕过自动组件检测。

find_package(osgPresentation)

OpenSceneGraph 和 osgPresentation 头文件旨在 C++ 项目源代码中包含为

example.cxx
#include <osg/PositionAttitudeTransform>
#include <osgPresentation/SlideEventHandler>
// ...

使用 OpenSceneGraph 工具包时,可能还需要其他库,例如 OpenGL。

结果变量

此模块定义了以下变量

osgPresentation_FOUND

一个布尔值,指示是否找到 OpenSceneGraph 工具包的 osgPresentation NodeKit。为了向后兼容,OSGPRESENTATION_FOUND 变量也设置为相同的值。

OSGPRESENTATION_LIBRARIES

使用 osgPresentation 所需链接的库。

OSGPRESENTATION_LIBRARY

一个结果变量,其值与 OSGPRESENTATION_LIBRARIES 变量相同。

缓存变量

以下缓存变量也可以设置

OSGPRESENTATION_INCLUDE_DIR

包含使用 osgPresentation 所需头文件的包含目录。

OSGPRESENTATION_LIBRARY_DEBUG

osgPresentation 调试库的路径。

提示

此模块接受以下变量

OSGDIR

环境变量,可以在安装在自定义位置时设置,以帮助定位 OpenSceneGraph 工具包,包括其 osgPresentation NodeKit。它应指向配置、构建和安装时使用的 OpenSceneGraph 安装前缀:./configure --prefix=$OSGDIR

示例

使用此模块显式查找 osgPresentation 并创建封装其使用要求以链接到项目目标的导入目标

find_package(osgPresentation)

if(osgPresentation_FOUND AND NOT TARGET osgPresentation::osgPresentation)
  add_library(osgPresentation::osgPresentation INTERFACE IMPORTED)
  set_target_properties(
    osgPresentation::osgPresentation
    PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${OSGPRESENTATION_INCLUDE_DIR}"
      INTERFACE_LINK_LIBRARIES "${OSGPRESENTATION_LIBRARIES}"
  )
endif()

target_link_libraries(example PRIVATE osgPresentation::osgPresentation)

另请参阅