1# Copyright (c) 2015-2016 The Khronos Group Inc. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15set(GRAMMAR_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/generate_grammar_tables.py") 16set(VIMSYNTAX_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/generate_vim_syntax.py") 17set(XML_REGISTRY_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/generate_registry_tables.py") 18set(LANG_HEADER_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/generate_language_headers.py") 19 20# Pull in grammar files that have migrated to SPIRV-Headers 21set(DEBUGINFO_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/unified1/extinst.debuginfo.grammar.json") 22set(CLDEBUGINFO100_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json") 23set(VKDEBUGINFO100_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json") 24 25# macro() definitions are used in the following because we need to append .inc 26# file paths into some global lists (*_CPP_DEPENDS). And those global lists are 27# later used by set_source_files_properties() calls. 28# function() definitions are not suitable because they create new scopes. 29macro(spvtools_core_tables CONFIG_VERSION) 30 set(GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/spirv.core.grammar.json") 31 set(GRAMMAR_INSTS_INC_FILE "${spirv-tools_BINARY_DIR}/core.insts-${CONFIG_VERSION}.inc") 32 set(GRAMMAR_KINDS_INC_FILE "${spirv-tools_BINARY_DIR}/operand.kinds-${CONFIG_VERSION}.inc") 33 add_custom_command(OUTPUT ${GRAMMAR_INSTS_INC_FILE} ${GRAMMAR_KINDS_INC_FILE} 34 COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT} 35 --spirv-core-grammar=${GRAMMAR_JSON_FILE} 36 --extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE} 37 --extinst-cldebuginfo100-grammar=${CLDEBUGINFO100_GRAMMAR_JSON_FILE} 38 --core-insts-output=${GRAMMAR_INSTS_INC_FILE} 39 --operand-kinds-output=${GRAMMAR_KINDS_INC_FILE} 40 DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} 41 ${GRAMMAR_JSON_FILE} 42 ${DEBUGINFO_GRAMMAR_JSON_FILE} 43 ${CLDEBUGINFO100_GRAMMAR_JSON_FILE} 44 COMMENT "Generate info tables for SPIR-V v${CONFIG_VERSION} core instructions and operands.") 45 list(APPEND OPCODE_CPP_DEPENDS ${GRAMMAR_INSTS_INC_FILE}) 46 list(APPEND OPERAND_CPP_DEPENDS ${GRAMMAR_KINDS_INC_FILE}) 47endmacro(spvtools_core_tables) 48 49macro(spvtools_enum_string_mapping CONFIG_VERSION) 50 set(GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/spirv.core.grammar.json") 51 set(GRAMMAR_EXTENSION_ENUM_INC_FILE "${spirv-tools_BINARY_DIR}/extension_enum.inc") 52 set(GRAMMAR_ENUM_STRING_MAPPING_INC_FILE "${spirv-tools_BINARY_DIR}/enum_string_mapping.inc") 53 add_custom_command(OUTPUT ${GRAMMAR_EXTENSION_ENUM_INC_FILE} 54 ${GRAMMAR_ENUM_STRING_MAPPING_INC_FILE} 55 COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT} 56 --spirv-core-grammar=${GRAMMAR_JSON_FILE} 57 --extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE} 58 --extinst-cldebuginfo100-grammar=${CLDEBUGINFO100_GRAMMAR_JSON_FILE} 59 --extension-enum-output=${GRAMMAR_EXTENSION_ENUM_INC_FILE} 60 --enum-string-mapping-output=${GRAMMAR_ENUM_STRING_MAPPING_INC_FILE} 61 DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} 62 ${GRAMMAR_JSON_FILE} 63 ${DEBUGINFO_GRAMMAR_JSON_FILE} 64 ${CLDEBUGINFO100_GRAMMAR_JSON_FILE} 65 COMMENT "Generate enum-string mapping for SPIR-V v${CONFIG_VERSION}.") 66 list(APPEND EXTENSION_H_DEPENDS ${GRAMMAR_EXTENSION_ENUM_INC_FILE}) 67 list(APPEND ENUM_STRING_MAPPING_CPP_DEPENDS ${GRAMMAR_ENUM_STRING_MAPPING_INC_FILE}) 68endmacro(spvtools_enum_string_mapping) 69 70macro(spvtools_vimsyntax CONFIG_VERSION CLVERSION) 71 set(GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/spirv.core.grammar.json") 72 set(GLSL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/extinst.glsl.std.450.grammar.json") 73 set(OPENCL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/extinst.opencl.std.100.grammar.json") 74 set(VIMSYNTAX_FILE "${spirv-tools_BINARY_DIR}/spvasm.vim") 75 add_custom_command(OUTPUT ${VIMSYNTAX_FILE} 76 COMMAND ${PYTHON_EXECUTABLE} ${VIMSYNTAX_PROCESSING_SCRIPT} 77 --spirv-core-grammar=${GRAMMAR_JSON_FILE} 78 --extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE} 79 --extinst-glsl-grammar=${GLSL_GRAMMAR_JSON_FILE} 80 --extinst-opencl-grammar=${OPENCL_GRAMMAR_JSON_FILE} 81 >${VIMSYNTAX_FILE} 82 DEPENDS ${VIMSYNTAX_PROCESSING_SCRIPT} ${GRAMMAR_JSON_FILE} 83 ${GLSL_GRAMMAR_JSON_FILE} ${OPENCL_GRAMMAR_JSON_FILE} ${DEBUGINFO_GRAMMAR_JSON_FILE} 84 COMMENT "Generate spvasm.vim: Vim syntax file for SPIR-V assembly.") 85endmacro(spvtools_vimsyntax) 86 87macro(spvtools_glsl_tables CONFIG_VERSION) 88 set(CORE_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/spirv.core.grammar.json") 89 set(GLSL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/extinst.glsl.std.450.grammar.json") 90 set(GRAMMAR_INC_FILE "${spirv-tools_BINARY_DIR}/glsl.std.450.insts.inc") 91 add_custom_command(OUTPUT ${GRAMMAR_INC_FILE} 92 COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT} 93 --extinst-glsl-grammar=${GLSL_GRAMMAR_JSON_FILE} 94 --glsl-insts-output=${GRAMMAR_INC_FILE} 95 DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} ${CORE_GRAMMAR_JSON_FILE} ${GLSL_GRAMMAR_JSON_FILE} 96 COMMENT "Generate info tables for GLSL extended instructions and operands v${CONFIG_VERSION}.") 97 list(APPEND EXTINST_CPP_DEPENDS ${GRAMMAR_INC_FILE}) 98endmacro(spvtools_glsl_tables) 99 100macro(spvtools_opencl_tables CONFIG_VERSION) 101 set(CORE_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/spirv.core.grammar.json") 102 set(OPENCL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/extinst.opencl.std.100.grammar.json") 103 set(GRAMMAR_INC_FILE "${spirv-tools_BINARY_DIR}/opencl.std.insts.inc") 104 add_custom_command(OUTPUT ${GRAMMAR_INC_FILE} 105 COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT} 106 --extinst-opencl-grammar=${OPENCL_GRAMMAR_JSON_FILE} 107 --opencl-insts-output=${GRAMMAR_INC_FILE} 108 DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} ${CORE_GRAMMAR_JSON_FILE} ${OPENCL_GRAMMAR_JSON_FILE} 109 COMMENT "Generate info tables for OpenCL extended instructions and operands v${CONFIG_VERSION}.") 110 list(APPEND EXTINST_CPP_DEPENDS ${GRAMMAR_INC_FILE}) 111endmacro(spvtools_opencl_tables) 112 113macro(spvtools_vendor_tables VENDOR_TABLE SHORT_NAME OPERAND_KIND_PREFIX) 114 set(INSTS_FILE "${spirv-tools_BINARY_DIR}/${VENDOR_TABLE}.insts.inc") 115 set(GRAMMAR_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/unified1/extinst.${VENDOR_TABLE}.grammar.json") 116 if(NOT EXISTS ${GRAMMAR_FILE}) 117 set(GRAMMAR_FILE "${spirv-tools_SOURCE_DIR}/source/extinst.${VENDOR_TABLE}.grammar.json") 118 endif() 119 add_custom_command(OUTPUT ${INSTS_FILE} 120 COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT} 121 --extinst-vendor-grammar=${GRAMMAR_FILE} 122 --vendor-insts-output=${INSTS_FILE} 123 --vendor-operand-kind-prefix=${OPERAND_KIND_PREFIX} 124 DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} ${GRAMMAR_FILE} 125 COMMENT "Generate extended instruction tables for ${VENDOR_TABLE}.") 126 add_custom_target(spv-tools-${SHORT_NAME} DEPENDS ${INSTS_FILE}) 127 set_property(TARGET spv-tools-${SHORT_NAME} PROPERTY FOLDER "SPIRV-Tools build") 128 list(APPEND EXTINST_CPP_DEPENDS spv-tools-${SHORT_NAME}) 129endmacro(spvtools_vendor_tables) 130 131macro(spvtools_extinst_lang_headers NAME GRAMMAR_FILE) 132 set(OUT_H ${spirv-tools_BINARY_DIR}/${NAME}.h) 133 add_custom_command(OUTPUT ${OUT_H} 134 COMMAND ${PYTHON_EXECUTABLE} ${LANG_HEADER_PROCESSING_SCRIPT} 135 --extinst-grammar=${GRAMMAR_FILE} 136 --extinst-output-path=${OUT_H} 137 DEPENDS ${LANG_HEADER_PROCESSING_SCRIPT} ${GRAMMAR_FILE} 138 COMMENT "Generate language specific header for ${NAME}.") 139 add_custom_target(spirv-tools-header-${NAME} DEPENDS ${OUT_H}) 140 set_property(TARGET spirv-tools-header-${NAME} PROPERTY FOLDER "SPIRV-Tools build") 141 list(APPEND EXTINST_CPP_DEPENDS spirv-tools-header-${NAME}) 142endmacro(spvtools_extinst_lang_headers) 143 144spvtools_core_tables("unified1") 145spvtools_enum_string_mapping("unified1") 146spvtools_opencl_tables("unified1") 147spvtools_glsl_tables("unified1") 148spvtools_vendor_tables("spv-amd-shader-explicit-vertex-parameter" "spv-amd-sevp" "") 149spvtools_vendor_tables("spv-amd-shader-trinary-minmax" "spv-amd-stm" "") 150spvtools_vendor_tables("spv-amd-gcn-shader" "spv-amd-gs" "") 151spvtools_vendor_tables("spv-amd-shader-ballot" "spv-amd-sb" "") 152spvtools_vendor_tables("debuginfo" "debuginfo" "") 153spvtools_vendor_tables("opencl.debuginfo.100" "cldi100" "CLDEBUG100_") 154spvtools_vendor_tables("nonsemantic.shader.debuginfo.100" "shdi100" "SHDEBUG100_") 155spvtools_vendor_tables("nonsemantic.clspvreflection" "clspvreflection" "") 156spvtools_extinst_lang_headers("DebugInfo" ${DEBUGINFO_GRAMMAR_JSON_FILE}) 157spvtools_extinst_lang_headers("OpenCLDebugInfo100" ${CLDEBUGINFO100_GRAMMAR_JSON_FILE}) 158spvtools_extinst_lang_headers("NonSemanticShaderDebugInfo100" ${VKDEBUGINFO100_GRAMMAR_JSON_FILE}) 159 160spvtools_vimsyntax("unified1" "1.0") 161add_custom_target(spirv-tools-vimsyntax DEPENDS ${VIMSYNTAX_FILE}) 162set_property(TARGET spirv-tools-vimsyntax PROPERTY FOLDER "SPIRV-Tools utilities") 163 164# Extract the list of known generators from the SPIR-V XML registry file. 165set(GENERATOR_INC_FILE ${spirv-tools_BINARY_DIR}/generators.inc) 166set(SPIRV_XML_REGISTRY_FILE ${SPIRV_HEADER_INCLUDE_DIR}/spirv/spir-v.xml) 167add_custom_command(OUTPUT ${GENERATOR_INC_FILE} 168 COMMAND ${PYTHON_EXECUTABLE} ${XML_REGISTRY_PROCESSING_SCRIPT} 169 --xml=${SPIRV_XML_REGISTRY_FILE} 170 --generator-output=${GENERATOR_INC_FILE} 171 DEPENDS ${XML_REGISTRY_PROCESSING_SCRIPT} ${SPIRV_XML_REGISTRY_FILE} 172 COMMENT "Generate tables based on the SPIR-V XML registry.") 173list(APPEND OPCODE_CPP_DEPENDS ${GENERATOR_INC_FILE}) 174 175# The following .cpp files include the above generated .inc files. 176# Add those .inc files as their dependencies. 177# 178# We need to wrap the .inc files with a custom target to avoid problems when 179# multiple targets depend on the same custom command. 180add_custom_target(core_tables 181 DEPENDS ${OPCODE_CPP_DEPENDS} ${OPERAND_CPP_DEPENDS}) 182add_custom_target(enum_string_mapping 183 DEPENDS ${EXTENSION_H_DEPENDS} ${ENUM_STRING_MAPPING_CPP_DEPENDS}) 184add_custom_target(extinst_tables 185 DEPENDS ${EXTINST_CPP_DEPENDS}) 186 187set_source_files_properties( 188 ${CMAKE_CURRENT_SOURCE_DIR}/extensions.h 189 PROPERTIES HEADER_FILE_ONLY TRUE) 190 191set(SPIRV_TOOLS_BUILD_VERSION_INC 192 ${spirv-tools_BINARY_DIR}/build-version.inc) 193set(SPIRV_TOOLS_BUILD_VERSION_INC_GENERATOR 194 ${spirv-tools_SOURCE_DIR}/utils/update_build_version.py) 195set(SPIRV_TOOLS_CHANGES_FILE 196 ${spirv-tools_SOURCE_DIR}/CHANGES) 197add_custom_command(OUTPUT ${SPIRV_TOOLS_BUILD_VERSION_INC} 198 COMMAND ${PYTHON_EXECUTABLE} 199 ${SPIRV_TOOLS_BUILD_VERSION_INC_GENERATOR} 200 ${SPIRV_TOOLS_CHANGES_FILE} ${SPIRV_TOOLS_BUILD_VERSION_INC} 201 DEPENDS ${SPIRV_TOOLS_BUILD_VERSION_INC_GENERATOR} 202 ${SPIRV_TOOLS_CHANGES_FILE} 203 COMMENT "Update build-version.inc in the SPIRV-Tools build directory (if necessary).") 204# Convenience target for standalone generation of the build-version.inc file. 205# This is not required for any dependence chain. 206add_custom_target(spirv-tools-build-version 207 DEPENDS ${SPIRV_TOOLS_BUILD_VERSION_INC}) 208set_property(TARGET spirv-tools-build-version PROPERTY FOLDER "SPIRV-Tools build") 209 210list(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}) 211set_source_files_properties( 212 ${CMAKE_CURRENT_SOURCE_DIR}/pch_source.cpp 213 PROPERTIES OBJECT_DEPENDS "${PCH_DEPENDS}") 214 215add_subdirectory(opt) 216add_subdirectory(reduce) 217add_subdirectory(fuzz) 218add_subdirectory(link) 219add_subdirectory(lint) 220add_subdirectory(diff) 221 222set(SPIRV_SOURCES 223 ${spirv-tools_SOURCE_DIR}/include/spirv-tools/libspirv.h 224 225 ${CMAKE_CURRENT_SOURCE_DIR}/util/bitutils.h 226 ${CMAKE_CURRENT_SOURCE_DIR}/util/bit_vector.h 227 ${CMAKE_CURRENT_SOURCE_DIR}/util/hash_combine.h 228 ${CMAKE_CURRENT_SOURCE_DIR}/util/hex_float.h 229 ${CMAKE_CURRENT_SOURCE_DIR}/util/make_unique.h 230 ${CMAKE_CURRENT_SOURCE_DIR}/util/parse_number.h 231 ${CMAKE_CURRENT_SOURCE_DIR}/util/small_vector.h 232 ${CMAKE_CURRENT_SOURCE_DIR}/util/string_utils.h 233 ${CMAKE_CURRENT_SOURCE_DIR}/util/timer.h 234 ${CMAKE_CURRENT_SOURCE_DIR}/assembly_grammar.h 235 ${CMAKE_CURRENT_SOURCE_DIR}/binary.h 236 ${CMAKE_CURRENT_SOURCE_DIR}/cfa.h 237 ${CMAKE_CURRENT_SOURCE_DIR}/common_debug_info.h 238 ${CMAKE_CURRENT_SOURCE_DIR}/diagnostic.h 239 ${CMAKE_CURRENT_SOURCE_DIR}/disassemble.h 240 ${CMAKE_CURRENT_SOURCE_DIR}/enum_set.h 241 ${CMAKE_CURRENT_SOURCE_DIR}/enum_string_mapping.h 242 ${CMAKE_CURRENT_SOURCE_DIR}/ext_inst.h 243 ${CMAKE_CURRENT_SOURCE_DIR}/extensions.h 244 ${CMAKE_CURRENT_SOURCE_DIR}/instruction.h 245 ${CMAKE_CURRENT_SOURCE_DIR}/latest_version_glsl_std_450_header.h 246 ${CMAKE_CURRENT_SOURCE_DIR}/latest_version_opencl_std_header.h 247 ${CMAKE_CURRENT_SOURCE_DIR}/latest_version_spirv_header.h 248 ${CMAKE_CURRENT_SOURCE_DIR}/macro.h 249 ${CMAKE_CURRENT_SOURCE_DIR}/name_mapper.h 250 ${CMAKE_CURRENT_SOURCE_DIR}/opcode.h 251 ${CMAKE_CURRENT_SOURCE_DIR}/operand.h 252 ${CMAKE_CURRENT_SOURCE_DIR}/parsed_operand.h 253 ${CMAKE_CURRENT_SOURCE_DIR}/print.h 254 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_constant.h 255 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_definition.h 256 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_endian.h 257 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_fuzzer_options.h 258 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_optimizer_options.h 259 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_reducer_options.h 260 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_target_env.h 261 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_validator_options.h 262 ${CMAKE_CURRENT_SOURCE_DIR}/table.h 263 ${CMAKE_CURRENT_SOURCE_DIR}/text.h 264 ${CMAKE_CURRENT_SOURCE_DIR}/text_handler.h 265 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate.h 266 267 ${CMAKE_CURRENT_SOURCE_DIR}/util/bit_vector.cpp 268 ${CMAKE_CURRENT_SOURCE_DIR}/util/parse_number.cpp 269 ${CMAKE_CURRENT_SOURCE_DIR}/util/string_utils.cpp 270 ${CMAKE_CURRENT_SOURCE_DIR}/assembly_grammar.cpp 271 ${CMAKE_CURRENT_SOURCE_DIR}/binary.cpp 272 ${CMAKE_CURRENT_SOURCE_DIR}/diagnostic.cpp 273 ${CMAKE_CURRENT_SOURCE_DIR}/disassemble.cpp 274 ${CMAKE_CURRENT_SOURCE_DIR}/enum_string_mapping.cpp 275 ${CMAKE_CURRENT_SOURCE_DIR}/ext_inst.cpp 276 ${CMAKE_CURRENT_SOURCE_DIR}/extensions.cpp 277 ${CMAKE_CURRENT_SOURCE_DIR}/libspirv.cpp 278 ${CMAKE_CURRENT_SOURCE_DIR}/name_mapper.cpp 279 ${CMAKE_CURRENT_SOURCE_DIR}/opcode.cpp 280 ${CMAKE_CURRENT_SOURCE_DIR}/operand.cpp 281 ${CMAKE_CURRENT_SOURCE_DIR}/parsed_operand.cpp 282 ${CMAKE_CURRENT_SOURCE_DIR}/print.cpp 283 ${CMAKE_CURRENT_SOURCE_DIR}/software_version.cpp 284 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_endian.cpp 285 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_fuzzer_options.cpp 286 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_optimizer_options.cpp 287 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_reducer_options.cpp 288 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_target_env.cpp 289 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_validator_options.cpp 290 ${CMAKE_CURRENT_SOURCE_DIR}/table.cpp 291 ${CMAKE_CURRENT_SOURCE_DIR}/text.cpp 292 ${CMAKE_CURRENT_SOURCE_DIR}/text_handler.cpp 293 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate.cpp 294 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_adjacency.cpp 295 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_annotation.cpp 296 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_arithmetics.cpp 297 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_atomics.cpp 298 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_barriers.cpp 299 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_bitwise.cpp 300 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_builtins.cpp 301 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_capability.cpp 302 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_cfg.cpp 303 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_composites.cpp 304 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_constants.cpp 305 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_conversion.cpp 306 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_debug.cpp 307 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_decorations.cpp 308 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_derivatives.cpp 309 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_extensions.cpp 310 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_execution_limitations.cpp 311 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_function.cpp 312 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_id.cpp 313 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_image.cpp 314 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_interfaces.cpp 315 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_instruction.cpp 316 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_layout.cpp 317 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_literals.cpp 318 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_logicals.cpp 319 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_memory.cpp 320 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_memory_semantics.cpp 321 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_mesh_shading.cpp 322 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_misc.cpp 323 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_mode_setting.cpp 324 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_non_uniform.cpp 325 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_primitives.cpp 326 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_ray_query.cpp 327 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_ray_tracing.cpp 328 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_scopes.cpp 329 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_small_type_uses.cpp 330 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_type.cpp 331 ${CMAKE_CURRENT_SOURCE_DIR}/val/decoration.h 332 ${CMAKE_CURRENT_SOURCE_DIR}/val/basic_block.cpp 333 ${CMAKE_CURRENT_SOURCE_DIR}/val/construct.cpp 334 ${CMAKE_CURRENT_SOURCE_DIR}/val/function.cpp 335 ${CMAKE_CURRENT_SOURCE_DIR}/val/instruction.cpp 336 ${CMAKE_CURRENT_SOURCE_DIR}/val/validation_state.cpp) 337 338if (${SPIRV_TIMER_ENABLED}) 339 set(SPIRV_SOURCES 340 ${SPIRV_SOURCES} 341 ${CMAKE_CURRENT_SOURCE_DIR}/util/timer.cpp) 342endif() 343 344# The software_version.cpp file includes build-version.inc. 345# Rebuild the software_version.cpp object file if it is older than 346# build-version.inc or whenever build-version.inc itself is out of 347# date. In the latter case, rebuild build-version.inc first. 348# CMake is not smart enough to detect this dependency automatically. 349# Without this, the dependency detection system for #included files 350# does not kick in on a clean build for the following reason: The 351# build will fail early because it doesn't know how to build the 352# missing source file build-version.inc. That occurs before the 353# preprocessor is run on software_version.cpp to detect the 354# #include dependency. 355set_source_files_properties( 356 ${CMAKE_CURRENT_SOURCE_DIR}/software_version.cpp 357 PROPERTIES OBJECT_DEPENDS "${SPIRV_TOOLS_BUILD_VERSION_INC}") 358 359spvtools_pch(SPIRV_SOURCES pch_source) 360 361# spirv_tools_default_target_options() sets the target options that are common 362# for all ${SPIRV_TOOLS} targets. 363function(spirv_tools_default_target_options target) 364 spvtools_default_compile_options(${target}) 365 target_include_directories(${target} 366 PUBLIC 367 $<BUILD_INTERFACE:${spirv-tools_SOURCE_DIR}/include> 368 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> 369 PRIVATE ${spirv-tools_BINARY_DIR} 370 PRIVATE ${SPIRV_HEADER_INCLUDE_DIR} 371 ) 372 set_property(TARGET ${target} PROPERTY FOLDER "SPIRV-Tools libraries") 373 spvtools_check_symbol_exports(${target}) 374 add_dependencies(${target} spirv-tools-build-version core_tables enum_string_mapping extinst_tables) 375endfunction() 376 377# Always build ${SPIRV_TOOLS}-shared. This is expected distro packages, and 378# unlike the other SPIRV_TOOLS target, defaults to hidden symbol visibility. 379add_library(${SPIRV_TOOLS}-shared SHARED ${SPIRV_SOURCES}) 380spirv_tools_default_target_options(${SPIRV_TOOLS}-shared) 381set_target_properties(${SPIRV_TOOLS}-shared PROPERTIES CXX_VISIBILITY_PRESET hidden) 382target_compile_definitions(${SPIRV_TOOLS}-shared 383 PRIVATE SPIRV_TOOLS_IMPLEMENTATION 384 PUBLIC SPIRV_TOOLS_SHAREDLIB 385) 386 387if(SPIRV_TOOLS_BUILD_STATIC) 388 add_library(${SPIRV_TOOLS}-static STATIC ${SPIRV_SOURCES}) 389 spirv_tools_default_target_options(${SPIRV_TOOLS}-static) 390 # The static target does not have the '-static' suffix. 391 set_target_properties(${SPIRV_TOOLS}-static PROPERTIES OUTPUT_NAME "${SPIRV_TOOLS}") 392 393 # Create the "${SPIRV_TOOLS}" target as an alias to either "${SPIRV_TOOLS}-static" 394 # or "${SPIRV_TOOLS}-shared" depending on the value of BUILD_SHARED_LIBS. 395 if(BUILD_SHARED_LIBS) 396 add_library(${SPIRV_TOOLS} ALIAS ${SPIRV_TOOLS}-shared) 397 else() 398 add_library(${SPIRV_TOOLS} ALIAS ${SPIRV_TOOLS}-static) 399 endif() 400 401 set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-static ${SPIRV_TOOLS}-shared) 402else() 403 add_library(${SPIRV_TOOLS} ${SPIRV_TOOLS_LIBRARY_TYPE} ${SPIRV_SOURCES}) 404 spirv_tools_default_target_options(${SPIRV_TOOLS}) 405 set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS} ${SPIRV_TOOLS}-shared) 406endif() 407 408if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") 409 find_library(LIBRT rt) 410 if(LIBRT) 411 foreach(target ${SPIRV_TOOLS_TARGETS}) 412 target_link_libraries(${target} rt) 413 endforeach() 414 endif() 415endif() 416 417if (ANDROID) 418 foreach(target ${SPIRV_TOOLS_TARGETS}) 419 target_link_libraries(${target} PRIVATE android log) 420 endforeach() 421endif() 422 423if(ENABLE_SPIRV_TOOLS_INSTALL) 424 install(TARGETS ${SPIRV_TOOLS_TARGETS} EXPORT ${SPIRV_TOOLS}Targets 425 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 426 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 427 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) 428 export(EXPORT ${SPIRV_TOOLS}Targets FILE ${SPIRV_TOOLS}Target.cmake) 429 430 spvtools_config_package_dir(${SPIRV_TOOLS} PACKAGE_DIR) 431 install(EXPORT ${SPIRV_TOOLS}Targets FILE ${SPIRV_TOOLS}Target.cmake DESTINATION ${PACKAGE_DIR}) 432 433 # Special config file for root library compared to other libs. 434 file(WRITE ${CMAKE_BINARY_DIR}/${SPIRV_TOOLS}Config.cmake 435 "include(\${CMAKE_CURRENT_LIST_DIR}/${SPIRV_TOOLS}Target.cmake)\n" 436 "if(TARGET ${SPIRV_TOOLS})\n" 437 " set(${SPIRV_TOOLS}_LIBRARIES ${SPIRV_TOOLS})\n" 438 " get_target_property(${SPIRV_TOOLS}_INCLUDE_DIRS ${SPIRV_TOOLS} INTERFACE_INCLUDE_DIRECTORIES)\n" 439 "endif()\n") 440 install(FILES ${CMAKE_BINARY_DIR}/${SPIRV_TOOLS}Config.cmake DESTINATION ${PACKAGE_DIR}) 441endif(ENABLE_SPIRV_TOOLS_INSTALL) 442 443if(MSVC AND (NOT ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))) 444 # Enable parallel builds across four cores for this lib 445 add_definitions(/MP4) 446endif() 447