Migrate BuildingViewer (16 files: DDS members, m_logger inits, QOpenGLWidget); gui:3:bld.info + gui:3:bdv now load
118 lines
4.4 KiB
CMake
118 lines
4.4 KiB
CMake
# FindOpenSceneGraph.cmake
|
|
#
|
|
# Locate an installed OpenSceneGraph and expose the module variables that the
|
|
# Legatus BuildingViewer stack links against:
|
|
# OSG_INCLUDE_DIR, OPENSCENEGRAPH_INCLUDE_DIRS
|
|
# OPENSCENEGRAPH_LIBRARIES (the OSG component libs that were found)
|
|
# OPENTHREADS_LIBRARIES
|
|
# OPENSCENEGRAPH_FOUND, OPENSCENEGRAPH_VERSION
|
|
#
|
|
# NOTE (Qt6-migration port): OSG 3.4.1 ships no FindOpenSceneGraph.cmake and
|
|
# installs no OpenSceneGraphConfig.cmake, so this module is supplied to close
|
|
# the bld/OSG floor. It finds the 3.4.1 build installed under CMAKE_PREFIX_PATH
|
|
# (the component libs live under <prefix>/lib64) and honours the requested
|
|
# components -- including the ported Qt6 osgQt (see the .osg-port notes).
|
|
#
|
|
# Mirrors the classic OSG Find-module variable names that BuildingViewer/Common
|
|
# links: ${OSG_INCLUDE_DIR}, ${OPENSCENEGRAPH_LIBRARIES}, ${OPENTHREADS_LIBRARIES}.
|
|
|
|
SET(OSG_SEARCH_PREFIXES ${CMAKE_PREFIX_PATH} /usr/local /usr)
|
|
|
|
# Include dir: locate the osg/Version header.
|
|
FIND_PATH(OSG_INCLUDE_DIR
|
|
NAMES osg/Version
|
|
PATHS ${OSG_SEARCH_PREFIXES}
|
|
PATH_SUFFIXES include)
|
|
|
|
# OpenThreads support library (distinct SONAME: libOpenThreads.so.20 for 3.4.1).
|
|
FIND_LIBRARY(OPENTHREADS_LIBRARY
|
|
NAMES OpenThreads
|
|
PATHS ${OSG_SEARCH_PREFIXES}
|
|
PATH_SUFFIXES lib lib64)
|
|
|
|
# OSG component libraries. Find each that exists and collect them so
|
|
# OPENSCENEGRAPH_LIBRARIES covers the transitive dependency set the BgViewer
|
|
# SDK and BuildingViewerCommon link (the SDK's NEEDED entries require
|
|
# osg/DB/GA/Qt/Shadow/Sim/Text/Util/Viewer/Particle/Manipulator/Animation).
|
|
SET(OSG_COMPONENT_LIBS
|
|
osg
|
|
osgDB
|
|
osgUtil
|
|
osgGA
|
|
osgText
|
|
osgViewer
|
|
osgAnimation
|
|
osgManipulator
|
|
osgParticle
|
|
osgShadow
|
|
osgSim
|
|
osgWidget
|
|
osgQt)
|
|
|
|
SET(OPENSCENEGRAPH_LIBRARIES "")
|
|
FOREACH(_osg_lib ${OSG_COMPONENT_LIBS})
|
|
FIND_LIBRARY(OSG_LIBRARY_${_osg_lib}
|
|
NAMES ${_osg_lib}
|
|
PATHS ${OSG_SEARCH_PREFIXES}
|
|
PATH_SUFFIXES lib lib64)
|
|
IF(OSG_LIBRARY_${_osg_lib})
|
|
LIST(APPEND OPENSCENEGRAPH_LIBRARIES ${OSG_LIBRARY_${_osg_lib}})
|
|
SET(OPENSCENEGRAPH_${_osg_lib}_FOUND TRUE)
|
|
ELSE()
|
|
SET(OPENSCENEGRAPH_${_osg_lib}_FOUND FALSE)
|
|
ENDIF()
|
|
ENDFOREACH()
|
|
|
|
# Core libs are mandatory for the package to count as found.
|
|
SET(_osg_core_ok TRUE)
|
|
IF(NOT OSG_LIBRARY_osg OR NOT OSG_LIBRARY_osgDB OR NOT OSG_LIBRARY_osgUtil
|
|
OR NOT OSG_LIBRARY_osgGA OR NOT OSG_LIBRARY_osgViewer OR NOT OPENTHREADS_LIBRARY)
|
|
SET(_osg_core_ok FALSE)
|
|
ENDIF()
|
|
|
|
# Any requested component that is missing makes the package not found.
|
|
FOREACH(_osg_req ${OpenSceneGraph_FIND_COMPONENTS})
|
|
IF(NOT OSG_LIBRARY_${_osg_req})
|
|
SET(_osg_core_ok FALSE)
|
|
MESSAGE(STATUS "OpenSceneGraph: required component '${_osg_req}' not found")
|
|
ENDIF()
|
|
ENDFOREACH()
|
|
|
|
# Version string from the installed header's OPENSCENEGRAPH_*_VERSION macros.
|
|
IF(OSG_INCLUDE_DIR)
|
|
FILE(READ "${OSG_INCLUDE_DIR}/osg/Version" _osg_version_header)
|
|
STRING(REGEX MATCH "#define[ \t]+OPENSCENEGRAPH_MAJOR_VERSION[ \t]+[0-9]+"
|
|
_osg_m "${_osg_version_header}")
|
|
STRING(REGEX MATCH "#define[ \t]+OPENSCENEGRAPH_MINOR_VERSION[ \t]+[0-9]+"
|
|
_osg_n "${_osg_version_header}")
|
|
STRING(REGEX MATCH "#define[ \t]+OPENSCENEGRAPH_PATCH_VERSION[ \t]+[0-9]+"
|
|
_osg_p "${_osg_version_header}")
|
|
STRING(REGEX REPLACE "[^0-9]" "" _osg_major "${_osg_m}")
|
|
STRING(REGEX REPLACE "[^0-9]" "" _osg_minor "${_osg_n}")
|
|
STRING(REGEX REPLACE "[^0-9]" "" _osg_patch "${_osg_p}")
|
|
IF(_osg_major AND _osg_minor AND _osg_patch)
|
|
SET(OPENSCENEGRAPH_VERSION "${_osg_major}.${_osg_minor}.${_osg_patch}")
|
|
ENDIF()
|
|
ENDIF()
|
|
|
|
IF(OSG_INCLUDE_DIR AND _osg_core_ok)
|
|
SET(OPENSCENEGRAPH_FOUND TRUE)
|
|
SET(OPENSCENEGRAPH_INCLUDE_DIRS ${OSG_INCLUDE_DIR})
|
|
SET(OPENTHREADS_LIBRARIES ${OPENTHREADS_LIBRARY})
|
|
ELSE()
|
|
SET(OPENSCENEGRAPH_FOUND FALSE)
|
|
ENDIF()
|
|
|
|
INCLUDE(FindPackageHandleStandardArgs)
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSceneGraph
|
|
FOUND_VAR OPENSCENEGRAPH_FOUND
|
|
VERSION_VAR OPENSCENEGRAPH_VERSION
|
|
REQUIRED_VARS OPENSCENEGRAPH_INCLUDE_DIRS OPENSCENEGRAPH_LIBRARIES OPENTHREADS_LIBRARIES)
|
|
|
|
MARK_AS_ADVANCED(
|
|
OSG_INCLUDE_DIR OPENTHREADS_LIBRARY
|
|
OSG_LIBRARY_osg OSG_LIBRARY_osgDB OSG_LIBRARY_osgUtil OSG_LIBRARY_osgGA
|
|
OSG_LIBRARY_osgText OSG_LIBRARY_osgViewer OSG_LIBRARY_osgAnimation
|
|
OSG_LIBRARY_osgManipulator OSG_LIBRARY_osgParticle OSG_LIBRARY_osgShadow
|
|
OSG_LIBRARY_osgSim OSG_LIBRARY_osgWidget OSG_LIBRARY_osgQt)
|