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# For now, assume the DebugInfo grammar file is in the current directory. 21# It might migrate to SPIRV-Headers. 22set(DEBUGINFO_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/unified1/extinst.debuginfo.grammar.json") 23set(CLDEBUGINFO100_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/unified1/extinst.opencl.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 add_custom_command(OUTPUT ${INSTS_FILE} 117 COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT} 118 --extinst-vendor-grammar=${GRAMMAR_FILE} 119 --vendor-insts-output=${INSTS_FILE} 120 --vendor-operand-kind-prefix=${OPERAND_KIND_PREFIX} 121 DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} ${GRAMMAR_FILE} 122 COMMENT "Generate extended instruction tables for ${VENDOR_TABLE}.") 123 add_custom_target(spv-tools-${SHORT_NAME} DEPENDS ${INSTS_FILE}) 124 set_property(TARGET spv-tools-${SHORT_NAME} PROPERTY FOLDER "SPIRV-Tools build") 125 list(APPEND EXTINST_CPP_DEPENDS spv-tools-${SHORT_NAME}) 126endmacro(spvtools_vendor_tables) 127 128macro(spvtools_extinst_lang_headers NAME GRAMMAR_FILE) 129 set(OUT_H ${spirv-tools_BINARY_DIR}/${NAME}.h) 130 add_custom_command(OUTPUT ${OUT_H} 131 COMMAND ${PYTHON_EXECUTABLE} ${LANG_HEADER_PROCESSING_SCRIPT} 132 --extinst-grammar=${GRAMMAR_FILE} 133 --extinst-output-path=${OUT_H} 134 DEPENDS ${LANG_HEADER_PROCESSING_SCRIPT} ${GRAMMAR_FILE} 135 COMMENT "Generate language specific header for ${NAME}.") 136 add_custom_target(spirv-tools-header-${NAME} DEPENDS ${OUT_H}) 137 set_property(TARGET spirv-tools-header-${NAME} PROPERTY FOLDER "SPIRV-Tools build") 138 list(APPEND EXTINST_CPP_DEPENDS spirv-tools-header-${NAME}) 139endmacro(spvtools_extinst_lang_headers) 140 141spvtools_core_tables("unified1") 142spvtools_enum_string_mapping("unified1") 143spvtools_opencl_tables("unified1") 144spvtools_glsl_tables("unified1") 145spvtools_vendor_tables("spv-amd-shader-explicit-vertex-parameter" "spv-amd-sevp" "") 146spvtools_vendor_tables("spv-amd-shader-trinary-minmax" "spv-amd-stm" "") 147spvtools_vendor_tables("spv-amd-gcn-shader" "spv-amd-gs" "") 148spvtools_vendor_tables("spv-amd-shader-ballot" "spv-amd-sb" "") 149spvtools_vendor_tables("debuginfo" "debuginfo" "") 150spvtools_vendor_tables("opencl.debuginfo.100" "cldi100" "CLDEBUG100_") 151spvtools_vendor_tables("nonsemantic.clspvreflection" "clspvreflection" "") 152spvtools_extinst_lang_headers("DebugInfo" ${DEBUGINFO_GRAMMAR_JSON_FILE}) 153spvtools_extinst_lang_headers("OpenCLDebugInfo100" ${CLDEBUGINFO100_GRAMMAR_JSON_FILE}) 154 155spvtools_vimsyntax("unified1" "1.0") 156add_custom_target(spirv-tools-vimsyntax DEPENDS ${VIMSYNTAX_FILE}) 157set_property(TARGET spirv-tools-vimsyntax PROPERTY FOLDER "SPIRV-Tools utilities") 158 159# Extract the list of known generators from the SPIR-V XML registry file. 160set(GENERATOR_INC_FILE ${spirv-tools_BINARY_DIR}/generators.inc) 161set(SPIRV_XML_REGISTRY_FILE ${SPIRV_HEADER_INCLUDE_DIR}/spirv/spir-v.xml) 162add_custom_command(OUTPUT ${GENERATOR_INC_FILE} 163 COMMAND ${PYTHON_EXECUTABLE} ${XML_REGISTRY_PROCESSING_SCRIPT} 164 --xml=${SPIRV_XML_REGISTRY_FILE} 165 --generator-output=${GENERATOR_INC_FILE} 166 DEPENDS ${XML_REGISTRY_PROCESSING_SCRIPT} ${SPIRV_XML_REGISTRY_FILE} 167 COMMENT "Generate tables based on the SPIR-V XML registry.") 168list(APPEND OPCODE_CPP_DEPENDS ${GENERATOR_INC_FILE}) 169 170# The following .cpp files include the above generated .inc files. 171# Add those .inc files as their dependencies. 172# 173# We need to wrap the .inc files with a custom target to avoid problems when 174# multiple targets depend on the same custom command. 175add_custom_target(core_tables 176 DEPENDS ${OPCODE_CPP_DEPENDS} ${OPERAND_CPP_DEPENDS}) 177add_custom_target(enum_string_mapping 178 DEPENDS ${EXTENSION_H_DEPENDS} ${ENUM_STRING_MAPPING_CPP_DEPENDS}) 179add_custom_target(extinst_tables 180 DEPENDS ${EXTINST_CPP_DEPENDS}) 181 182set_source_files_properties( 183 ${CMAKE_CURRENT_SOURCE_DIR}/extensions.h 184 PROPERTIES HEADER_FILE_ONLY TRUE) 185 186set(SPIRV_TOOLS_BUILD_VERSION_INC 187 ${spirv-tools_BINARY_DIR}/build-version.inc) 188set(SPIRV_TOOLS_BUILD_VERSION_INC_GENERATOR 189 ${spirv-tools_SOURCE_DIR}/utils/update_build_version.py) 190set(SPIRV_TOOLS_CHANGES_FILE 191 ${spirv-tools_SOURCE_DIR}/CHANGES) 192add_custom_command(OUTPUT ${SPIRV_TOOLS_BUILD_VERSION_INC} 193 COMMAND ${PYTHON_EXECUTABLE} 194 ${SPIRV_TOOLS_BUILD_VERSION_INC_GENERATOR} 195 ${spirv-tools_SOURCE_DIR} ${SPIRV_TOOLS_BUILD_VERSION_INC} 196 DEPENDS ${SPIRV_TOOLS_BUILD_VERSION_INC_GENERATOR} 197 ${SPIRV_TOOLS_CHANGES_FILE} 198 COMMENT "Update build-version.inc in the SPIRV-Tools build directory (if necessary).") 199# Convenience target for standalone generation of the build-version.inc file. 200# This is not required for any dependence chain. 201add_custom_target(spirv-tools-build-version 202 DEPENDS ${SPIRV_TOOLS_BUILD_VERSION_INC}) 203set_property(TARGET spirv-tools-build-version PROPERTY FOLDER "SPIRV-Tools build") 204 205list(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}) 206set_source_files_properties( 207 ${CMAKE_CURRENT_SOURCE_DIR}/pch_source.cpp 208 PROPERTIES OBJECT_DEPENDS "${PCH_DEPENDS}") 209 210add_subdirectory(opt) 211add_subdirectory(reduce) 212add_subdirectory(fuzz) 213add_subdirectory(link) 214 215set(SPIRV_SOURCES 216 ${spirv-tools_SOURCE_DIR}/include/spirv-tools/libspirv.h 217 218 ${CMAKE_CURRENT_SOURCE_DIR}/util/bitutils.h 219 ${CMAKE_CURRENT_SOURCE_DIR}/util/bit_vector.h 220 ${CMAKE_CURRENT_SOURCE_DIR}/util/hex_float.h 221 ${CMAKE_CURRENT_SOURCE_DIR}/util/make_unique.h 222 ${CMAKE_CURRENT_SOURCE_DIR}/util/parse_number.h 223 ${CMAKE_CURRENT_SOURCE_DIR}/util/small_vector.h 224 ${CMAKE_CURRENT_SOURCE_DIR}/util/string_utils.h 225 ${CMAKE_CURRENT_SOURCE_DIR}/util/timer.h 226 ${CMAKE_CURRENT_SOURCE_DIR}/assembly_grammar.h 227 ${CMAKE_CURRENT_SOURCE_DIR}/binary.h 228 ${CMAKE_CURRENT_SOURCE_DIR}/cfa.h 229 ${CMAKE_CURRENT_SOURCE_DIR}/diagnostic.h 230 ${CMAKE_CURRENT_SOURCE_DIR}/disassemble.h 231 ${CMAKE_CURRENT_SOURCE_DIR}/enum_set.h 232 ${CMAKE_CURRENT_SOURCE_DIR}/enum_string_mapping.h 233 ${CMAKE_CURRENT_SOURCE_DIR}/ext_inst.h 234 ${CMAKE_CURRENT_SOURCE_DIR}/extensions.h 235 ${CMAKE_CURRENT_SOURCE_DIR}/instruction.h 236 ${CMAKE_CURRENT_SOURCE_DIR}/latest_version_glsl_std_450_header.h 237 ${CMAKE_CURRENT_SOURCE_DIR}/latest_version_opencl_std_header.h 238 ${CMAKE_CURRENT_SOURCE_DIR}/latest_version_spirv_header.h 239 ${CMAKE_CURRENT_SOURCE_DIR}/macro.h 240 ${CMAKE_CURRENT_SOURCE_DIR}/name_mapper.h 241 ${CMAKE_CURRENT_SOURCE_DIR}/opcode.h 242 ${CMAKE_CURRENT_SOURCE_DIR}/operand.h 243 ${CMAKE_CURRENT_SOURCE_DIR}/parsed_operand.h 244 ${CMAKE_CURRENT_SOURCE_DIR}/print.h 245 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_constant.h 246 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_definition.h 247 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_endian.h 248 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_fuzzer_options.h 249 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_optimizer_options.h 250 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_reducer_options.h 251 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_target_env.h 252 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_validator_options.h 253 ${CMAKE_CURRENT_SOURCE_DIR}/table.h 254 ${CMAKE_CURRENT_SOURCE_DIR}/text.h 255 ${CMAKE_CURRENT_SOURCE_DIR}/text_handler.h 256 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate.h 257 258 ${CMAKE_CURRENT_SOURCE_DIR}/util/bit_vector.cpp 259 ${CMAKE_CURRENT_SOURCE_DIR}/util/parse_number.cpp 260 ${CMAKE_CURRENT_SOURCE_DIR}/util/string_utils.cpp 261 ${CMAKE_CURRENT_SOURCE_DIR}/assembly_grammar.cpp 262 ${CMAKE_CURRENT_SOURCE_DIR}/binary.cpp 263 ${CMAKE_CURRENT_SOURCE_DIR}/diagnostic.cpp 264 ${CMAKE_CURRENT_SOURCE_DIR}/disassemble.cpp 265 ${CMAKE_CURRENT_SOURCE_DIR}/enum_string_mapping.cpp 266 ${CMAKE_CURRENT_SOURCE_DIR}/ext_inst.cpp 267 ${CMAKE_CURRENT_SOURCE_DIR}/extensions.cpp 268 ${CMAKE_CURRENT_SOURCE_DIR}/libspirv.cpp 269 ${CMAKE_CURRENT_SOURCE_DIR}/name_mapper.cpp 270 ${CMAKE_CURRENT_SOURCE_DIR}/opcode.cpp 271 ${CMAKE_CURRENT_SOURCE_DIR}/operand.cpp 272 ${CMAKE_CURRENT_SOURCE_DIR}/parsed_operand.cpp 273 ${CMAKE_CURRENT_SOURCE_DIR}/print.cpp 274 ${CMAKE_CURRENT_SOURCE_DIR}/software_version.cpp 275 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_endian.cpp 276 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_fuzzer_options.cpp 277 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_optimizer_options.cpp 278 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_reducer_options.cpp 279 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_target_env.cpp 280 ${CMAKE_CURRENT_SOURCE_DIR}/spirv_validator_options.cpp 281 ${CMAKE_CURRENT_SOURCE_DIR}/table.cpp 282 ${CMAKE_CURRENT_SOURCE_DIR}/text.cpp 283 ${CMAKE_CURRENT_SOURCE_DIR}/text_handler.cpp 284 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate.cpp 285 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_adjacency.cpp 286 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_annotation.cpp 287 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_arithmetics.cpp 288 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_atomics.cpp 289 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_barriers.cpp 290 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_bitwise.cpp 291 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_builtins.cpp 292 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_capability.cpp 293 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_cfg.cpp 294 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_composites.cpp 295 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_constants.cpp 296 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_conversion.cpp 297 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_debug.cpp 298 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_decorations.cpp 299 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_derivatives.cpp 300 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_extensions.cpp 301 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_execution_limitations.cpp 302 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_function.cpp 303 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_id.cpp 304 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_image.cpp 305 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_interfaces.cpp 306 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_instruction.cpp 307 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_layout.cpp 308 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_literals.cpp 309 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_logicals.cpp 310 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_memory.cpp 311 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_memory_semantics.cpp 312 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_misc.cpp 313 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_mode_setting.cpp 314 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_non_uniform.cpp 315 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_primitives.cpp 316 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_scopes.cpp 317 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_small_type_uses.cpp 318 ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_type.cpp 319 ${CMAKE_CURRENT_SOURCE_DIR}/val/decoration.h 320 ${CMAKE_CURRENT_SOURCE_DIR}/val/basic_block.cpp 321 ${CMAKE_CURRENT_SOURCE_DIR}/val/construct.cpp 322 ${CMAKE_CURRENT_SOURCE_DIR}/val/function.cpp 323 ${CMAKE_CURRENT_SOURCE_DIR}/val/instruction.cpp 324 ${CMAKE_CURRENT_SOURCE_DIR}/val/validation_state.cpp) 325 326if (${SPIRV_TIMER_ENABLED}) 327 set(SPIRV_SOURCES 328 ${SPIRV_SOURCES} 329 ${CMAKE_CURRENT_SOURCE_DIR}/util/timer.cpp) 330endif() 331 332# The software_version.cpp file includes build-version.inc. 333# Rebuild the software_version.cpp object file if it is older than 334# build-version.inc or whenever build-version.inc itself is out of 335# date. In the latter case, rebuild build-version.inc first. 336# CMake is not smart enough to detect this dependency automatically. 337# Without this, the dependency detection system for #included files 338# does not kick in on a clean build for the following reason: The 339# build will fail early because it doesn't know how to build the 340# missing source file build-version.inc. That occurs before the 341# preprocessor is run on software_version.cpp to detect the 342# #include dependency. 343set_source_files_properties( 344 ${CMAKE_CURRENT_SOURCE_DIR}/software_version.cpp 345 PROPERTIES OBJECT_DEPENDS "${SPIRV_TOOLS_BUILD_VERSION_INC}") 346 347spvtools_pch(SPIRV_SOURCES pch_source) 348 349# spirv_tools_default_target_options() sets the target options that are common 350# for all ${SPIRV_TOOLS} targets. 351function(spirv_tools_default_target_options target) 352 spvtools_default_compile_options(${target}) 353 target_include_directories(${target} 354 PUBLIC 355 $<BUILD_INTERFACE:${spirv-tools_SOURCE_DIR}/include> 356 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> 357 PRIVATE ${spirv-tools_BINARY_DIR} 358 PRIVATE ${SPIRV_HEADER_INCLUDE_DIR} 359 ) 360 set_property(TARGET ${target} PROPERTY FOLDER "SPIRV-Tools libraries") 361 spvtools_check_symbol_exports(${target}) 362 add_dependencies(${target} core_tables enum_string_mapping extinst_tables) 363endfunction() 364 365# Always build ${SPIRV_TOOLS}-shared. This is expected distro packages, and 366# unlike the other SPIRV_TOOLS target, defaults to hidden symbol visibility. 367add_library(${SPIRV_TOOLS}-shared SHARED ${SPIRV_SOURCES}) 368spirv_tools_default_target_options(${SPIRV_TOOLS}-shared) 369set_target_properties(${SPIRV_TOOLS}-shared PROPERTIES CXX_VISIBILITY_PRESET hidden) 370target_compile_definitions(${SPIRV_TOOLS}-shared 371 PRIVATE SPIRV_TOOLS_IMPLEMENTATION 372 PUBLIC SPIRV_TOOLS_SHAREDLIB 373) 374 375if(SPIRV_TOOLS_BUILD_STATIC) 376 add_library(${SPIRV_TOOLS}-static STATIC ${SPIRV_SOURCES}) 377 spirv_tools_default_target_options(${SPIRV_TOOLS}-static) 378 # The static target does not have the '-static' suffix. 379 set_target_properties(${SPIRV_TOOLS}-static PROPERTIES OUTPUT_NAME "${SPIRV_TOOLS}") 380 381 # Create the "${SPIRV_TOOLS}" target as an alias to either "${SPIRV_TOOLS}-static" 382 # or "${SPIRV_TOOLS}-shared" depending on the value of BUILD_SHARED_LIBS. 383 if(BUILD_SHARED_LIBS) 384 add_library(${SPIRV_TOOLS} ALIAS ${SPIRV_TOOLS}-shared) 385 else() 386 add_library(${SPIRV_TOOLS} ALIAS ${SPIRV_TOOLS}-static) 387 endif() 388 389 set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-static ${SPIRV_TOOLS}-shared) 390else() 391 add_library(${SPIRV_TOOLS} ${SPIRV_TOOLS_LIBRARY_TYPE} ${SPIRV_SOURCES}) 392 spirv_tools_default_target_options(${SPIRV_TOOLS}) 393 set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS} ${SPIRV_TOOLS}-shared) 394endif() 395 396if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") 397 find_library(LIBRT rt) 398 if(LIBRT) 399 foreach(target ${SPIRV_TOOLS_TARGETS}) 400 target_link_libraries(${target} ${LIBRT}) 401 endforeach() 402 endif() 403endif() 404 405if(ENABLE_SPIRV_TOOLS_INSTALL) 406 install(TARGETS ${SPIRV_TOOLS_TARGETS} EXPORT ${SPIRV_TOOLS}Targets 407 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 408 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 409 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) 410 export(EXPORT ${SPIRV_TOOLS}Targets FILE ${SPIRV_TOOLS}Target.cmake) 411 412 spvtools_config_package_dir(${SPIRV_TOOLS} PACKAGE_DIR) 413 install(EXPORT ${SPIRV_TOOLS}Targets FILE ${SPIRV_TOOLS}Target.cmake DESTINATION ${PACKAGE_DIR}) 414 415 # Special config file for root library compared to other libs. 416 file(WRITE ${CMAKE_BINARY_DIR}/${SPIRV_TOOLS}Config.cmake 417 "include(\${CMAKE_CURRENT_LIST_DIR}/${SPIRV_TOOLS}Target.cmake)\n" 418 "set(${SPIRV_TOOLS}_LIBRARIES ${SPIRV_TOOLS})\n" 419 "get_target_property(${SPIRV_TOOLS}_INCLUDE_DIRS ${SPIRV_TOOLS} INTERFACE_INCLUDE_DIRECTORIES)\n") 420 install(FILES ${CMAKE_BINARY_DIR}/${SPIRV_TOOLS}Config.cmake DESTINATION ${PACKAGE_DIR}) 421endif(ENABLE_SPIRV_TOOLS_INSTALL) 422 423if(MSVC AND (NOT ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))) 424 # Enable parallel builds across four cores for this lib 425 add_definitions(/MP4) 426endif() 427