File: GenerateOpenXRRuntimeManifest.cmake

package info (click to toggle)
freespace2 25.0.0%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 47,232 kB
  • sloc: cpp: 657,500; ansic: 22,305; sh: 293; python: 200; makefile: 198; xml: 181
file content (145 lines) | stat: -rw-r--r-- 5,333 bytes parent folder | download | duplicates (2)
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Copyright 2019-2023, Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
#
# Maintained by:
# 2019-2023 Rylie Pavlik <rylie.pavlik@collabora.com> <rylie@ryliepavlik.com>

#[[.rst:
GenerateOpenXRRuntimeManifest
---------------

The following functions are provided by this module:

- :command:`generate_openxr_runtime_manifest_buildtree`
- :command:`generate_openxr_runtime_manifest_at_install`


.. command:: generate_openxr_runtime_manifest_buildtree

  Generates a runtime manifest suitable for use in the build tree,
  with absolute paths, at configure time::

    generate_openxr_runtime_manifest_buildtree(
        RUNTIME_TARGET <target>          # Name of your runtime target
        OUT_FILE <outfile>               # Name of the manifest file (with path) to generate
        [MANIFEST_TEMPLATE <template>]   # Optional: Specify an alternate template to use
        )


.. command:: generate_openxr_runtime_manifest_at_install

  Generates a runtime manifest at install time and installs it where desired::

    generate_openxr_runtime_manifest_buildtree(
        RUNTIME_TARGET <target>            # Name of your runtime target
        DESTINATION <dest>                 # The install-prefix-relative path to install the manifest to.
        RELATIVE_RUNTIME_DIR <dir>         # The install-prefix-relative path that the runtime library is installed to.
        [COMPONENT <comp>]                 # If present, the component to place the manifest in.
        [ABSOLUTE_RUNTIME_PATH|            # If present, path in generated manifest is absolute
         RUNTIME_DIR_RELATIVE_TO_MANIFEST <dir>]
                                           # If present (and ABSOLUTE_RUNTIME_PATH not present), specifies the
                                           # runtime directory relative to the manifest directory in the installed layout
        [OUT_FILENAME <outfilename>        # Optional: Alternate name of the manifest file to generate
        [MANIFEST_TEMPLATE <template>]     # Optional: Specify an alternate template to use
        )
#]]

# This module is mostly just argument parsing, the guts are in GenerateKhrManifest

get_filename_component(_OXR_MANIFEST_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}"
                       PATH)
include("${_OXR_MANIFEST_CMAKE_DIR}/GenerateKhrManifest.cmake")

set(_OXR_MANIFEST_TEMPLATE
    "${_OXR_MANIFEST_CMAKE_DIR}/openxr_manifest.in.json"
    CACHE INTERNAL "" FORCE)

function(generate_openxr_runtime_manifest_buildtree)
    set(options)
    set(oneValueArgs MANIFEST_TEMPLATE RUNTIME_TARGET OUT_FILE)
    set(multiValueArgs)
    cmake_parse_arguments(_genmanifest "${options}" "${oneValueArgs}"
                          "${multiValueArgs}" ${ARGN})

    if(NOT _genmanifest_MANIFEST_TEMPLATE)
        set(_genmanifest_MANIFEST_TEMPLATE "${_OXR_MANIFEST_TEMPLATE}")
    endif()
    if(NOT _genmanifest_RUNTIME_TARGET)
        message(FATAL_ERROR "Need RUNTIME_TARGET specified!")
    endif()
    if(NOT _genmanifest_OUT_FILE)
        message(FATAL_ERROR "Need OUT_FILE specified!")
    endif()

    generate_khr_manifest_buildtree(
        MANIFEST_DESCRIPTION
        "OpenXR runtime manifest"
        MANIFEST_TEMPLATE
        "${_genmanifest_MANIFEST_TEMPLATE}"
        TARGET
        "${_genmanifest_RUNTIME_TARGET}"
        OUT_FILE
        "${_genmanifest_OUT_FILE}")

endfunction()

function(generate_openxr_runtime_manifest_at_install)
    set(options ABSOLUTE_RUNTIME_PATH)
    set(oneValueArgs
        MANIFEST_TEMPLATE
        DESTINATION
        OUT_FILENAME
        COMPONENT
        RUNTIME_TARGET
        RUNTIME_DIR_RELATIVE_TO_MANIFEST
        RELATIVE_RUNTIME_DIR)
    set(multiValueArgs)
    cmake_parse_arguments(_genmanifest "${options}" "${oneValueArgs}"
                          "${multiValueArgs}" ${ARGN})

    if(NOT _genmanifest_MANIFEST_TEMPLATE)
        set(_genmanifest_MANIFEST_TEMPLATE "${_OXR_MANIFEST_TEMPLATE}")
    endif()
    if(NOT _genmanifest_RUNTIME_TARGET)
        message(FATAL_ERROR "Need RUNTIME_TARGET specified!")
    endif()
    if(NOT _genmanifest_DESTINATION)
        message(FATAL_ERROR "Need DESTINATION specified!")
    endif()
    if(NOT _genmanifest_RELATIVE_RUNTIME_DIR)
        message(FATAL_ERROR "Need RELATIVE_RUNTIME_DIR specified!")
    endif()
    if(NOT _genmanifest_OUT_FILENAME)
        set(_genmanifest_OUT_FILENAME "${_genmanifest_RUNTIME_TARGET}.json")
    endif()

    set(_genmanifest_fwdargs)

    if(_genmanifest_ABSOLUTE_RUNTIME_PATH)
        list(APPEND _genmanifest_fwdargs ABSOLUTE_TARGET_PATH)
    endif()

    if(_genmanifest_RUNTIME_DIR_RELATIVE_TO_MANIFEST)
        list(APPEND _genmanifest_fwdargs TARGET_DIR_RELATIVE_TO_MANIFEST
             "${_genmanifest_RUNTIME_DIR_RELATIVE_TO_MANIFEST}")
    endif()
    if(_genmanifest_COMPONENT)
        list(APPEND _genmanifest_fwdargs COMPONENT "${_genmanifest_COMPONENT}")
    endif()

    generate_khr_manifest_at_install(
        ${_genmanifest_fwdargs}
        MANIFEST_DESCRIPTION
        "OpenXR runtime manifest"
        MANIFEST_TEMPLATE
        "${_genmanifest_MANIFEST_TEMPLATE}"
        TARGET
        "${_genmanifest_RUNTIME_TARGET}"
        DESTINATION
        "${_genmanifest_DESTINATION}"
        RELATIVE_TARGET_DIR
        "${_genmanifest_RELATIVE_RUNTIME_DIR}"
        OUT_FILENAME
        "${_genmanifest_OUT_FILENAME}")
endfunction()