OpenSceneGraph/CMakeModules/OpenSceneGraphConfig.cmake.in
2018-11-15 12:52:11 +08:00

169 lines
5.8 KiB
CMake

# - Config file for the OpenSceneGraph package.
#
# For finding and loading OpenSceneGraph from your project, type:
#
# find_package(OpenSceneGraph [version] [COMPONENTS comp])
#
# This creates the following variables:
#
# OpenSceneGraph_LIBRARIES : All the libraries of all the requested components
# OPENSCENEGRAPH_LIBRARIES
#
# OpenSceneGraph_INCLUDE_DIRS : All the include directories of all the requested components
# OPENSCENEGRAPH_INCLUDE_DIRS
#
# OpenSceneGraph_FOUND : Set to true if all required components can be found
# OPENSCENEGRAPH_FOUND
#
# OSG_LIBRARY : The library for the core OSG component
# OSG_LIBRARIES
#
# OSG_INCLUDE_DIR : The include directory for the core OSG component
#
# <COMP>_LIBRARY : This is created for each requested component <comp>
# <COMP>_LIBRARIES and refers to the component's library
#
# <COMP>_INCLUDE_DIR : This is created for each requested component <comp>
# and refers to the component's include directory
################################################################################
#
# This config-file will also import the following targets:
#
# @PKG_NAMESPACE@::osg (for the core OSG library)
# @PKG_NAMESPACE@::<comp> (for each requested component library)
#
# Use target_link_libraries(tgt [PUBLIC|PRIVATE] @PKG_NAMESPACE@::<comp>)
# for each component that you want to link to.
#
################################################################################
# =========================== DO NOT MODIFY THIS FILE DIRECTLY ===========================
# This file is auto-generated from OpenSceneGraph/CMakeModules/OpenSceneGraphConfig.cmake
# ========================================================================================
# We depend on 2.8.8 for CMakePackageConfigHelpers. This config file is not
# guaranteed to work with lower versions of cmake.
cmake_minimum_required(VERSION 2.8.8)
# Shortcut if find_package(OpenSceneGraph ...) has been called before
if(OpenSceneGraph_CONFIG_INCLUDED)
# Check that each of the components requested have already been found.
set(OpenSceneGraph_all_components_found TRUE)
foreach(component ${OpenSceneGraph_FIND_COMPONENTS})
if(NOT TARGET @PKG_NAMESPACE@::${component})
set(OpenSceneGraph_all_components_found FALSE)
break()
endif()
endforeach()
# If this config file has been called before, and all the requested
# components are already found, then exit early.
if(OpenSceneGraph_all_components_found)
return()
endif()
endif()
set(OpenSceneGraph_CONFIG_INCLUDED TRUE)
@PACKAGE_INIT@
set(OpenSceneGraph_INCLUDE_DIRS @PACKAGE_INSTALL_INCDIR@)
set(OPENSCENEGRAPH_INCLUDE_DIRS ${OpenSceneGraph_INCLUDE_DIRS})
set(OpenSceneGraph_LIBRARIES)
foreach(component OpenThreads osg ${OpenSceneGraph_FIND_COMPONENTS})
message(STATUS "Looking for [${component}] component of OpenSceneGraph")
if(TARGET @PKG_NAMESPACE@::${component})
# This component has already been found, so we'll skip it
continue()
endif()
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${component}-targets.cmake)
if(OpenSceneGraph_FIND_REQUIRED_${component} OR NOT OpenSceneGraph_FIND_QUIETLY)
message("Could not find [${component}] component of OpenSceneGraph")
endif()
continue()
endif()
include(${CMAKE_CURRENT_LIST_DIR}/${component}-targets.cmake)
if(NOT OpenSceneGraph_FIND_QUIETLY)
message(STATUS "Found [${component}] component of OpenSceneGraph")
endif()
string(TOUPPER ${component} UC_COMPONENT)
# Components all get installed to the same include directory
set(${UC_COMPONENT}_INCLUDE_DIR ${OpenSceneGraph_INCLUDE_DIRS})
if(WIN32)
# For Windows, we need to provide the consumer with the IMPLIB (.lib) file
set(osg_imported_lib_property IMPORTED_IMPLIB)
else()
# For UNIX, we need to provide the shared object (.so) file
set(osg_imported_lib_property IMPORTED_LOCATION)
endif()
# For each possible configuration, find the relevant file on disk
foreach(osg_configuration "" _DEBUG _RELEASE)
get_property(${UC_COMPONENT}_LIBRARY${osg_configuration}
TARGET @PKG_NAMESPACE@::${component}
PROPERTY ${osg_imported_lib_property}${osg_configuration}
)
set(${UC_COMPONENT}_LIBRARIES${osg_configuration} ${${UC_COMPONENT}_LIBRARY})
endforeach()
# If a default library configuration was not found, create it
if(NOT ${UC_COMPONENT}_LIBRARY)
if(${UC_COMPONENT}_LIBRARY_DEBUG AND ${UC_COMPONENT}_LIBRARY_RELEASE)
# We have a release and a debug library, so let's use both
set(${UC_COMPONENT}_LIBRARY
optimized ${${UC_COMPONENT}_LIBRARY_RELEASE}
debug ${${UC_COMPONENT}_LIBRARY_DEBUG})
elseif(${UC_COMPONENT}_LIBRARY_RELEASE)
# There is only a release library, so let's use that
set(${UC_COMPONENT}_LIBRARY optimized ${${UC_COMPONENT}_LIBRARY_RELEASE})
elseif(${UC_COMPONENT}_LIBRARY_DEBUG)
# There is only a debug library, so let's use that
set(${UC_COMPONENT}_LIBRARY debug ${${UC_COMPONENT}_LIBRARY_DEBUG})
else()
# This should never happen, or else something is severely broken
# with the configuration, so we'll quit early.
message(FATAL_ERROR
"Could not find either an optimized or a debug version of the "
"requested OSG component: [${component}]")
endif()
set(${UC_COMPONENT}_LIBRARIES ${${UC_COMPONENT}_LIBRARY})
endif()
list(APPEND OpenSceneGraph_LIBRARIES ${${UC_COMPONENT}_LIBRARIES})
endforeach()
set(OPENSCENEGRAPH_LIBRARIES ${OpenSceneGraph_LIBRARIES})
check_required_components(OpenSceneGraph)