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