File: BundleOSGRuntime.cmake

package info (click to toggle)
freespace2 24.0.2%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: trixie
  • size: 43,188 kB
  • sloc: cpp: 583,107; ansic: 21,729; python: 1,174; sh: 464; makefile: 248; xml: 181
file content (118 lines) | stat: -rw-r--r-- 3,361 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# - Include the OpenSceneGraph runtime files in an installation or built package.
#
#  OSGRUNTIME_BUNDLE - Set to "yes" to enable this behavior
#  OSGRUNTIME_zlib1dll - Must be set to the location of zlib1.dll on Windows
#  OSGRUNTIME_zlib1ddll - Can be set to the location of zlib1d.dll (debug) on Windows.
#                         If set, will be installed.
#
# Requires these CMake modules:
#  no additional modules required
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

function(_osgbundle_split_debug_versions releasevar debugvar)
	set(release)
	set(debug)
	foreach(fn ${ARGN})
		get_filename_component(name "${fn}" NAME_WE)
		if(${name} MATCHES "d$")
			list(APPEND debug "${fn}")
		else()
			list(APPEND release "${fn}")
		endif()
	endforeach()
	set(${releasevar} ${release} PARENT_SCOPE)
	set(${debugvar} ${debug} PARENT_SCOPE)
endfunction()

function(_osgbundle_find_plugins varprefix filenameprefix)
	file(GLOB
		all
		"${OSG_RUNTIME_LIBRARY_DIR}/osgPlugins-${OPENSCENEGRAPH_VERSION}/${filenameprefix}*${CMAKE_SHARED_LIBRARY_SUFFIX}")
	_osgbundle_split_debug_versions(${varprefix}_PLUGINS_RELEASE
		${varprefix}_PLUGINS_DEBUG
		${all})
endfunction()

if(OPENSCENEGRAPH_FOUND)
	if(WIN32)
		get_filename_component(_osglibdir "${OSG_LIBRARY}" PATH)
		get_filename_component(_osgroot "${_osglibdir}/.." ABSOLUTE)
		set(OSG_RUNTIME_LIBRARY_DIR "${_osgroot}/bin")
		find_file(OSGBUNDLE_zlib1dll
			zlib1.dll
			PATHS
			"${_osgroot}/bin"
			"${_osgroot}/lib")
		find_file(OSGBUNDLE_zlib1ddll
			zlib1d.dll
			PATHS
			"${_osgroot}/bin"
			"${_osgroot}/lib")
		mark_as_advanced(OSGBUNDLE_zlib1dll OSGBUNDLE_zlib1ddll)
		set(_osgbundle_required OSGBUNDLE_zlib1dll)
		set(_osgbundle_platformOK on)
	else()
		get_filename_component(_osglibdir "${OSG_LIBRARY}" PATH)
		set(OSG_RUNTIME_LIBRARY_DIR "${_osglibdir}")
		set(_osgbundle_platformOK on)
	endif()

	# Find the osgDB plugins

	_osgbundle_find_plugins(OSGDB osgdb)
	_osgbundle_find_plugins(OSGWRAPPER osgwrapper)
endif()



if(_osgbundle_platformOK)
	set(_osgbundle_caninstall on)
	foreach(_var ${_osgbundle_required})
		if(NOT ${_var})
			# If we are missing a single required file, cut out now.
			set(_osgbundle_caninstall off)
			option(OSGRUNTIME_BUNDLE
				"Install a local copy of the OpenSceneGraph runtime files with the project."
				off)
		endif()
	endforeach()
	if(_osgbundle_caninstall)
		option(OSGRUNTIME_BUNDLE
			"Install a local copy of the OpenSceneGraph runtime files with the project."
			on)
	endif()
endif()

mark_as_advanced(OSGRUNTIME_BUNDLE)

if(OSGRUNTIME_BUNDLE AND OPENSCENEGRAPH_FOUND AND _osgbundle_caninstall)
	if(WIN32)
		set(DESTINATION bin)
		install(FILES "${OSGBUNDLE_zlib1dll}"
			DESTINATION ${DESTINATION})

		if(OSGBUNDLE_zlib1ddll)
			install(FILES "${OSGBUNDLE_zlib1ddll}"
				DESTINATION ${DESTINATION})
		endif()

	else()
		set(DESTINATION lib)
	endif()

	install(DIRECTORY "${_osgroot}/bin/" "${_osgroot}/lib/"
		DESTINATION ${DESTINATION}
		FILES_MATCHING

		# Runtime files
		PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()