2013-10-15 19:17:36 +04:00
|
|
|
#.rst:
|
|
|
|
# FindOpenSceneGraph
|
|
|
|
# ------------------
|
2009-01-31 04:09:16 +03:00
|
|
|
#
|
2013-10-15 19:17:36 +04:00
|
|
|
# Find OpenSceneGraph
|
2009-01-31 04:09:16 +03:00
|
|
|
#
|
2013-10-15 19:17:36 +04:00
|
|
|
# This module searches for the OpenSceneGraph core "osg" library as well
|
|
|
|
# as OpenThreads, and whatever additional COMPONENTS (nodekits) that you
|
|
|
|
# specify.
|
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# See http://www.openscenegraph.org
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# NOTE: To use this module effectively you must either require CMake >=
|
|
|
|
# 2.6.3 with cmake_minimum_required(VERSION 2.6.3) or download and place
|
|
|
|
# FindOpenThreads.cmake, Findosg_functions.cmake, Findosg.cmake, and
|
|
|
|
# Find<etc>.cmake files into your CMAKE_MODULE_PATH.
|
|
|
|
#
|
|
|
|
# ==================================
|
2009-01-31 04:09:16 +03:00
|
|
|
#
|
|
|
|
# This module accepts the following variables (note mixed case)
|
|
|
|
#
|
2013-10-15 19:17:36 +04:00
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# OpenSceneGraph_DEBUG - Enable debugging output
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# OpenSceneGraph_MARK_AS_ADVANCED - Mark cache variables as advanced
|
|
|
|
# automatically
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# The following environment variables are also respected for finding the
|
|
|
|
# OSG and it's various components. CMAKE_PREFIX_PATH can also be used
|
|
|
|
# for this (see find_library() CMake documentation).
|
|
|
|
#
|
2014-10-22 23:52:31 +04:00
|
|
|
# ``<MODULE>_DIR``
|
|
|
|
# (where MODULE is of the form "OSGVOLUME" and there is a FindosgVolume.cmake file)
|
|
|
|
# ``OSG_DIR``
|
|
|
|
# ..
|
|
|
|
# ``OSGDIR``
|
|
|
|
# ..
|
|
|
|
# ``OSG_ROOT``
|
|
|
|
# ..
|
2009-01-31 04:09:16 +03:00
|
|
|
#
|
|
|
|
#
|
2013-10-15 19:17:36 +04:00
|
|
|
# [CMake 2.8.10]: The CMake variable OSG_DIR can now be used as well to
|
|
|
|
# influence detection, instead of needing to specify an environment
|
|
|
|
# variable.
|
2012-08-19 00:46:08 +04:00
|
|
|
#
|
2009-01-31 04:09:16 +03:00
|
|
|
# This module defines the following output variables:
|
|
|
|
#
|
2013-10-15 19:17:36 +04:00
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# OPENSCENEGRAPH_FOUND - Was the OSG and all of the specified components found?
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# OPENSCENEGRAPH_VERSION - The version of the OSG which was found
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# OPENSCENEGRAPH_INCLUDE_DIRS - Where to find the headers
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# OPENSCENEGRAPH_LIBRARIES - The OSG libraries
|
|
|
|
#
|
|
|
|
#
|
2009-01-31 04:09:16 +03:00
|
|
|
#
|
2013-10-15 19:17:36 +04:00
|
|
|
# ================================== Example Usage:
|
2009-01-31 04:09:16 +03:00
|
|
|
#
|
2013-10-15 19:17:36 +04:00
|
|
|
# ::
|
2009-01-31 04:09:16 +03:00
|
|
|
#
|
2013-10-15 19:17:36 +04:00
|
|
|
# find_package(OpenSceneGraph 2.0.0 REQUIRED osgDB osgUtil)
|
|
|
|
# # libOpenThreads & libosg automatically searched
|
|
|
|
# include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
|
2009-01-31 04:09:16 +03:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2013-10-15 19:17:36 +04:00
|
|
|
# ::
|
2009-01-31 04:09:16 +03:00
|
|
|
#
|
2013-10-15 19:17:36 +04:00
|
|
|
# add_executable(foo foo.cc)
|
|
|
|
# target_link_libraries(foo ${OPENSCENEGRAPH_LIBRARIES})
|
2009-09-22 06:38:12 +04:00
|
|
|
|
2009-09-28 19:45:50 +04:00
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2009 Kitware, Inc.
|
2012-08-19 00:46:08 +04:00
|
|
|
# Copyright 2009-2012 Philip Lowman <philip@yhbt.com>
|
2009-09-28 19:45:50 +04:00
|
|
|
#
|
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
|
|
|
#
|
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
2010-08-07 04:48:47 +04:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-09-28 19:45:50 +04:00
|
|
|
# License text for the above reference.)
|
|
|
|
|
2009-01-31 04:09:16 +03:00
|
|
|
#
|
|
|
|
# Naming convention:
|
|
|
|
# Local variables of the form _osg_foo
|
|
|
|
# Input variables of the form OpenSceneGraph_FOO
|
|
|
|
# Output variables of the form OPENSCENEGRAPH_FOO
|
|
|
|
#
|
|
|
|
|
2012-11-04 00:35:44 +04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake)
|
2009-01-31 04:09:16 +03:00
|
|
|
|
|
|
|
set(_osg_modules_to_process)
|
|
|
|
foreach(_osg_component ${OpenSceneGraph_FIND_COMPONENTS})
|
|
|
|
list(APPEND _osg_modules_to_process ${_osg_component})
|
|
|
|
endforeach()
|
|
|
|
list(APPEND _osg_modules_to_process "osg" "OpenThreads")
|
|
|
|
list(REMOVE_DUPLICATES _osg_modules_to_process)
|
|
|
|
|
|
|
|
if(OpenSceneGraph_DEBUG)
|
2012-02-24 23:39:01 +04:00
|
|
|
message(STATUS "[ FindOpenSceneGraph.cmake:${CMAKE_CURRENT_LIST_LINE} ] "
|
2009-01-31 04:09:16 +03:00
|
|
|
"Components = ${_osg_modules_to_process}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#
|
|
|
|
# First we need to find and parse osg/Version
|
|
|
|
#
|
|
|
|
OSG_FIND_PATH(OSG osg/Version)
|
|
|
|
if(OpenSceneGraph_MARK_AS_ADVANCED)
|
|
|
|
OSG_MARK_AS_ADVANCED(OSG)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Try to ascertain the version...
|
|
|
|
if(OSG_INCLUDE_DIR)
|
|
|
|
if(OpenSceneGraph_DEBUG)
|
2012-02-24 23:39:01 +04:00
|
|
|
message(STATUS "[ FindOpenSceneGraph.cmake:${CMAKE_CURRENT_LIST_LINE} ] "
|
2009-01-31 04:09:16 +03:00
|
|
|
"Detected OSG_INCLUDE_DIR = ${OSG_INCLUDE_DIR}")
|
|
|
|
endif()
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2009-10-20 15:55:48 +04:00
|
|
|
set(_osg_Version_file "${OSG_INCLUDE_DIR}/osg/Version")
|
|
|
|
if("${OSG_INCLUDE_DIR}" MATCHES "\\.framework$" AND NOT EXISTS "${_osg_Version_file}")
|
|
|
|
set(_osg_Version_file "${OSG_INCLUDE_DIR}/Headers/Version")
|
|
|
|
endif()
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2009-10-20 15:55:48 +04:00
|
|
|
if(EXISTS "${_osg_Version_file}")
|
2012-08-19 15:54:56 +04:00
|
|
|
file(STRINGS "${_osg_Version_file}" _osg_Version_contents
|
|
|
|
REGEX "#define (OSG_VERSION_[A-Z]+|OPENSCENEGRAPH_[A-Z]+_VERSION)[ \t]+[0-9]+")
|
2009-10-16 21:25:59 +04:00
|
|
|
else()
|
|
|
|
set(_osg_Version_contents "unknown")
|
|
|
|
endif()
|
2009-01-31 04:09:16 +03:00
|
|
|
|
|
|
|
string(REGEX MATCH ".*#define OSG_VERSION_MAJOR[ \t]+[0-9]+.*"
|
2009-10-16 21:25:59 +04:00
|
|
|
_osg_old_defines "${_osg_Version_contents}")
|
2009-01-31 04:09:16 +03:00
|
|
|
string(REGEX MATCH ".*#define OPENSCENEGRAPH_MAJOR_VERSION[ \t]+[0-9]+.*"
|
2009-10-16 21:25:59 +04:00
|
|
|
_osg_new_defines "${_osg_Version_contents}")
|
2009-01-31 04:09:16 +03:00
|
|
|
if(_osg_old_defines)
|
|
|
|
string(REGEX REPLACE ".*#define OSG_VERSION_MAJOR[ \t]+([0-9]+).*"
|
|
|
|
"\\1" _osg_VERSION_MAJOR ${_osg_Version_contents})
|
|
|
|
string(REGEX REPLACE ".*#define OSG_VERSION_MINOR[ \t]+([0-9]+).*"
|
|
|
|
"\\1" _osg_VERSION_MINOR ${_osg_Version_contents})
|
|
|
|
string(REGEX REPLACE ".*#define OSG_VERSION_PATCH[ \t]+([0-9]+).*"
|
|
|
|
"\\1" _osg_VERSION_PATCH ${_osg_Version_contents})
|
|
|
|
elseif(_osg_new_defines)
|
|
|
|
string(REGEX REPLACE ".*#define OPENSCENEGRAPH_MAJOR_VERSION[ \t]+([0-9]+).*"
|
|
|
|
"\\1" _osg_VERSION_MAJOR ${_osg_Version_contents})
|
|
|
|
string(REGEX REPLACE ".*#define OPENSCENEGRAPH_MINOR_VERSION[ \t]+([0-9]+).*"
|
|
|
|
"\\1" _osg_VERSION_MINOR ${_osg_Version_contents})
|
|
|
|
string(REGEX REPLACE ".*#define OPENSCENEGRAPH_PATCH_VERSION[ \t]+([0-9]+).*"
|
|
|
|
"\\1" _osg_VERSION_PATCH ${_osg_Version_contents})
|
|
|
|
else()
|
2012-02-24 23:39:01 +04:00
|
|
|
message(WARNING "[ FindOpenSceneGraph.cmake:${CMAKE_CURRENT_LIST_LINE} ] "
|
2009-01-31 04:09:16 +03:00
|
|
|
"Failed to parse version number, please report this as a bug")
|
|
|
|
endif()
|
2012-08-19 15:54:56 +04:00
|
|
|
unset(_osg_Version_contents)
|
2009-01-31 04:09:16 +03:00
|
|
|
|
|
|
|
set(OPENSCENEGRAPH_VERSION "${_osg_VERSION_MAJOR}.${_osg_VERSION_MINOR}.${_osg_VERSION_PATCH}"
|
|
|
|
CACHE INTERNAL "The version of OSG which was detected")
|
|
|
|
if(OpenSceneGraph_DEBUG)
|
2012-02-24 23:39:01 +04:00
|
|
|
message(STATUS "[ FindOpenSceneGraph.cmake:${CMAKE_CURRENT_LIST_LINE} ] "
|
2009-01-31 04:09:16 +03:00
|
|
|
"Detected version ${OPENSCENEGRAPH_VERSION}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(_osg_quiet)
|
|
|
|
if(OpenSceneGraph_FIND_QUIETLY)
|
|
|
|
set(_osg_quiet "QUIET")
|
|
|
|
endif()
|
|
|
|
#
|
2012-08-13 21:47:32 +04:00
|
|
|
# Here we call find_package() on all of the components
|
2009-01-31 04:09:16 +03:00
|
|
|
#
|
|
|
|
foreach(_osg_module ${_osg_modules_to_process})
|
|
|
|
if(OpenSceneGraph_DEBUG)
|
2012-02-24 23:39:01 +04:00
|
|
|
message(STATUS "[ FindOpenSceneGraph.cmake:${CMAKE_CURRENT_LIST_LINE} ] "
|
2009-01-31 04:09:16 +03:00
|
|
|
"Calling find_package(${_osg_module} ${_osg_required} ${_osg_quiet})")
|
|
|
|
endif()
|
2009-08-13 05:58:14 +04:00
|
|
|
find_package(${_osg_module} ${_osg_quiet})
|
2009-01-31 04:09:16 +03:00
|
|
|
|
|
|
|
string(TOUPPER ${_osg_module} _osg_module_UC)
|
2014-09-17 00:20:19 +04:00
|
|
|
# append to list if module was found OR is required
|
|
|
|
if( ${_osg_module_UC}_FOUND OR OpenSceneGraph_FIND_REQUIRED )
|
|
|
|
list(APPEND OPENSCENEGRAPH_INCLUDE_DIR ${${_osg_module_UC}_INCLUDE_DIR})
|
|
|
|
list(APPEND OPENSCENEGRAPH_LIBRARIES ${${_osg_module_UC}_LIBRARIES})
|
|
|
|
endif()
|
2009-01-31 04:09:16 +03:00
|
|
|
|
|
|
|
if(OpenSceneGraph_MARK_AS_ADVANCED)
|
|
|
|
OSG_MARK_AS_ADVANCED(${_osg_module})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if(OPENSCENEGRAPH_INCLUDE_DIR)
|
|
|
|
list(REMOVE_DUPLICATES OPENSCENEGRAPH_INCLUDE_DIR)
|
|
|
|
endif()
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2009-01-31 04:09:16 +03:00
|
|
|
#
|
2012-08-19 23:06:28 +04:00
|
|
|
# Check each module to see if it's found
|
2009-01-31 04:09:16 +03:00
|
|
|
#
|
2012-08-19 23:06:28 +04:00
|
|
|
set(_osg_component_founds)
|
2009-01-31 04:09:16 +03:00
|
|
|
if(OpenSceneGraph_FIND_REQUIRED)
|
2012-08-19 23:06:28 +04:00
|
|
|
foreach(_osg_module ${_osg_modules_to_process})
|
|
|
|
string(TOUPPER ${_osg_module} _osg_module_UC)
|
|
|
|
list(APPEND _osg_component_founds ${_osg_module_UC}_FOUND)
|
|
|
|
endforeach()
|
2009-01-31 04:09:16 +03:00
|
|
|
endif()
|
2009-08-13 05:58:14 +04:00
|
|
|
|
2012-08-19 23:06:28 +04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSceneGraph
|
|
|
|
REQUIRED_VARS OPENSCENEGRAPH_LIBRARIES OPENSCENEGRAPH_INCLUDE_DIR ${_osg_component_founds}
|
|
|
|
VERSION_VAR OPENSCENEGRAPH_VERSION)
|
2009-01-31 04:09:16 +03:00
|
|
|
|
2012-08-19 23:06:28 +04:00
|
|
|
unset(_osg_component_founds)
|
2009-01-31 04:09:16 +03:00
|
|
|
|
|
|
|
set(OPENSCENEGRAPH_INCLUDE_DIRS ${OPENSCENEGRAPH_INCLUDE_DIR})
|
|
|
|
|