2016-03-17 02:43:31 +00:00
|
|
|
# Copyright (c) 2015-2016 The Khronos Group Inc.
|
|
|
|
#
|
2016-09-01 19:33:59 +00:00
|
|
|
# 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
|
2016-03-17 02:43:31 +00:00
|
|
|
#
|
2016-09-01 19:33:59 +00:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2016-03-17 02:43:31 +00:00
|
|
|
#
|
2016-09-01 19:33:59 +00:00
|
|
|
# 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.
|
2016-03-17 02:43:31 +00:00
|
|
|
|
2016-04-15 16:51:55 +00:00
|
|
|
set(GRAMMAR_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/generate_grammar_tables.py")
|
2016-12-16 20:32:56 +00:00
|
|
|
set(VIMSYNTAX_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/generate_vim_syntax.py")
|
2016-12-09 19:01:43 +00:00
|
|
|
set(XML_REGISTRY_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/generate_registry_tables.py")
|
2017-12-03 17:30:08 +00:00
|
|
|
set(LANG_HEADER_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/generate_language_headers.py")
|
|
|
|
|
|
|
|
# For now, assume the DebugInfo grammar file is in the current directory.
|
|
|
|
# It might migrate to SPIRV-Headers.
|
2020-07-30 16:08:53 +00:00
|
|
|
set(DEBUGINFO_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/unified1/extinst.debuginfo.grammar.json")
|
|
|
|
set(CLDEBUGINFO100_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json")
|
2016-04-15 16:51:55 +00:00
|
|
|
|
|
|
|
# macro() definitions are used in the following because we need to append .inc
|
|
|
|
# file paths into some global lists (*_CPP_DEPENDS). And those global lists are
|
|
|
|
# later used by set_source_files_properties() calls.
|
|
|
|
# function() definitions are not suitable because they create new scopes.
|
2018-11-26 15:37:30 +00:00
|
|
|
macro(spvtools_core_tables CONFIG_VERSION)
|
|
|
|
set(GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/spirv.core.grammar.json")
|
|
|
|
set(GRAMMAR_INSTS_INC_FILE "${spirv-tools_BINARY_DIR}/core.insts-${CONFIG_VERSION}.inc")
|
|
|
|
set(GRAMMAR_KINDS_INC_FILE "${spirv-tools_BINARY_DIR}/operand.kinds-${CONFIG_VERSION}.inc")
|
2016-04-15 16:51:55 +00:00
|
|
|
add_custom_command(OUTPUT ${GRAMMAR_INSTS_INC_FILE} ${GRAMMAR_KINDS_INC_FILE}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT}
|
|
|
|
--spirv-core-grammar=${GRAMMAR_JSON_FILE}
|
2017-12-03 17:30:08 +00:00
|
|
|
--extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE}
|
2019-12-19 22:16:26 +00:00
|
|
|
--extinst-cldebuginfo100-grammar=${CLDEBUGINFO100_GRAMMAR_JSON_FILE}
|
2016-04-15 16:51:55 +00:00
|
|
|
--core-insts-output=${GRAMMAR_INSTS_INC_FILE}
|
|
|
|
--operand-kinds-output=${GRAMMAR_KINDS_INC_FILE}
|
2019-12-19 22:16:26 +00:00
|
|
|
DEPENDS ${GRAMMAR_PROCESSING_SCRIPT}
|
|
|
|
${GRAMMAR_JSON_FILE}
|
|
|
|
${DEBUGINFO_GRAMMAR_JSON_FILE}
|
|
|
|
${CLDEBUGINFO100_GRAMMAR_JSON_FILE}
|
2018-11-26 15:37:30 +00:00
|
|
|
COMMENT "Generate info tables for SPIR-V v${CONFIG_VERSION} core instructions and operands.")
|
2016-04-15 16:51:55 +00:00
|
|
|
list(APPEND OPCODE_CPP_DEPENDS ${GRAMMAR_INSTS_INC_FILE})
|
|
|
|
list(APPEND OPERAND_CPP_DEPENDS ${GRAMMAR_KINDS_INC_FILE})
|
|
|
|
endmacro(spvtools_core_tables)
|
|
|
|
|
2018-11-26 15:37:30 +00:00
|
|
|
macro(spvtools_enum_string_mapping CONFIG_VERSION)
|
|
|
|
set(GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/spirv.core.grammar.json")
|
2017-03-15 21:28:24 +00:00
|
|
|
set(GRAMMAR_EXTENSION_ENUM_INC_FILE "${spirv-tools_BINARY_DIR}/extension_enum.inc")
|
|
|
|
set(GRAMMAR_ENUM_STRING_MAPPING_INC_FILE "${spirv-tools_BINARY_DIR}/enum_string_mapping.inc")
|
|
|
|
add_custom_command(OUTPUT ${GRAMMAR_EXTENSION_ENUM_INC_FILE}
|
|
|
|
${GRAMMAR_ENUM_STRING_MAPPING_INC_FILE}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT}
|
|
|
|
--spirv-core-grammar=${GRAMMAR_JSON_FILE}
|
2017-12-03 17:30:08 +00:00
|
|
|
--extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE}
|
2019-12-19 22:16:26 +00:00
|
|
|
--extinst-cldebuginfo100-grammar=${CLDEBUGINFO100_GRAMMAR_JSON_FILE}
|
2017-03-15 21:28:24 +00:00
|
|
|
--extension-enum-output=${GRAMMAR_EXTENSION_ENUM_INC_FILE}
|
|
|
|
--enum-string-mapping-output=${GRAMMAR_ENUM_STRING_MAPPING_INC_FILE}
|
2019-12-19 22:16:26 +00:00
|
|
|
DEPENDS ${GRAMMAR_PROCESSING_SCRIPT}
|
|
|
|
${GRAMMAR_JSON_FILE}
|
|
|
|
${DEBUGINFO_GRAMMAR_JSON_FILE}
|
|
|
|
${CLDEBUGINFO100_GRAMMAR_JSON_FILE}
|
2018-11-26 15:37:30 +00:00
|
|
|
COMMENT "Generate enum-string mapping for SPIR-V v${CONFIG_VERSION}.")
|
2017-03-15 21:28:24 +00:00
|
|
|
list(APPEND EXTENSION_H_DEPENDS ${GRAMMAR_EXTENSION_ENUM_INC_FILE})
|
|
|
|
list(APPEND ENUM_STRING_MAPPING_CPP_DEPENDS ${GRAMMAR_ENUM_STRING_MAPPING_INC_FILE})
|
|
|
|
endmacro(spvtools_enum_string_mapping)
|
|
|
|
|
2018-11-26 15:37:30 +00:00
|
|
|
macro(spvtools_vimsyntax CONFIG_VERSION CLVERSION)
|
|
|
|
set(GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/spirv.core.grammar.json")
|
|
|
|
set(GLSL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/extinst.glsl.std.450.grammar.json")
|
|
|
|
set(OPENCL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/extinst.opencl.std.100.grammar.json")
|
2016-12-16 20:32:56 +00:00
|
|
|
set(VIMSYNTAX_FILE "${spirv-tools_BINARY_DIR}/spvasm.vim")
|
|
|
|
add_custom_command(OUTPUT ${VIMSYNTAX_FILE}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${VIMSYNTAX_PROCESSING_SCRIPT}
|
|
|
|
--spirv-core-grammar=${GRAMMAR_JSON_FILE}
|
2018-02-08 17:05:40 +00:00
|
|
|
--extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE}
|
2016-12-16 20:32:56 +00:00
|
|
|
--extinst-glsl-grammar=${GLSL_GRAMMAR_JSON_FILE}
|
|
|
|
--extinst-opencl-grammar=${OPENCL_GRAMMAR_JSON_FILE}
|
|
|
|
>${VIMSYNTAX_FILE}
|
|
|
|
DEPENDS ${VIMSYNTAX_PROCESSING_SCRIPT} ${GRAMMAR_JSON_FILE}
|
2017-12-03 17:30:08 +00:00
|
|
|
${GLSL_GRAMMAR_JSON_FILE} ${OPENCL_GRAMMAR_JSON_FILE} ${DEBUGINFO_GRAMMAR_JSON_FILE}
|
2016-12-16 20:32:56 +00:00
|
|
|
COMMENT "Generate spvasm.vim: Vim syntax file for SPIR-V assembly.")
|
|
|
|
endmacro(spvtools_vimsyntax)
|
|
|
|
|
2018-11-26 15:37:30 +00:00
|
|
|
macro(spvtools_glsl_tables CONFIG_VERSION)
|
|
|
|
set(CORE_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/spirv.core.grammar.json")
|
|
|
|
set(GLSL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/extinst.glsl.std.450.grammar.json")
|
2017-12-13 22:55:00 +00:00
|
|
|
set(GRAMMAR_INC_FILE "${spirv-tools_BINARY_DIR}/glsl.std.450.insts.inc")
|
2016-04-15 16:51:55 +00:00
|
|
|
add_custom_command(OUTPUT ${GRAMMAR_INC_FILE}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT}
|
|
|
|
--extinst-glsl-grammar=${GLSL_GRAMMAR_JSON_FILE}
|
|
|
|
--glsl-insts-output=${GRAMMAR_INC_FILE}
|
|
|
|
DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} ${CORE_GRAMMAR_JSON_FILE} ${GLSL_GRAMMAR_JSON_FILE}
|
2018-11-26 15:37:30 +00:00
|
|
|
COMMENT "Generate info tables for GLSL extended instructions and operands v${CONFIG_VERSION}.")
|
2016-04-15 16:51:55 +00:00
|
|
|
list(APPEND EXTINST_CPP_DEPENDS ${GRAMMAR_INC_FILE})
|
|
|
|
endmacro(spvtools_glsl_tables)
|
|
|
|
|
2018-11-26 15:37:30 +00:00
|
|
|
macro(spvtools_opencl_tables CONFIG_VERSION)
|
|
|
|
set(CORE_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/spirv.core.grammar.json")
|
|
|
|
set(OPENCL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/extinst.opencl.std.100.grammar.json")
|
2017-12-13 22:55:00 +00:00
|
|
|
set(GRAMMAR_INC_FILE "${spirv-tools_BINARY_DIR}/opencl.std.insts.inc")
|
2016-04-15 16:51:55 +00:00
|
|
|
add_custom_command(OUTPUT ${GRAMMAR_INC_FILE}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT}
|
|
|
|
--extinst-opencl-grammar=${OPENCL_GRAMMAR_JSON_FILE}
|
|
|
|
--opencl-insts-output=${GRAMMAR_INC_FILE}
|
|
|
|
DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} ${CORE_GRAMMAR_JSON_FILE} ${OPENCL_GRAMMAR_JSON_FILE}
|
2018-11-26 15:37:30 +00:00
|
|
|
COMMENT "Generate info tables for OpenCL extended instructions and operands v${CONFIG_VERSION}.")
|
2016-04-15 16:51:55 +00:00
|
|
|
list(APPEND EXTINST_CPP_DEPENDS ${GRAMMAR_INC_FILE})
|
|
|
|
endmacro(spvtools_opencl_tables)
|
|
|
|
|
2019-12-19 22:16:26 +00:00
|
|
|
macro(spvtools_vendor_tables VENDOR_TABLE SHORT_NAME OPERAND_KIND_PREFIX)
|
2017-03-21 16:43:26 +00:00
|
|
|
set(INSTS_FILE "${spirv-tools_BINARY_DIR}/${VENDOR_TABLE}.insts.inc")
|
2020-07-30 16:08:53 +00:00
|
|
|
set(GRAMMAR_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/unified1/extinst.${VENDOR_TABLE}.grammar.json")
|
2017-03-21 16:43:26 +00:00
|
|
|
add_custom_command(OUTPUT ${INSTS_FILE}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT}
|
|
|
|
--extinst-vendor-grammar=${GRAMMAR_FILE}
|
|
|
|
--vendor-insts-output=${INSTS_FILE}
|
2019-12-19 22:16:26 +00:00
|
|
|
--vendor-operand-kind-prefix=${OPERAND_KIND_PREFIX}
|
2017-03-21 16:43:26 +00:00
|
|
|
DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} ${GRAMMAR_FILE}
|
|
|
|
COMMENT "Generate extended instruction tables for ${VENDOR_TABLE}.")
|
2019-04-18 17:22:28 +00:00
|
|
|
add_custom_target(spv-tools-${SHORT_NAME} DEPENDS ${INSTS_FILE})
|
|
|
|
set_property(TARGET spv-tools-${SHORT_NAME} PROPERTY FOLDER "SPIRV-Tools build")
|
|
|
|
list(APPEND EXTINST_CPP_DEPENDS spv-tools-${SHORT_NAME})
|
2017-03-21 16:43:26 +00:00
|
|
|
endmacro(spvtools_vendor_tables)
|
|
|
|
|
2017-12-03 17:30:08 +00:00
|
|
|
macro(spvtools_extinst_lang_headers NAME GRAMMAR_FILE)
|
2020-02-25 05:46:52 +00:00
|
|
|
set(OUT_H ${spirv-tools_BINARY_DIR}/${NAME}.h)
|
2017-12-03 17:30:08 +00:00
|
|
|
add_custom_command(OUTPUT ${OUT_H}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${LANG_HEADER_PROCESSING_SCRIPT}
|
|
|
|
--extinst-grammar=${GRAMMAR_FILE}
|
2020-02-25 05:46:52 +00:00
|
|
|
--extinst-output-path=${OUT_H}
|
2017-12-03 17:30:08 +00:00
|
|
|
DEPENDS ${LANG_HEADER_PROCESSING_SCRIPT} ${GRAMMAR_FILE}
|
|
|
|
COMMENT "Generate language specific header for ${NAME}.")
|
|
|
|
add_custom_target(spirv-tools-header-${NAME} DEPENDS ${OUT_H})
|
|
|
|
set_property(TARGET spirv-tools-header-${NAME} PROPERTY FOLDER "SPIRV-Tools build")
|
2018-12-20 20:02:53 +00:00
|
|
|
list(APPEND EXTINST_CPP_DEPENDS spirv-tools-header-${NAME})
|
2017-12-03 17:30:08 +00:00
|
|
|
endmacro(spvtools_extinst_lang_headers)
|
|
|
|
|
2018-02-09 19:29:02 +00:00
|
|
|
spvtools_core_tables("unified1")
|
2018-02-12 15:45:39 +00:00
|
|
|
spvtools_enum_string_mapping("unified1")
|
|
|
|
spvtools_opencl_tables("unified1")
|
|
|
|
spvtools_glsl_tables("unified1")
|
2019-12-19 22:16:26 +00:00
|
|
|
spvtools_vendor_tables("spv-amd-shader-explicit-vertex-parameter" "spv-amd-sevp" "")
|
|
|
|
spvtools_vendor_tables("spv-amd-shader-trinary-minmax" "spv-amd-stm" "")
|
|
|
|
spvtools_vendor_tables("spv-amd-gcn-shader" "spv-amd-gs" "")
|
|
|
|
spvtools_vendor_tables("spv-amd-shader-ballot" "spv-amd-sb" "")
|
|
|
|
spvtools_vendor_tables("debuginfo" "debuginfo" "")
|
|
|
|
spvtools_vendor_tables("opencl.debuginfo.100" "cldi100" "CLDEBUG100_")
|
2020-07-30 16:08:53 +00:00
|
|
|
spvtools_vendor_tables("nonsemantic.clspvreflection" "clspvreflection" "")
|
2017-12-03 17:30:08 +00:00
|
|
|
spvtools_extinst_lang_headers("DebugInfo" ${DEBUGINFO_GRAMMAR_JSON_FILE})
|
2019-12-19 22:16:26 +00:00
|
|
|
spvtools_extinst_lang_headers("OpenCLDebugInfo100" ${CLDEBUGINFO100_GRAMMAR_JSON_FILE})
|
2016-04-15 16:51:55 +00:00
|
|
|
|
2018-02-12 15:45:39 +00:00
|
|
|
spvtools_vimsyntax("unified1" "1.0")
|
2016-12-16 20:32:56 +00:00
|
|
|
add_custom_target(spirv-tools-vimsyntax DEPENDS ${VIMSYNTAX_FILE})
|
2017-04-05 21:32:39 +00:00
|
|
|
set_property(TARGET spirv-tools-vimsyntax PROPERTY FOLDER "SPIRV-Tools utilities")
|
2016-12-09 19:01:43 +00:00
|
|
|
|
|
|
|
# Extract the list of known generators from the SPIR-V XML registry file.
|
|
|
|
set(GENERATOR_INC_FILE ${spirv-tools_BINARY_DIR}/generators.inc)
|
|
|
|
set(SPIRV_XML_REGISTRY_FILE ${SPIRV_HEADER_INCLUDE_DIR}/spirv/spir-v.xml)
|
|
|
|
add_custom_command(OUTPUT ${GENERATOR_INC_FILE}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${XML_REGISTRY_PROCESSING_SCRIPT}
|
|
|
|
--xml=${SPIRV_XML_REGISTRY_FILE}
|
|
|
|
--generator-output=${GENERATOR_INC_FILE}
|
|
|
|
DEPENDS ${XML_REGISTRY_PROCESSING_SCRIPT} ${SPIRV_XML_REGISTRY_FILE}
|
|
|
|
COMMENT "Generate tables based on the SPIR-V XML registry.")
|
|
|
|
list(APPEND OPCODE_CPP_DEPENDS ${GENERATOR_INC_FILE})
|
|
|
|
|
2016-04-15 16:51:55 +00:00
|
|
|
# The following .cpp files include the above generated .inc files.
|
|
|
|
# Add those .inc files as their dependencies.
|
|
|
|
#
|
2018-12-20 20:02:53 +00:00
|
|
|
# We need to wrap the .inc files with a custom target to avoid problems when
|
|
|
|
# multiple targets depend on the same custom command.
|
|
|
|
add_custom_target(core_tables
|
|
|
|
DEPENDS ${OPCODE_CPP_DEPENDS} ${OPERAND_CPP_DEPENDS})
|
|
|
|
add_custom_target(enum_string_mapping
|
|
|
|
DEPENDS ${EXTENSION_H_DEPENDS} ${ENUM_STRING_MAPPING_CPP_DEPENDS})
|
|
|
|
add_custom_target(extinst_tables
|
|
|
|
DEPENDS ${EXTINST_CPP_DEPENDS})
|
2017-03-15 21:28:24 +00:00
|
|
|
|
|
|
|
set_source_files_properties(
|
2018-11-06 14:26:23 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/extensions.h
|
2017-03-15 21:28:24 +00:00
|
|
|
PROPERTIES HEADER_FILE_ONLY TRUE)
|
2016-04-15 16:51:55 +00:00
|
|
|
|
2016-04-22 00:50:11 +00:00
|
|
|
set(SPIRV_TOOLS_BUILD_VERSION_INC
|
2016-08-04 22:25:42 +00:00
|
|
|
${spirv-tools_BINARY_DIR}/build-version.inc)
|
2016-04-22 00:50:11 +00:00
|
|
|
set(SPIRV_TOOLS_BUILD_VERSION_INC_GENERATOR
|
2016-08-04 22:25:42 +00:00
|
|
|
${spirv-tools_SOURCE_DIR}/utils/update_build_version.py)
|
2016-04-22 00:50:11 +00:00
|
|
|
set(SPIRV_TOOLS_CHANGES_FILE
|
2016-08-04 22:25:42 +00:00
|
|
|
${spirv-tools_SOURCE_DIR}/CHANGES)
|
2016-04-22 00:50:11 +00:00
|
|
|
add_custom_command(OUTPUT ${SPIRV_TOOLS_BUILD_VERSION_INC}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE}
|
|
|
|
${SPIRV_TOOLS_BUILD_VERSION_INC_GENERATOR}
|
|
|
|
${spirv-tools_SOURCE_DIR} ${SPIRV_TOOLS_BUILD_VERSION_INC}
|
|
|
|
DEPENDS ${SPIRV_TOOLS_BUILD_VERSION_INC_GENERATOR}
|
|
|
|
${SPIRV_TOOLS_CHANGES_FILE}
|
|
|
|
COMMENT "Update build-version.inc in the SPIRV-Tools build directory (if necessary).")
|
|
|
|
# Convenience target for standalone generation of the build-version.inc file.
|
|
|
|
# This is not required for any dependence chain.
|
|
|
|
add_custom_target(spirv-tools-build-version
|
|
|
|
DEPENDS ${SPIRV_TOOLS_BUILD_VERSION_INC})
|
2017-04-05 21:32:39 +00:00
|
|
|
set_property(TARGET spirv-tools-build-version PROPERTY FOLDER "SPIRV-Tools build")
|
2016-04-22 00:50:11 +00:00
|
|
|
|
2018-11-06 14:26:23 +00:00
|
|
|
list(APPEND PCH_DEPENDS ${ENUM_STRING_MAPPING_CPP_DEPENDS} ${OPCODE_CPP_DEPENDS} ${OPERAND_CPP_DEPENDS} ${EXTENSION_H_DEPENDS} ${EXTINST_CPP_DEPENDS} ${SPIRV_TOOLS_BUILD_VERSION_INC})
|
|
|
|
set_source_files_properties(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/pch_source.cpp
|
|
|
|
PROPERTIES OBJECT_DEPENDS "${PCH_DEPENDS}")
|
|
|
|
|
2016-05-22 18:11:24 +00:00
|
|
|
add_subdirectory(opt)
|
2018-11-21 19:03:09 +00:00
|
|
|
add_subdirectory(reduce)
|
2019-05-27 13:34:55 +00:00
|
|
|
add_subdirectory(fuzz)
|
2017-07-13 00:16:51 +00:00
|
|
|
add_subdirectory(link)
|
2016-05-22 18:11:24 +00:00
|
|
|
|
2016-03-17 02:43:31 +00:00
|
|
|
set(SPIRV_SOURCES
|
|
|
|
${spirv-tools_SOURCE_DIR}/include/spirv-tools/libspirv.h
|
2016-03-31 21:26:31 +00:00
|
|
|
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/util/bitutils.h
|
2018-04-12 15:00:58 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/util/bit_vector.h
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/util/hex_float.h
|
2018-08-14 16:44:54 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/util/make_unique.h
|
2016-09-01 18:27:04 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/util/parse_number.h
|
2018-06-04 18:26:08 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/util/small_vector.h
|
2017-03-10 20:58:15 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/util/string_utils.h
|
2018-03-07 14:25:51 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/util/timer.h
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/assembly_grammar.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/binary.h
|
2017-04-28 19:38:10 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cfa.h
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/diagnostic.h
|
2018-01-10 19:23:47 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/disassemble.h
|
2016-08-31 18:35:58 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/enum_set.h
|
2017-03-15 21:28:24 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/enum_string_mapping.h
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/ext_inst.h
|
2017-03-10 20:58:15 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/extensions.h
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/instruction.h
|
2017-12-13 22:55:00 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/latest_version_glsl_std_450_header.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/latest_version_opencl_std_header.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/latest_version_spirv_header.h
|
2016-04-27 20:47:13 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/macro.h
|
2016-07-08 18:29:52 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/name_mapper.h
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/opcode.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/operand.h
|
2016-10-13 19:17:11 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/parsed_operand.h
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/print.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_constant.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_definition.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_endian.h
|
2019-05-27 13:34:55 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_fuzzer_options.h
|
2018-09-10 15:49:41 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_optimizer_options.h
|
2018-11-21 19:03:09 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_reducer_options.h
|
2016-05-11 13:48:52 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_target_env.h
|
2017-02-15 18:29:33 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_validator_options.h
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/table.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/text.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/text_handler.h
|
2018-07-11 14:27:34 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate.h
|
2016-03-31 21:26:31 +00:00
|
|
|
|
2018-04-12 15:00:58 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/util/bit_vector.cpp
|
2016-09-01 18:27:04 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/util/parse_number.cpp
|
2017-03-10 20:58:15 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/util/string_utils.cpp
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/assembly_grammar.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/binary.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/diagnostic.cpp
|
2016-03-31 21:26:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/disassemble.cpp
|
2017-03-15 21:28:24 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/enum_string_mapping.cpp
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/ext_inst.cpp
|
2017-03-08 18:59:01 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/extensions.cpp
|
2016-09-16 20:12:04 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/libspirv.cpp
|
2016-07-08 18:29:52 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/name_mapper.cpp
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/opcode.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/operand.cpp
|
2016-10-13 19:17:11 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/parsed_operand.cpp
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/print.cpp
|
2016-04-22 00:50:11 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/software_version.cpp
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_endian.cpp
|
2019-05-27 13:34:55 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_fuzzer_options.cpp
|
2018-09-10 15:49:41 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_optimizer_options.cpp
|
2018-11-21 19:03:09 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_reducer_options.cpp
|
2016-03-31 21:26:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_target_env.cpp
|
2017-02-15 18:29:33 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/spirv_validator_options.cpp
|
2016-03-17 02:43:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/table.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/text.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/text_handler.cpp
|
2018-07-11 14:27:34 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_adjacency.cpp
|
2018-08-08 18:21:27 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_annotation.cpp
|
2018-07-11 14:27:34 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_arithmetics.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_atomics.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_barriers.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_bitwise.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_builtins.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_capability.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_cfg.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_composites.cpp
|
2018-08-17 15:20:55 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_constants.cpp
|
2018-07-11 14:27:34 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_conversion.cpp
|
2018-08-08 17:47:09 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_debug.cpp
|
2018-07-11 14:27:34 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_decorations.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_derivatives.cpp
|
2018-11-27 21:20:01 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_extensions.cpp
|
2018-08-10 13:53:17 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_execution_limitations.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_function.cpp
|
2018-07-11 14:27:34 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_id.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_image.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_interfaces.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_instruction.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_layout.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_literals.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_logicals.cpp
|
2018-08-01 18:44:56 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_memory.cpp
|
2018-12-06 19:38:15 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_memory_semantics.cpp
|
2019-06-03 14:55:07 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_misc.cpp
|
2018-08-08 18:49:59 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_mode_setting.cpp
|
2018-07-11 14:27:34 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_non_uniform.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_primitives.cpp
|
2018-11-29 18:48:42 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_scopes.cpp
|
2019-07-11 17:05:14 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_small_type_uses.cpp
|
2018-08-03 15:38:51 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_type.cpp
|
2017-01-11 15:51:23 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/decoration.h
|
2016-11-08 18:26:09 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/basic_block.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/construct.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/function.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/instruction.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/val/validation_state.cpp)
|
2016-03-17 02:43:31 +00:00
|
|
|
|
2018-03-07 14:25:51 +00:00
|
|
|
if (${SPIRV_TIMER_ENABLED})
|
|
|
|
set(SPIRV_SOURCES
|
|
|
|
${SPIRV_SOURCES}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/util/timer.cpp)
|
|
|
|
endif()
|
|
|
|
|
2016-04-22 00:50:11 +00:00
|
|
|
# The software_version.cpp file includes build-version.inc.
|
|
|
|
# Rebuild the software_version.cpp object file if it is older than
|
|
|
|
# build-version.inc or whenever build-version.inc itself is out of
|
|
|
|
# date. In the latter case, rebuild build-version.inc first.
|
|
|
|
# CMake is not smart enough to detect this dependency automatically.
|
|
|
|
# Without this, the dependency detection system for #included files
|
|
|
|
# does not kick in on a clean build for the following reason: The
|
|
|
|
# build will fail early because it doesn't know how to build the
|
|
|
|
# missing source file build-version.inc. That occurs before the
|
|
|
|
# preprocessor is run on software_version.cpp to detect the
|
|
|
|
# #include dependency.
|
|
|
|
set_source_files_properties(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/software_version.cpp
|
|
|
|
PROPERTIES OBJECT_DEPENDS "${SPIRV_TOOLS_BUILD_VERSION_INC}")
|
|
|
|
|
2018-11-07 14:15:04 +00:00
|
|
|
spvtools_pch(SPIRV_SOURCES pch_source)
|
2018-11-06 14:26:23 +00:00
|
|
|
|
2020-10-29 13:25:26 +00:00
|
|
|
# spirv_tools_default_target_options() sets the target options that are common
|
|
|
|
# for all ${SPIRV_TOOLS} targets.
|
|
|
|
function(spirv_tools_default_target_options target)
|
|
|
|
spvtools_default_compile_options(${target})
|
|
|
|
target_include_directories(${target}
|
|
|
|
PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${spirv-tools_SOURCE_DIR}/include>
|
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
|
|
PRIVATE ${spirv-tools_BINARY_DIR}
|
|
|
|
PRIVATE ${SPIRV_HEADER_INCLUDE_DIR}
|
2016-03-21 20:36:14 +00:00
|
|
|
)
|
2020-10-29 13:25:26 +00:00
|
|
|
set_property(TARGET ${target} PROPERTY FOLDER "SPIRV-Tools libraries")
|
|
|
|
spvtools_check_symbol_exports(${target})
|
|
|
|
add_dependencies(${target} core_tables enum_string_mapping extinst_tables)
|
|
|
|
endfunction()
|
2016-03-17 02:43:31 +00:00
|
|
|
|
2020-10-29 13:25:26 +00:00
|
|
|
# Always build ${SPIRV_TOOLS}-shared. This is expected distro packages, and
|
|
|
|
# unlike the other SPIRV_TOOLS target, defaults to hidden symbol visibility.
|
2018-02-02 22:37:14 +00:00
|
|
|
add_library(${SPIRV_TOOLS}-shared SHARED ${SPIRV_SOURCES})
|
2020-10-29 13:25:26 +00:00
|
|
|
spirv_tools_default_target_options(${SPIRV_TOOLS}-shared)
|
2018-02-02 22:37:14 +00:00
|
|
|
set_target_properties(${SPIRV_TOOLS}-shared PROPERTIES CXX_VISIBILITY_PRESET hidden)
|
|
|
|
target_compile_definitions(${SPIRV_TOOLS}-shared
|
|
|
|
PRIVATE SPIRV_TOOLS_IMPLEMENTATION
|
|
|
|
PUBLIC SPIRV_TOOLS_SHAREDLIB
|
|
|
|
)
|
2020-07-27 17:29:07 +00:00
|
|
|
|
2020-10-29 13:25:26 +00:00
|
|
|
if(SPIRV_TOOLS_BUILD_STATIC)
|
|
|
|
add_library(${SPIRV_TOOLS}-static STATIC ${SPIRV_SOURCES})
|
|
|
|
spirv_tools_default_target_options(${SPIRV_TOOLS}-static)
|
|
|
|
# The static target does not have the '-static' suffix.
|
|
|
|
set_target_properties(${SPIRV_TOOLS}-static PROPERTIES OUTPUT_NAME "${SPIRV_TOOLS}")
|
|
|
|
|
|
|
|
# Create the "${SPIRV_TOOLS}" target as an alias to either "${SPIRV_TOOLS}-static"
|
|
|
|
# or "${SPIRV_TOOLS}-shared" depending on the value of BUILD_SHARED_LIBS.
|
|
|
|
if(BUILD_SHARED_LIBS)
|
2020-07-27 17:29:07 +00:00
|
|
|
add_library(${SPIRV_TOOLS} ALIAS ${SPIRV_TOOLS}-shared)
|
2020-10-29 13:25:26 +00:00
|
|
|
else()
|
2020-07-27 17:29:07 +00:00
|
|
|
add_library(${SPIRV_TOOLS} ALIAS ${SPIRV_TOOLS}-static)
|
2020-10-29 13:25:26 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-static ${SPIRV_TOOLS}-shared)
|
|
|
|
else()
|
|
|
|
add_library(${SPIRV_TOOLS} ${SPIRV_TOOLS_LIBRARY_TYPE} ${SPIRV_SOURCES})
|
|
|
|
spirv_tools_default_target_options(${SPIRV_TOOLS})
|
|
|
|
set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS} ${SPIRV_TOOLS}-shared)
|
2020-07-27 17:29:07 +00:00
|
|
|
endif()
|
2018-02-02 22:37:14 +00:00
|
|
|
|
2019-02-25 13:57:34 +00:00
|
|
|
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
|
|
|
find_library(LIBRT rt)
|
|
|
|
if(LIBRT)
|
2020-10-29 13:25:26 +00:00
|
|
|
foreach(target ${SPIRV_TOOLS_TARGETS})
|
|
|
|
target_link_libraries(${target} ${LIBRT})
|
|
|
|
endforeach()
|
2019-02-25 13:57:34 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2017-07-04 13:11:40 +00:00
|
|
|
if(ENABLE_SPIRV_TOOLS_INSTALL)
|
2020-10-29 13:25:26 +00:00
|
|
|
install(TARGETS ${SPIRV_TOOLS_TARGETS} EXPORT ${SPIRV_TOOLS}Targets
|
2017-07-04 13:11:40 +00:00
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
2019-10-17 15:36:55 +00:00
|
|
|
export(EXPORT ${SPIRV_TOOLS}Targets FILE ${SPIRV_TOOLS}Target.cmake)
|
|
|
|
|
|
|
|
spvtools_config_package_dir(${SPIRV_TOOLS} PACKAGE_DIR)
|
|
|
|
install(EXPORT ${SPIRV_TOOLS}Targets FILE ${SPIRV_TOOLS}Target.cmake DESTINATION ${PACKAGE_DIR})
|
|
|
|
|
|
|
|
# Special config file for root library compared to other libs.
|
|
|
|
file(WRITE ${CMAKE_BINARY_DIR}/${SPIRV_TOOLS}Config.cmake
|
|
|
|
"include(\${CMAKE_CURRENT_LIST_DIR}/${SPIRV_TOOLS}Target.cmake)\n"
|
|
|
|
"set(${SPIRV_TOOLS}_LIBRARIES ${SPIRV_TOOLS})\n"
|
|
|
|
"get_target_property(${SPIRV_TOOLS}_INCLUDE_DIRS ${SPIRV_TOOLS} INTERFACE_INCLUDE_DIRECTORIES)\n")
|
|
|
|
install(FILES ${CMAKE_BINARY_DIR}/${SPIRV_TOOLS}Config.cmake DESTINATION ${PACKAGE_DIR})
|
2017-07-04 13:11:40 +00:00
|
|
|
endif(ENABLE_SPIRV_TOOLS_INSTALL)
|
2018-10-01 14:47:39 +00:00
|
|
|
|
2020-08-10 14:59:24 +00:00
|
|
|
if(MSVC AND (NOT ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")))
|
2018-10-01 14:47:39 +00:00
|
|
|
# Enable parallel builds across four cores for this lib
|
|
|
|
add_definitions(/MP4)
|
|
|
|
endif()
|