The open source OpenXR runtime
1# Copyright 2019-2023, Collabora, Ltd.
2#
3# SPDX-License-Identifier: BSL-1.0
4#
5# Maintained by:
6# 2019-2023 Rylie Pavlik <rylie.pavlik@collabora.com> <rylie@ryliepavlik.com>
7
8#[[.rst:
9GenerateVulkanApiLayerManifest
10---------------
11
12The following functions are provided by this module:
13
14- :command:`generate_vulkan_api_layer_manifest_buildtree`
15- :command:`generate_vulkan_api_layer_manifest_at_install`
16
17
18.. command:: generate_vulkan_api_layer_manifest_buildtree
19
20 Generates a layer manifest suitable for use in the build tree,
21 with absolute paths, at configure time::
22
23 generate_vulkan_api_layer_manifest_buildtree(
24 MANIFEST_TEMPLATE <template> # The template for your manifest file
25 LAYER_TARGET <target> # Name of your layer target
26 OUT_FILE <outfile> # Name of the manifest file (with path) to generate
27 )
28
29
30.. command:: generate_vulkan_api_layer_manifest_at_install
31
32 Generates a layer manifest at install time and installs it where desired::
33
34 generate_vulkan_api_layer_manifest_at_install(
35 MANIFEST_TEMPLATE <template> # The template for your manifest file
36 LAYER_TARGET <target> # Name of your layer target
37 DESTINATION <dest> # The install-prefix-relative path to install the manifest to.
38 RELATIVE_LAYER_DIR <dir> # The install-prefix-relative path that the layer library is installed to.
39 [COMPONENT <comp>] # If present, the component to place the manifest in.
40 [ABSOLUTE_LAYER_PATH| # If present, path in generated manifest is absolute
41 LAYER_DIR_RELATIVE_TO_MANIFEST <dir>]
42 # If present (and ABSOLUTE_LAYER_PATH not present), specifies the
43 # layer directory relative to the manifest directory in the installed layout
44 [OUT_FILENAME <outfilename> # Optional: Alternate name of the manifest file to generate
45 )
46#]]
47
48# This module is mostly just argument parsing, the guts are in GenerateKhrManifest
49
50get_filename_component(_VK_MANIFEST_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
51include("${_VK_MANIFEST_CMAKE_DIR}/GenerateKhrManifest.cmake")
52
53function(generate_vulkan_api_layer_manifest_buildtree)
54 set(options)
55 set(oneValueArgs MANIFEST_TEMPLATE LAYER_TARGET OUT_FILE)
56 set(multiValueArgs)
57 cmake_parse_arguments(_genmanifest "${options}" "${oneValueArgs}"
58 "${multiValueArgs}" ${ARGN})
59
60 if(NOT _genmanifest_MANIFEST_TEMPLATE)
61 message(FATAL_ERROR "Need MANIFEST_TEMPLATE specified!")
62 endif()
63 if(NOT _genmanifest_LAYER_TARGET)
64 message(FATAL_ERROR "Need LAYER_TARGET specified!")
65 endif()
66 if(NOT _genmanifest_OUT_FILE)
67 message(FATAL_ERROR "Need OUT_FILE specified!")
68 endif()
69
70 generate_khr_manifest_buildtree(
71 MANIFEST_DESCRIPTION
72 "Vulkan API layer manifest"
73 MANIFEST_TEMPLATE
74 "${_genmanifest_MANIFEST_TEMPLATE}"
75 TARGET
76 "${_genmanifest_LAYER_TARGET}"
77 OUT_FILE
78 "${_genmanifest_OUT_FILE}")
79
80endfunction()
81
82function(generate_vulkan_api_layer_manifest_at_install)
83 set(options ABSOLUTE_LAYER_PATH)
84 set(oneValueArgs
85 MANIFEST_TEMPLATE
86 DESTINATION
87 OUT_FILENAME
88 COMPONENT
89 LAYER_TARGET
90 LAYER_DIR_RELATIVE_TO_MANIFEST
91 RELATIVE_LAYER_DIR)
92 set(multiValueArgs)
93 cmake_parse_arguments(_genmanifest "${options}" "${oneValueArgs}"
94 "${multiValueArgs}" ${ARGN})
95
96 if(NOT _genmanifest_MANIFEST_TEMPLATE)
97 message(FATAL_ERROR "Need MANIFEST_TEMPLATE specified!")
98 endif()
99 if(NOT _genmanifest_LAYER_TARGET)
100 message(FATAL_ERROR "Need LAYER_TARGET specified!")
101 endif()
102 if(NOT _genmanifest_DESTINATION)
103 message(FATAL_ERROR "Need DESTINATION specified!")
104 endif()
105 if(NOT _genmanifest_RELATIVE_LAYER_DIR)
106 message(FATAL_ERROR "Need RELATIVE_LAYER_DIR specified!")
107 endif()
108 if(NOT _genmanifest_OUT_FILENAME)
109 set(_genmanifest_OUT_FILENAME "${_genmanifest_LAYER_TARGET}.json")
110 endif()
111
112 set(_genmanifest_fwdargs)
113
114 if(_genmanifest_ABSOLUTE_LAYER_PATH)
115 list(APPEND _genmanifest_fwdargs ABSOLUTE_TARGET_PATH)
116 endif()
117
118 if(_genmanifest_LAYER_DIR_RELATIVE_TO_MANIFEST)
119 list(APPEND _genmanifest_fwdargs TARGET_DIR_RELATIVE_TO_MANIFEST
120 "${_genmanifest_LAYER_DIR_RELATIVE_TO_MANIFEST}")
121 endif()
122 if(_genmanifest_COMPONENT)
123 list(APPEND _genmanifest_fwdargs COMPONENT "${_genmanifest_COMPONENT}")
124 endif()
125
126 generate_khr_manifest_at_install(
127 ${_genmanifest_fwdargs}
128 MANIFEST_DESCRIPTION
129 "Vulkan API layer manifest"
130 MANIFEST_TEMPLATE
131 "${_genmanifest_MANIFEST_TEMPLATE}"
132 TARGET
133 "${_genmanifest_LAYER_TARGET}"
134 DESTINATION
135 "${_genmanifest_DESTINATION}"
136 RELATIVE_TARGET_DIR
137 "${_genmanifest_RELATIVE_LAYER_DIR}"
138 OUT_FILENAME
139 "${_genmanifest_OUT_FILENAME}")
140endfunction()