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

3.3 版本中新增。

布尔值,指示是否找到了 OpenSceneGraph 工具包的 osgPresentation NodeKit。

OSGPRESENTATION_LIBRARIES

使用 osgPresentation 所需链接的库。

OSGPRESENTATION_LIBRARY

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

缓存变量

以下缓存变量也可以设置

OSGPRESENTATION_INCLUDE_DIR

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

OSGPRESENTATION_LIBRARY_DEBUG

osgPresentation 调试库的路径。

提示

此模块接受以下变量

OSGDIR

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

已弃用变量

以下变量提供用于向后兼容性

OSGPRESENTATION_FOUND

自版本 4.2 起已弃用: 请使用 osgPresentation_FOUND,其值相同。

布尔值,指示是否找到了 OpenSceneGraph 工具包的 osgPresentation NodeKit。

示例

使用此模块显式查找 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)

另请参阅