summaryrefslogtreecommitdiffstats
path: root/cmake/ConfigurePaths.cmake
blob: 3f45a1936346a3f5e62296489aea70774a8782df (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
# - pre-configured paths for CMake
#
# Usage:
#   configure_paths(<PREFIX>)
#
# Checks if configure-like prefix and installation paths were passed by the user
# and sets up corresponding variables for use in install() commands and to fill
# out .pc files:
#
#   PREFIX_PREFIX       defaults to ...     CMAKE_INSTALL_PREFIX
#   PREFIX_EPREFIX                          PREFIX_PREFIX
#   PREFIX_SBINDIR                          PREFIX_EPREFIX/sbin
#   PREFIX_SYSCONFDIR                       PREFIX_PREFIX/etc
#   PREFIX_LOCALSTATEDIR                    PREFIX_PREFIX/var
#   PREFIX_BINDIR                           PREFIX_EPREFIX/bin
#   PREFIX_LIBDIR                           PREFIX_EPREFIX/lib
#   PREFIX_INCLUDEDIR                       PREFIX_PREFIX/include
#   PREFIX_PKGCONFIGDIR                     PREFIX_LIBDIR/pkgconfig
#   PREFIX_TYPELIBDIR                       PREFIX_LIBDIR/girepository-1.0
#   PREFIX_DATAROOTDIR                      PREFIX_PREFIX/share
#   PREFIX_DATADIR                          PREFIX_DATAROOTDIR
#   PREFIX_INFODIR                          PREFIX_DATAROOTDIR/info
#   PREFIX_MANDIR                           PREFIX_DATAROOTDIR/man
#   PREFIX_LOCALEDIR                        PREFIX_DATAROOTDIR/locale
#   PREFIX_GIRDIR                           PREFIX_DATAROOTDIR/gir-1.0

# Copyright (C) 2013 Matthias Vogelgesang <matthias.vogelgesang@gmail.com>
#
# Redistribution and use, with or without modification, are permitted
# provided that the following conditions are met:
# 
#    1. Redistributions must retain the above copyright notice, this
#       list of conditions and the following disclaimer.
#    2. The name of the author may not be used to endorse or promote
#       products derived from this software without specific prior
#       written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


if(__configure_paths)
    return()
endif()

set(__configure_paths YES)

macro(_set_var _prefix _var _user _override _description)
    set(_name "${_prefix}_${_var}")

    set("${_name}" "${_user}")

    if("${_name}" STREQUAL "")
        set("${_name}" "${_override}")
    endif()

    set(${_name} "${${_name}}" CACHE PATH "${_description}")
    mark_as_advanced(${_name})
endmacro()

function(configure_paths _prefix)
    _set_var("${_prefix}" "PREFIX"          "${PREFIX}"         "${CMAKE_INSTALL_PREFIX}"               "install architecture-independent files in PREFIX")
    _set_var("${_prefix}" "EPREFIX"         "${EXEC_PREFIX}"    "${${_prefix}_PREFIX}"                  "install architecture-dependent files in EPREFIX")

    _set_var("${_prefix}" "SBINDIR"         "${SBINDIR}"        "${${_prefix}_EPREFIX}/sbin"            "system admin executabls")
    _set_var("${_prefix}" "SYSCONFDIR"      "${SYSCONFDIR}"     "${${_prefix}_PREFIX}/etc"              "read-only single-machine data")
    _set_var("${_prefix}" "LOCALSTATEDIR"   "${LOCALSTATEDIR}"  "${${_prefix}_PREFIX}/var"              "modifiable single-machine data")
    _set_var("${_prefix}" "BINDIR"          "${BINDIR}"         "${${_prefix}_EPREFIX}/bin"             "user executables")
	IF(WIN32)
		_set_var("${_prefix}" "LIBDIR"          "${LIBDIR}"         "${${_prefix}_EPREFIX}/bin"             "object code libraries")
	ELSE()
		_set_var("${_prefix}" "LIBDIR"          "${LIBDIR}"         "${${_prefix}_EPREFIX}/lib"             "object code libraries")
	ENDIF()
    _set_var("${_prefix}" "INCLUDEDIR"      "${INCLUDEDIR}"     "${${_prefix}_PREFIX}/include"          "C header files")
    _set_var("${_prefix}" "PKGCONFIGDIR"    "${PKGCONFIGDIR}"   "${${_prefix}_LIBDIR}/pkgconfig"        "pkg-config files")
    _set_var("${_prefix}" "TYPELIBDIR"      "${TYPELIBDIR}"     "${${_prefix}_LIBDIR}/girepository-1.0" "GObject run-time introspection data")
    _set_var("${_prefix}" "DATAROOTDIR"     "${DATAROOTDIR}"    "${${_prefix}_PREFIX}/share"            "read-only arch.-independent data root")
    _set_var("${_prefix}" "DATADIR"         "${DATADIR}"        "${${_prefix}_DATAROOTDIR}"             "read-only architecture-independent data")
    _set_var("${_prefix}" "INFODIR"         "${INFODIR}"        "${${_prefix}_DATAROOTDIR}/info"        "info documentation")
    _set_var("${_prefix}" "MANDIR"          "${MANDIR}"         "${${_prefix}_DATAROOTDIR}/man"         "man documentation")
    _set_var("${_prefix}" "LOCALEDIR"       "${LOCALEDIR}"      "${${_prefix}_DATAROOTDIR}/locale"      "locale-dependent data")
    _set_var("${_prefix}" "GIRDIR"          "${GIRDIR}"         "${${_prefix}_DATAROOTDIR}/gir-1.0"     "GObject introspection data")
endfunction()

# vim: tw=0: