The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 158 lines 6.3 kB view raw
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: 9GenerateKhrManifest 10------------------- 11 12This is a utility module, usually wrapped by more usage-specific modules. 13The general goal is to be able to generate a (JSON) manifest describing targets 14with some absolute, relative, or unspecified path, such as required by the OpenXR 15and Vulkan loaders for runtimes and API layers. 16 17The following functions are provided by this module: 18 19- :command:`generate_khr_manifest_buildtree` 20- :command:`generate_khr_manifest_at_install` 21 22 23.. command:: generate_khr_manifest_buildtree 24 25 Generates a manifest suitable for use in the build tree, 26 with absolute paths, at configure time:: 27 28 generate_khr_manifest_buildtree( 29 MANIFEST_TEMPLATE <template> # The template for your manifest file 30 TARGET <target> # Name of your target (layer, runtime, etc) 31 OUT_FILE <outfile> # Name of the manifest file (with path) to generate 32 MANIFEST_DESCRIPTION "<desc>" # A brief description of the thing we're generating (e.g. "Vulkan API layer manifest") 33 ) 34 35 36.. command:: generate_khr_manifest_at_install 37 38 Generates a manifest at install time and installs it where desired:: 39 40 generate_khr_manifest_at_install( 41 MANIFEST_TEMPLATE <template> # The template for your manifest file 42 TARGET <target> # Name of your target (layer, runtime, etc) 43 DESTINATION <dest> # The install-prefix-relative path to install the manifest to. 44 RELATIVE_TARGET_DIR <dir> # The install-prefix-relative path that the target library is installed to. 45 MANIFEST_DESCRIPTION "<desc>" # A brief description of the thing we're generating (e.g. "Vulkan API layer manifest") 46 [COMPONENT <comp>] # If present, the component to place the manifest in. 47 [ABSOLUTE_TARGET_PATH| # If present, path in generated manifest is absolute 48 TARGET_DIR_RELATIVE_TO_MANIFEST <dir>] 49 # If present (and ABSOLUTE_TARGET_PATH not present), specifies the 50 # target directory relative to the manifest directory in the installed layout 51 [OUT_FILENAME <outfilename> # Optional: Alternate name of the manifest file to generate (defaults to target name + .json) 52 ) 53#]] 54get_filename_component(_KHR_MANIFEST_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" 55 PATH) 56set(_KHR_MANIFEST_SCRIPT 57 "${_KHR_MANIFEST_CMAKE_DIR}/GenerateKhrManifestInternals.cmake.in" 58 CACHE INTERNAL "" FORCE) 59 60function(generate_khr_manifest_buildtree) 61 set(options) 62 set(oneValueArgs MANIFEST_TEMPLATE TARGET OUT_FILE MANIFEST_DESCRIPTION LIBMONADO) 63 set(multiValueArgs) 64 cmake_parse_arguments(_genmanifest "${options}" "${oneValueArgs}" 65 "${multiValueArgs}" ${ARGN}) 66 67 if(NOT _genmanifest_MANIFEST_TEMPLATE) 68 message(FATAL_ERROR "Need MANIFEST_TEMPLATE specified!") 69 endif() 70 if(NOT _genmanifest_TARGET) 71 message(FATAL_ERROR "Need TARGET specified!") 72 endif() 73 if(NOT _genmanifest_OUT_FILE) 74 message(FATAL_ERROR "Need OUT_FILE specified!") 75 endif() 76 if(NOT _genmanifest_MANIFEST_DESCRIPTION) 77 message(FATAL_ERROR "Need MANIFEST_DESCRIPTION specified!") 78 endif() 79 if(_genmanifest_LIBMONADO) 80 set(_libmonado "$<TARGET_FILE:${_genmanifest_LIBMONADO}>") 81 endif() 82 83 # Set template values 84 set(_genmanifest_INTERMEDIATE_MANIFEST 85 ${CMAKE_CURRENT_BINARY_DIR}/intermediate_manifest_buildtree_${_genmanifest_TARGET}.json 86 ) 87 set(_genmanifest_IS_INSTALL OFF) 88 89 set(_script 90 ${CMAKE_CURRENT_BINARY_DIR}/make_build_manifest_${_genmanifest_TARGET}.cmake 91 ) 92 configure_file("${_KHR_MANIFEST_SCRIPT}" "${_script}" @ONLY) 93 add_custom_command( 94 TARGET ${_genmanifest_TARGET} 95 POST_BUILD 96 BYPRODUCTS "${_genmanifest_OUT_FILE}" 97 COMMAND 98 "${CMAKE_COMMAND}" "-DOUT_FILE=${_genmanifest_OUT_FILE}" 99 "-DLIBMONADO=${_libmonado}" 100 "-DTARGET_PATH=$<TARGET_FILE:${_genmanifest_TARGET}>" -P 101 "${_script}" 102 COMMENT 103 "Generating ${_genmanifest_MANIFEST_DESCRIPTION} named ${_genmanifest_OUT_FILE} for build tree usage" 104 VERBATIM 105 ) 106endfunction() 107 108function(generate_khr_manifest_at_install) 109 set(options ABSOLUTE_TARGET_PATH) 110 set(oneValueArgs 111 MANIFEST_TEMPLATE 112 TARGET 113 DESTINATION 114 OUT_FILENAME 115 TARGET_DIR_RELATIVE_TO_MANIFEST 116 RELATIVE_TARGET_DIR 117 MANIFEST_DESCRIPTION 118 COMPONENT 119 LIBMONADO 120 ) 121 set(multiValueArgs) 122 cmake_parse_arguments(_genmanifest "${options}" "${oneValueArgs}" 123 "${multiValueArgs}" ${ARGN}) 124 125 if(NOT _genmanifest_MANIFEST_TEMPLATE) 126 message(FATAL_ERROR "Need MANIFEST_TEMPLATE specified!") 127 endif() 128 if(NOT _genmanifest_TARGET) 129 message(FATAL_ERROR "Need TARGET specified!") 130 endif() 131 if(NOT _genmanifest_DESTINATION) 132 message(FATAL_ERROR "Need DESTINATION specified!") 133 endif() 134 if(NOT _genmanifest_RELATIVE_TARGET_DIR) 135 message(FATAL_ERROR "Need RELATIVE_TARGET_DIR specified!") 136 endif() 137 if(NOT _genmanifest_OUT_FILENAME) 138 set(_genmanifest_OUT_FILENAME "${_genmanifest_TARGET}.json") 139 endif() 140 if(NOT _genmanifest_COMPONENT) 141 set(_genmanifest_COMPONENT Unspecified) 142 endif() 143 set(_genmanifest_INTERMEDIATE_MANIFEST 144 "${CMAKE_CURRENT_BINARY_DIR}/${_genmanifest_OUT_FILENAME}") 145 set(_genmanifest_IS_INSTALL ON) 146 # Template value 147 set(TARGET_FILENAME 148 "${CMAKE_SHARED_MODULE_PREFIX}${_genmanifest_TARGET}${CMAKE_SHARED_MODULE_SUFFIX}" 149 ) 150 if(_genmanifest_LIBMONADO) 151 set(LIBMONADO "${CMAKE_SHARED_MODULE_PREFIX}${_genmanifest_LIBMONADO}${CMAKE_SHARED_MODULE_SUFFIX}") 152 endif() 153 154 set(_script 155 "${CMAKE_CURRENT_BINARY_DIR}/make_manifest_${_genmanifest_TARGET}.cmake") 156 configure_file("${_KHR_MANIFEST_SCRIPT}" "${_script}" @ONLY) 157 install(SCRIPT "${_script}" COMPONENT ${_genmanifest_COMPONENT}) 158endfunction()