2023-12-12 22:29:42 +00:00
|
|
|
# Copyright (c) 2017-2023, The Khronos Group Inc.
|
2023-02-04 10:30:48 +00:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
# Author:
|
|
|
|
#
|
|
|
|
|
|
|
|
# Copy the openxr_platform_defines.h file and place it in the binary (build) directory.
|
|
|
|
configure_file(openxr_platform_defines.h ${CMAKE_CURRENT_BINARY_DIR}/openxr_platform_defines.h COPYONLY)
|
|
|
|
|
|
|
|
# Generate OpenXR header files.
|
2023-04-02 18:41:16 +00:00
|
|
|
# Get the list of generated headers from the common single-point-of-truth
|
|
|
|
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/../generated_header_list.txt HEADERS LENGTH_MINIMUM 8)
|
2023-02-04 10:30:48 +00:00
|
|
|
|
|
|
|
set(HAVE_PREGENERATED TRUE)
|
|
|
|
set(SOURCE_HEADERS)
|
|
|
|
foreach(output ${HEADERS})
|
|
|
|
list(APPEND SOURCE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/${output})
|
|
|
|
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${output})
|
|
|
|
set(HAVE_PREGENERATED FALSE)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set(XR_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
|
|
|
|
if(HAVE_PREGENERATED AND NOT BUILD_FORCE_GENERATION)
|
|
|
|
add_custom_target(generate_openxr_header
|
|
|
|
COMMENT "Using found pre-generated OpenXR headers.")
|
|
|
|
|
|
|
|
set(INSTALL_HEADERS
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/openxr_platform_defines.h
|
|
|
|
${SOURCE_HEADERS})
|
|
|
|
else()
|
|
|
|
|
|
|
|
set(GENERATED_HEADERS)
|
|
|
|
set(OUTPUT_STAMPS)
|
|
|
|
# Copy the openxr_platform_defines.h file and place it in the binary (build) directory.
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openxr_platform_defines.h
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/openxr_platform_defines.h
|
|
|
|
COPYONLY)
|
|
|
|
|
|
|
|
# Generate the header files and place it in the binary (build) directory.
|
2023-04-02 18:41:16 +00:00
|
|
|
file(GLOB _templates LIST_DIRECTORIES false CONFIGURE_DEPENDS ${XR_ROOT}/specification/scripts/template_*)
|
2023-02-04 10:30:48 +00:00
|
|
|
foreach(output ${HEADERS})
|
2023-04-02 18:41:16 +00:00
|
|
|
if("${output}" MATCHES "reflection")
|
|
|
|
set(_extra_deps ${XR_ROOT}/specification/scripts/jinja_helpers.py ${_templates})
|
|
|
|
else()
|
|
|
|
unset(_extra_deps)
|
|
|
|
endif()
|
2023-02-04 10:30:48 +00:00
|
|
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${output}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${XR_ROOT}/specification/scripts/genxr.py
|
|
|
|
-registry ${XR_ROOT}/specification/registry/xr.xml
|
|
|
|
-o ${CMAKE_CURRENT_BINARY_DIR} ${output}
|
|
|
|
DEPENDS
|
|
|
|
${XR_ROOT}/specification/scripts/genxr.py
|
|
|
|
${XR_ROOT}/specification/scripts/cgenerator.py
|
|
|
|
${XR_ROOT}/specification/scripts/creflectiongenerator.py
|
|
|
|
${XR_ROOT}/specification/scripts/generator.py
|
|
|
|
${XR_ROOT}/specification/scripts/reg.py
|
|
|
|
${XR_ROOT}/specification/registry/xr.xml
|
2023-04-02 18:41:16 +00:00
|
|
|
${_extra_deps}
|
2023-02-04 10:30:48 +00:00
|
|
|
COMMENT "Generating ${CMAKE_CURRENT_BINARY_DIR}/${output}"
|
|
|
|
)
|
|
|
|
list(APPEND GENERATED_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/${output}")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set_source_files_properties(
|
|
|
|
${GENERATED_HEADERS}
|
|
|
|
PROPERTIES GENERATED TRUE
|
|
|
|
)
|
|
|
|
|
|
|
|
set(INSTALL_HEADERS
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/openxr_platform_defines.h
|
|
|
|
${GENERATED_HEADERS})
|
|
|
|
|
|
|
|
|
|
|
|
# Define generate_openxr_header target to generate the OpenXR header files.
|
|
|
|
# Other targets that need the OpenXR headers should use generate_openxr_header as a dependency.
|
|
|
|
add_custom_target(generate_openxr_header
|
|
|
|
SOURCES ${XR_ROOT}/specification/registry/xr.xml
|
|
|
|
DEPENDS
|
|
|
|
${GENERATED_HEADERS}
|
|
|
|
${OUTPUT_STAMPS}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
set_target_properties(generate_openxr_header PROPERTIES FOLDER ${CODEGEN_FOLDER})
|
2023-04-02 18:41:16 +00:00
|
|
|
|
|
|
|
# make cache variables for install destinations
|
|
|
|
include(GNUInstallDirs)
|
2023-02-04 10:30:48 +00:00
|
|
|
|
|
|
|
INSTALL(FILES ${INSTALL_HEADERS}
|
2023-04-02 18:41:16 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openxr
|
2023-02-04 10:30:48 +00:00
|
|
|
COMPONENT Headers
|
|
|
|
)
|