1# - Provide access to the OpenSceneGraph runtime files for bundling in 2# an installation or package. 3# 4# Sets these variables: 5# - OSGDB_PLUGINS_RELEASE 6# - OSGDB_PLUGINS_DEBUG 7# - OSGWRAPPER_PLUGINS_RELEASE 8# - OSGWRAPPER_PLUGINS_DEBUG 9# - OSG_RUNTIME_LIBRARY_DIR 10# - OSG_PATH_TO_PLUGINS 11# 12# Creates this function: 13# - install_osg_plugins( {varNameForOutputFilenames} ) 14# 15# Requires these CMake modules: 16# no additional modules required 17# 18# Original Author: 19# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net> 20# http://academic.cleardefinition.com 21# Iowa State University HCI Graduate Program/VRAC 22# 23# Copyright Iowa State University 2009-2010. 24# Distributed under the Boost Software License, Version 1.0. 25# (See accompanying file LICENSE_1_0.txt or copy at 26# http://www.boost.org/LICENSE_1_0.txt) 27 28 29function(_osgbundle_split_debug_versions releasevar debugvar) 30 set(release) 31 set(debug) 32 foreach(fn ${ARGN}) 33 get_filename_component(name "${fn}" NAME_WE) 34 if("${name}" MATCHES "d$") 35 list(APPEND debug "${fn}") 36 else() 37 list(APPEND release "${fn}") 38 endif() 39 endforeach() 40 set(${releasevar} ${release} PARENT_SCOPE) 41 set(${debugvar} ${debug} PARENT_SCOPE) 42endfunction() 43 44function(_osgbundle_find_plugins varprefix filenameprefix) 45 file(GLOB 46 all 47 "${OSG_RUNTIME_LIBRARY_DIR}/osgPlugins-${OPENSCENEGRAPH_VERSION}/${filenameprefix}*${CMAKE_SHARED_LIBRARY_SUFFIX}") 48 _osgbundle_split_debug_versions(${varprefix}_PLUGINS_RELEASE 49 ${varprefix}_PLUGINS_DEBUG 50 ${all}) 51 set(${varprefix}_PLUGINS_RELEASE 52 "${${varprefix}_PLUGINS_RELEASE}" 53 PARENT_SCOPE) 54 set(${varprefix}_PLUGINS_DEBUG 55 "${${varprefix}_PLUGINS_DEBUG}" 56 PARENT_SCOPE) 57endfunction() 58 59if(OPENSCENEGRAPH_FOUND) 60 if(WIN32) 61 get_filename_component(_osglibdir "${OSG_LIBRARY}" PATH) 62 get_filename_component(_osgroot "${_osglibdir}/.." ABSOLUTE) 63 set(OSG_RUNTIME_LIBRARY_DIR "${_osgroot}/bin") 64 set(OSG_PATH_TO_PLUGINS "bin/osgPlugins-${OPENSCENEGRAPH_VERSION}/") 65 else() 66 get_filename_component(_osglibdir "${OSG_LIBRARY}" PATH) 67 set(OSG_RUNTIME_LIBRARY_DIR "${_osglibdir}") 68 set(OSG_PATH_TO_PLUGINS "lib/osgPlugins-${OPENSCENEGRAPH_VERSION}/") 69 endif() 70 # Find the osgDB plugins 71 _osgbundle_find_plugins(OSGDB osgdb) 72 _osgbundle_find_plugins(OSGWRAPPER osgwrapper) 73endif() 74 75function(install_osg_plugins var) 76 set(INSTALLEDPLUGINS) 77 foreach(plugin ${OSGDB_PLUGINS_RELEASE} ${OSGWRAPPER_PLUGINS_RELEASE}) 78 install(FILES "${plugin}" 79 DESTINATION "${OSG_PATH_TO_PLUGINS}" 80 CONFIGURATIONS Release RelWithDebInfo MinSizeRel) 81 get_filename_component(name "${plugin}" NAME) 82 list(APPEND INSTALLEDPLUGINS "${OSG_PATH_TO_PLUGINS}/${name}") 83 endforeach() 84 foreach(plugin ${OSGDB_PLUGINS_DEBUG} ${OSGWRAPPER_PLUGINS_DEBUG}) 85 install(FILES 86 "${plugin}" 87 DESTINATION 88 "${OSG_PATH_TO_PLUGINS}" 89 CONFIGURATIONS 90 Debug) 91 #get_filename_component(name "${plugin}" NAME) 92 #list(APPEND INSTALLEDPLUGINS "${OSG_PATH_TO_PLUGINS}/${name}") 93 endforeach() 94 set(${var} ${INSTALLEDPLUGINS} PARENT_SCOPE) 95endfunction() 96