Update glslang's tnt/CMakeLists.txt (#4348)
This commit is contained in:
40
third_party/glslang/tnt/CMakeLists.txt
vendored
40
third_party/glslang/tnt/CMakeLists.txt
vendored
@@ -58,53 +58,33 @@ endfunction(glslang_set_link_args)
|
||||
# message(STATUS "spirv-tools not linked - illegal SPIRV may be generated for HLSL")
|
||||
# endif()
|
||||
|
||||
find_package(PythonInterp 3 REQUIRED)
|
||||
|
||||
# Root directory for build-time generated include files
|
||||
set(GLSLANG_GENERATED_INCLUDEDIR "${CMAKE_BINARY_DIR}/include")
|
||||
|
||||
################################################################################
|
||||
# Build version information generation
|
||||
################################################################################
|
||||
include("../parse_version.cmake")
|
||||
set(GLSLANG_CHANGES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../CHANGES.md")
|
||||
set(GLSLANG_BUILD_INFO_PY "${CMAKE_CURRENT_SOURCE_DIR}/../build_info.py")
|
||||
set(GLSLANG_BUILD_INFO_H_TMPL "${CMAKE_CURRENT_SOURCE_DIR}/../build_info.h.tmpl")
|
||||
set(GLSLANG_BUILD_INFO_H "${GLSLANG_GENERATED_INCLUDEDIR}/glslang/build_info.h")
|
||||
|
||||
# Command to build the build_info.h file
|
||||
add_custom_command(
|
||||
OUTPUT ${GLSLANG_BUILD_INFO_H}
|
||||
COMMAND ${PYTHON_EXECUTABLE} "${GLSLANG_BUILD_INFO_PY}"
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
"-i" ${GLSLANG_BUILD_INFO_H_TMPL}
|
||||
"-o" ${GLSLANG_BUILD_INFO_H}
|
||||
DEPENDS ${GLSLANG_BUILD_INFO_PY}
|
||||
${GLSLANG_CHANGES_FILE}
|
||||
${GLSLANG_BUILD_INFO_H_TMPL}
|
||||
COMMENT "Generating ${GLSLANG_BUILD_INFO_H}")
|
||||
parse_version(${GLSLANG_CHANGES_FILE} GLSLANG)
|
||||
|
||||
# Target to build the build_info.h file
|
||||
add_custom_target(glslang-build-info DEPENDS ${GLSLANG_BUILD_INFO_H})
|
||||
function(configurate_version)
|
||||
set(major ${GLSLANG_VERSION_MAJOR})
|
||||
set(minor ${GLSLANG_VERSION_MINOR})
|
||||
set(patch ${GLSLANG_VERSION_PATCH})
|
||||
set(flavor ${GLSLANG_VERSION_FLAVOR})
|
||||
configure_file(${GLSLANG_BUILD_INFO_H_TMPL} ${GLSLANG_BUILD_INFO_H} @ONLY)
|
||||
endfunction()
|
||||
|
||||
# Populate the CMake GLSLANG_VERSION* variables with the build version
|
||||
# information.
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE} "${GLSLANG_BUILD_INFO_PY}"
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/.. "<major>.<minor>.<patch><-flavor>;<major>;<minor>;<patch>;<flavor>"
|
||||
OUTPUT_VARIABLE "GLSLANG_VERSIONS"
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
list(GET "GLSLANG_VERSIONS" 0 "GLSLANG_VERSION")
|
||||
list(GET "GLSLANG_VERSIONS" 1 "GLSLANG_VERSION_MAJOR")
|
||||
list(GET "GLSLANG_VERSIONS" 2 "GLSLANG_VERSION_MINOR")
|
||||
list(GET "GLSLANG_VERSIONS" 3 "GLSLANG_VERSION_PATCH")
|
||||
list(GET "GLSLANG_VERSIONS" 4 "GLSLANG_VERSION_FLAVOR")
|
||||
configure_file(${GLSLANG_CHANGES_FILE} "${CMAKE_CURRENT_BINARY_DIR}/CHANGES.md") # Required to re-run cmake on version change
|
||||
configurate_version()
|
||||
|
||||
# glslang_add_build_info_dependency() adds the glslang-build-info dependency and
|
||||
# generated include directories to target.
|
||||
function(glslang_add_build_info_dependency target)
|
||||
target_include_directories(${target} PUBLIC $<BUILD_INTERFACE:${GLSLANG_GENERATED_INCLUDEDIR}>)
|
||||
add_dependencies(${target} glslang-build-info)
|
||||
endfunction()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user