
# This module defines
# OSG_LIBRARY
# OSG_INCLUDE_DIR, where to find the headers
#
# $OSG_DIR is an environment variable that would
# correspond to the ./configure --prefix=$OSG_DIR


FIND_PATH(OSG_INCLUDE_DIR osg/Node
	$ENV{OSG_DIR}/include
    /usr/local/OpenSceneGraph/include
)

MACRO(FIND_OSG_LIBRARY MYLIBRARY MYLIBRARYNAME)

    FIND_LIBRARY(${MYLIBRARY} 
        NAMES ${MYLIBRARYNAME} ${MYLIBRARYNAME}d
        PATHS
	      $ENV{OSG_DIR}/lib
          /usr/local/lib64
          /usr/local/lib
          /usr/lib64
          /usr/lib
          /usr/local/OpenSceneGraph
	    )

ENDMACRO(FIND_OSG_LIBRARY LIBRARY LIBRARYNAME)

FIND_OSG_LIBRARY(OSG_LIBRARY osg)
FIND_OSG_LIBRARY(OSGUTIL_LIBRARY osgUtil)
FIND_OSG_LIBRARY(OSGDB_LIBRARY osgDB)
FIND_OSG_LIBRARY(OSGTEXT_LIBRARY osgText)
FIND_OSG_LIBRARY(OSGVIEWER_LIBRARY osgViewer)
FIND_OSG_LIBRARY(OSGVIEWER_LIBRARY osgShadow)

SET(OSG_LIBRARIES ${OSG_LIBRARY} ${OSGUTIL_LIBRARY} ${OSGDB_LIBRARY} ${OSGTEXT_LIBRARY} ${OSGTERRAIN_LIBRARY} ${OSGFX_LIBRARY} ${OSGVIEWER_LIBRARY})

SET(OSG_FOUND "NO")
IF(OSG_LIBRARY AND OSG_INCLUDE_DIR)
    SET(OSG_FOUND "YES")
	GET_FILENAME_COMPONENT(OSG_LIBRARY_DIR ${OSG_LIBRARY} PATH)
ENDIF(OSG_LIBRARY AND OSG_INCLUDE_DIR)
