Welcome to mirror list, hosted at ThFree Co, Russian Federation.

install-paths.cmake « cmake - github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 32d08a5b96c35555b8047e09a3c8f5d4a147b0ef (plain)
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
# Copyright 2020 The Mumble Developers. All rights reserved.
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file at the root of the
# Mumble source tree or at <https://www.mumble.info/LICENSE>.

include(GNUInstallDirs)

# Turns a path into an absolute path if it isn't absolute already
function(make_absolute out_path in_path)
	get_filename_component(abs_path "${in_path}" ABSOLUTE BASE_DIR "${CMAKE_INSTALL_PREFIX}")
	set(${out_path} "${abs_path}" PARENT_SCOPE)
endfunction()

function(assert_is_relative path)
	make_absolute(abs_path "${path}")

	if("${path}" STREQUAL "${abs_path}")
		message(FATAL_ERROR "Encountered absolute install path but expected a relative one (\"${path}\")")
	endif()
endfunction()


if(UNIX)
	if(APPLE)
		set(EXECUTABLEDIR_DEFAULT ".")
		set(LIBDIR_DEFAULT "${CMAKE_INSTALL_LIBDIR}/mumble")
		set(PLUGINDIR_DEFAULT "${CMAKE_INSTALL_LIBDIR}/mumble/plugins")
		set(SCRIPTDIR_DEFAULT "${CMAKE_INSTALL_BINDIR}")
		set(MANDIR_DEFAULT "${CMAKE_INSTALL_MANDIR}/man1")
		set(DOCDIR_DEFAULT "${CMAKE_INSTALL_DOCDIR}")
		set(LICENSEDIR_DEFAULT "${EXECUTABLEDIR_DEFAULT}/licenses")
	else()
		set(EXECUTABLEDIR_DEFAULT "bin")
		set(LIBDIR_DEFAULT "${CMAKE_INSTALL_LIBDIR}/mumble")
		set(PLUGINDIR_DEFAULT "${CMAKE_INSTALL_LIBDIR}/mumble/plugins")
		set(SCRIPTDIR_DEFAULT "${CMAKE_INSTALL_BINDIR}")
		set(MANDIR_DEFAULT "${CMAKE_INSTALL_MANDIR}/man1")
		set(DOCDIR_DEFAULT "${CMAKE_INSTALL_DOCDIR}")
		set(LICENSEDIR_DEFAULT "${EXECUTABLEDIR_DEFAULT}/licenses")
	endif()
else()
	set(EXECUTABLEDIR_DEFAULT ".")
	# In order for the installer to produce a working version of Mumble, this
	# path must not be changed.
	set(LIBDIR_DEFAULT ".")
	set(PLUGINDIR_DEFAULT "./plugins")
	set(SCRIPTDIR_DEFAULT "./scripts")
	set(MANDIR_DEFAULT "./man1")
	set(DOCDIR_DEFAULT "./docs")
	set(LICENSEDIR_DEFAULT "${EXECUTABLEDIR_DEFAULT}/licenses")
endif()

set(MUMBLE_INSTALL_EXECUTABLEDIR "${EXECUTABLEDIR_DEFAULT}" CACHE PATH "The directory to install the main executable(s) into")
set(MUMBLE_INSTALL_LIBDIR "${LIBDIR_DEFAULT}" CACHE PATH "The directory to install the built libraries into")
set(MUMBLE_INSTALL_PLUGINDIR "${PLUGINDIR_DEFAULT}" CACHE PATH "The directory to install the built plugins into")
set(MUMBLE_INSTALL_SCRIPTDIR "${SCRIPTDIR_DEFAULT}" CACHE PATH "The directory to install any additional scripts into")
set(MUMBLE_INSTALL_MANDIR "${MANDIR_DEFAULT}" CACHE PATH "The directory to install man files into")
set(MUMBLE_INSTALL_DOCDIR "${DOCDIR_DEFAULT}" CACHE PATH "The directory to install documentation files into")
set(MUMBLE_INSTALL_LICENSEDIR "${LICENSEDIR_DEFAULT}" CACHE PATH "The directory to install license files into")

if(packaging)
	# Using absolute install paths doesn't allow CPack to create the installer for us.
	# Therefore we have to make sure that the paths are indeed relative.
	assert_is_relative("${MUMBLE_INSTALL_EXECUTABLEDIR}")
	assert_is_relative("${MUMBLE_INSTALL_LIBDIR}")
	assert_is_relative("${MUMBLE_INSTALL_PLUGINDIR}")
	assert_is_relative("${MUMBLE_INSTALL_SCRIPTDIR}")
	assert_is_relative("${MUMBLE_INSTALL_MANDIR}")
	assert_is_relative("${MUMBLE_INSTALL_DOCDIR}")
	assert_is_relative("${MUMBLE_INSTALL_LICENSEDIR}")

	if(WIN32)
		if(NOT "${MUMBLE_INSTALL_LIBDIR}" STREQUAL "${LIBDIR_DEFAULT}")
			# The path has been altered which will not allow for a working installer to be created
			message(FATAL_ERROR "Found non default MUMBLE_INSTALL_LIBDIR path, that will not result in a working installer! (\"${MUMBLE_INSTALL_LIBDIR}\")")
		endif()
	endif()
else()
	# Turn all install paths into absolute ones as this is required for e.g. shared libraries to be loaded
	make_absolute(MUMBLE_INSTALL_EXECUTABLEDIR "${MUMBLE_INSTALL_EXECUTABLEDIR}")
	make_absolute(MUMBLE_INSTALL_LIBDIR "${MUMBLE_INSTALL_LIBDIR}")
	make_absolute(MUMBLE_INSTALL_PLUGINDIR "${MUMBLE_INSTALL_PLUGINDIR}")
	make_absolute(MUMBLE_INSTALL_SCRIPTDIR "${MUMBLE_INSTALL_SCRIPTDIR}")
	make_absolute(MUMBLE_INSTALL_MANDIR "${MUMBLE_INSTALL_MANDIR}")
	make_absolute(MUMBLE_INSTALL_DOCDIR "${MUMBLE_INSTALL_DOCDIR}")
	make_absolute(MUMBLE_INSTALL_LICENSEDIR "${MUMBLE_INSTALL_LICENSEDIR}")
endif()

option(display-install-paths OFF)

if(display-install-paths)
	message(STATUS "")
	message(STATUS "These are the paths the different components will be installed to:")
	message(STATUS "Executables:    \"${MUMBLE_INSTALL_EXECUTABLEDIR}\"")
	message(STATUS "Libraries:      \"${MUMBLE_INSTALL_LIBDIR}\"")
	message(STATUS "Plugins:        \"${MUMBLE_INSTALL_PLUGINDIR}\"")
	message(STATUS "Scripts:        \"${MUMBLE_INSTALL_SCRIPTDIR}\"")
	message(STATUS "Man-files:      \"${MUMBLE_INSTALL_MANDIR}\"")
	message(STATUS "Documentation:  \"${MUMBLE_INSTALL_DOCDIR}\"")
	message(STATUS "Licenses:       \"${MUMBLE_INSTALL_LICENSEDIR}\"")
	message(STATUS "")
endif()