summaryrefslogtreecommitdiff
path: root/Modules/FindOpenSceneGraph.cmake
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2013-02-13 18:21:12 -0800
committerAnas Nashif <anas.nashif@intel.com>2013-02-13 18:21:12 -0800
commitef8aa19c33e83ff019595fd7f8fdc29c35c336a3 (patch)
tree6501b44707b5c6a88fa5f817adee1a3ffcb0012d /Modules/FindOpenSceneGraph.cmake
parent035c7fabc3b82cbc9a346c11abe2e9462b4c0379 (diff)
downloadcmake-ef8aa19c33e83ff019595fd7f8fdc29c35c336a3.tar.gz
cmake-ef8aa19c33e83ff019595fd7f8fdc29c35c336a3.tar.bz2
cmake-ef8aa19c33e83ff019595fd7f8fdc29c35c336a3.zip
Imported Upstream version 2.8.10.2upstream/2.8.10.2
Diffstat (limited to 'Modules/FindOpenSceneGraph.cmake')
-rw-r--r--Modules/FindOpenSceneGraph.cmake100
1 files changed, 24 insertions, 76 deletions
diff --git a/Modules/FindOpenSceneGraph.cmake b/Modules/FindOpenSceneGraph.cmake
index 52f931689..4a5aaba41 100644
--- a/Modules/FindOpenSceneGraph.cmake
+++ b/Modules/FindOpenSceneGraph.cmake
@@ -14,7 +14,7 @@
#
# OpenSceneGraph_DEBUG - Enable debugging output
#
-# OpenSceneGraph_MARK_AS_ADVANCED - Mark cache variables as advanced
+# OpenSceneGraph_MARK_AS_ADVANCED - Mark cache variables as advanced
# automatically
#
# The following environment variables are also respected for finding the OSG
@@ -26,6 +26,10 @@
# OSGDIR
# OSG_ROOT
#
+# [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.
+#
# This module defines the following output variables:
#
# OPENSCENEGRAPH_FOUND - Was the OSG and all of the specified components found?
@@ -49,7 +53,7 @@
#=============================================================================
# Copyright 2009 Kitware, Inc.
-# Copyright 2009 Philip Lowman <philip@yhbt.com>
+# Copyright 2009-2012 Philip Lowman <philip@yhbt.com>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
@@ -96,14 +100,15 @@ if(OSG_INCLUDE_DIR)
message(STATUS "[ FindOpenSceneGraph.cmake:${CMAKE_CURRENT_LIST_LINE} ] "
"Detected OSG_INCLUDE_DIR = ${OSG_INCLUDE_DIR}")
endif()
-
+
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()
-
+
if(EXISTS "${_osg_Version_file}")
- file(READ "${_osg_Version_file}" _osg_Version_contents)
+ file(STRINGS "${_osg_Version_file}" _osg_Version_contents
+ REGEX "#define (OSG_VERSION_[A-Z]+|OPENSCENEGRAPH_[A-Z]+_VERSION)[ \t]+[0-9]+")
else()
set(_osg_Version_contents "unknown")
endif()
@@ -130,6 +135,7 @@ if(OSG_INCLUDE_DIR)
message(WARNING "[ FindOpenSceneGraph.cmake:${CMAKE_CURRENT_LIST_LINE} ] "
"Failed to parse version number, please report this as a bug")
endif()
+ unset(_osg_Version_contents)
set(OPENSCENEGRAPH_VERSION "${_osg_VERSION_MAJOR}.${_osg_VERSION_MINOR}.${_osg_VERSION_PATCH}"
CACHE INTERNAL "The version of OSG which was detected")
@@ -139,29 +145,12 @@ if(OSG_INCLUDE_DIR)
endif()
endif()
-#
-# Version checking
-#
-if(OpenSceneGraph_FIND_VERSION AND OPENSCENEGRAPH_VERSION)
- if(OpenSceneGraph_FIND_VERSION_EXACT)
- if(NOT OPENSCENEGRAPH_VERSION VERSION_EQUAL ${OpenSceneGraph_FIND_VERSION})
- set(_osg_version_not_exact TRUE)
- endif()
- else()
- # version is too low
- if(NOT OPENSCENEGRAPH_VERSION VERSION_EQUAL ${OpenSceneGraph_FIND_VERSION} AND
- NOT OPENSCENEGRAPH_VERSION VERSION_GREATER ${OpenSceneGraph_FIND_VERSION})
- set(_osg_version_not_high_enough TRUE)
- endif()
- endif()
-endif()
-
set(_osg_quiet)
if(OpenSceneGraph_FIND_QUIETLY)
set(_osg_quiet "QUIET")
endif()
#
-# Here we call FIND_PACKAGE() on all of the components
+# Here we call find_package() on all of the components
#
foreach(_osg_module ${_osg_modules_to_process})
if(OpenSceneGraph_DEBUG)
@@ -182,65 +171,24 @@ endforeach()
if(OPENSCENEGRAPH_INCLUDE_DIR)
list(REMOVE_DUPLICATES OPENSCENEGRAPH_INCLUDE_DIR)
endif()
-
+
#
-# Inform the users with an error message based on
-# what version they have vs. what version was
-# required.
+# Check each module to see if it's found
#
+set(_osg_component_founds)
if(OpenSceneGraph_FIND_REQUIRED)
- set(_osg_version_output_type FATAL_ERROR)
-else()
- set(_osg_version_output_type STATUS)
+ foreach(_osg_module ${_osg_modules_to_process})
+ string(TOUPPER ${_osg_module} _osg_module_UC)
+ list(APPEND _osg_component_founds ${_osg_module_UC}_FOUND)
+ endforeach()
endif()
-if(_osg_version_not_high_enough)
- set(_osg_EPIC_FAIL TRUE)
- if(NOT OpenSceneGraph_FIND_QUIETLY)
- message(${_osg_version_output_type}
- "ERROR: Version ${OpenSceneGraph_FIND_VERSION} or higher of the OSG "
- "is required. Version ${OPENSCENEGRAPH_VERSION} was found.")
- endif()
-elseif(_osg_version_not_exact)
- set(_osg_EPIC_FAIL TRUE)
- if(NOT OpenSceneGraph_FIND_QUIETLY)
- message(${_osg_version_output_type}
- "ERROR: Version ${OpenSceneGraph_FIND_VERSION} of the OSG is required "
- "(exactly), version ${OPENSCENEGRAPH_VERSION} was found.")
- endif()
-else()
-
- #
- # Check each module to see if it's found
- #
- if(OpenSceneGraph_FIND_REQUIRED)
- set(_osg_missing_message)
- foreach(_osg_module ${_osg_modules_to_process})
- string(TOUPPER ${_osg_module} _osg_module_UC)
- if(NOT ${_osg_module_UC}_FOUND)
- set(_osg_missing_nodekit_fail true)
- set(_osg_missing_message "${_osg_missing_message} ${_osg_module}")
- endif()
- endforeach()
-
- if(_osg_missing_nodekit_fail)
- message(FATAL_ERROR "ERROR: Missing the following osg "
- "libraries: ${_osg_missing_message}.\n"
- "Consider using CMAKE_PREFIX_PATH or the OSG_DIR "
- "environment variable. See the "
- "${CMAKE_CURRENT_LIST_FILE} for more details.")
- endif()
- endif()
- include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSceneGraph DEFAULT_MSG OPENSCENEGRAPH_LIBRARIES OPENSCENEGRAPH_INCLUDE_DIR)
-endif()
+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)
-if(_osg_EPIC_FAIL)
- # Zero out everything, we didn't meet version requirements
- set(OPENSCENEGRAPH_FOUND FALSE)
- set(OPENSCENEGRAPH_LIBRARIES)
- set(OPENSCENEGRAPH_INCLUDE_DIR)
-endif()
+unset(_osg_component_founds)
set(OPENSCENEGRAPH_INCLUDE_DIRS ${OPENSCENEGRAPH_INCLUDE_DIR})