2023-05-03 15:25:17 +00:00
# Copyright (c) 2015-2023 The Khronos Group Inc.
2015-05-22 17:26:19 +00:00
#
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
2015-05-22 17:26:19 +00:00
#
2016-09-01 19:33:59 +00:00
# http://www.apache.org/licenses/LICENSE-2.0
2015-05-22 17:26:19 +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.
2015-05-22 17:26:19 +00:00
2022-12-21 21:22:17 +00:00
cmake_minimum_required ( VERSION 3.17.2 )
2016-08-08 02:49:00 +00:00
2015-07-29 19:22:09 +00:00
project ( spirv-tools )
2023-01-16 15:52:31 +00:00
2023-07-19 21:47:24 +00:00
# Avoid a bug in CMake 3.22.1. By default it will set -std=c++11 for
# targets in test/*, when those tests need -std=c++17.
# https://github.com/KhronosGroup/SPIRV-Tools/issues/5340
# The bug is fixed in CMake 3.22.2
if ( ${ CMAKE_VERSION } VERSION_GREATER_EQUAL "3.22.1" )
if ( ${ CMAKE_VERSION } VERSION_LESS "3.22.2" )
cmake_policy ( SET CMP0128 NEW )
endif ( )
endif ( )
2023-01-16 15:52:31 +00:00
set_property ( GLOBAL PROPERTY USE_FOLDERS ON )
2016-02-02 19:41:35 +00:00
enable_testing ( )
2015-11-18 14:22:10 +00:00
set ( SPIRV_TOOLS "SPIRV-Tools" )
2015-05-22 17:26:19 +00:00
2017-07-04 13:11:40 +00:00
include ( GNUInstallDirs )
2016-04-03 22:21:35 +00:00
set ( CMAKE_POSITION_INDEPENDENT_CODE ON )
2022-12-16 02:12:53 +00:00
2023-01-20 14:17:34 +00:00
# Require at least C++17
2022-12-16 02:12:53 +00:00
if ( NOT CMAKE_CXX_STANDARD )
2023-01-20 14:17:34 +00:00
set ( CMAKE_CXX_STANDARD 17 )
2022-12-16 02:12:53 +00:00
endif ( )
2023-01-20 14:17:34 +00:00
if ( ${ CMAKE_CXX_STANDARD } LESS 17 )
message ( FATAL_ERROR "SPIRV-Tools requires C++17 or later, but is configured for C++${CMAKE_CXX_STANDARD})" )
2022-12-16 02:12:53 +00:00
endif ( )
2023-01-20 14:17:34 +00:00
set ( CMAKE_CXX_EXTENSIONS OFF )
2022-12-16 02:12:53 +00:00
2016-04-03 22:21:35 +00:00
2021-07-16 20:30:04 +00:00
option ( ENABLE_RTTI "Enables RTTI" OFF )
2018-11-23 16:47:37 +00:00
option ( SPIRV_ALLOW_TIMERS "Allow timers via clock_gettime on supported platforms" ON )
2015-05-22 17:26:19 +00:00
if ( "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" )
add_definitions ( -DSPIRV_LINUX )
2018-11-23 16:47:37 +00:00
set ( SPIRV_TIMER_ENABLED ${ SPIRV_ALLOW_TIMERS } )
2019-10-09 15:45:11 +00:00
elseif ( "${CMAKE_SYSTEM_NAME}" STREQUAL "Emscripten" )
add_definitions ( -DSPIRV_EMSCRIPTEN )
2020-05-19 15:43:35 +00:00
elseif ( "${CMAKE_SYSTEM_NAME}" MATCHES "Windows" )
2015-05-22 17:26:19 +00:00
add_definitions ( -DSPIRV_WINDOWS )
2016-12-19 18:26:42 +00:00
elseif ( "${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN" )
add_definitions ( -DSPIRV_WINDOWS )
2015-05-22 17:26:19 +00:00
elseif ( "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" )
add_definitions ( -DSPIRV_MAC )
2019-11-01 17:46:25 +00:00
elseif ( "${CMAKE_SYSTEM_NAME}" STREQUAL "iOS" )
add_definitions ( -DSPIRV_IOS )
2021-06-29 19:14:38 +00:00
elseif ( "${CMAKE_SYSTEM_NAME}" STREQUAL "tvOS" )
add_definitions ( -DSPIRV_TVOS )
2023-06-26 18:54:31 +00:00
elseif ( "${CMAKE_SYSTEM_NAME}" STREQUAL "visionOS" )
add_definitions ( -DSPIRV_VISIONOS )
2016-04-18 14:59:47 +00:00
elseif ( "${CMAKE_SYSTEM_NAME}" STREQUAL "Android" )
add_definitions ( -DSPIRV_ANDROID )
2018-11-23 16:47:37 +00:00
set ( SPIRV_TIMER_ENABLED ${ SPIRV_ALLOW_TIMERS } )
2017-05-28 21:19:58 +00:00
elseif ( "${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD" )
add_definitions ( -DSPIRV_FREEBSD )
2022-09-02 19:30:09 +00:00
elseif ( "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD" )
add_definitions ( -DSPIRV_OPENBSD )
2019-11-26 21:22:59 +00:00
elseif ( "${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia" )
add_definitions ( -DSPIRV_FUCHSIA )
2022-09-02 16:24:12 +00:00
elseif ( "${CMAKE_SYSTEM_NAME}" STREQUAL "GNU" )
add_definitions ( -DSPIRV_GNU )
2023-05-03 15:25:17 +00:00
elseif ( "${CMAKE_SYSTEM_NAME}" STREQUAL "QNX" )
add_definitions ( -DSPIRV_QNX )
2015-05-22 17:26:19 +00:00
else ( )
message ( FATAL_ERROR "Your platform '${CMAKE_SYSTEM_NAME}' is not supported!" )
endif ( )
2018-03-07 14:25:51 +00:00
if ( ${ SPIRV_TIMER_ENABLED } )
add_definitions ( -DSPIRV_TIMER_ENABLED )
endif ( )
2017-11-22 22:03:55 +00:00
2015-11-18 14:22:10 +00:00
if ( "${CMAKE_BUILD_TYPE}" STREQUAL "" )
2015-05-22 17:26:19 +00:00
message ( STATUS "No build type selected, default to Debug" )
set ( CMAKE_BUILD_TYPE "Debug" )
endif ( )
2017-07-04 13:11:40 +00:00
option ( SKIP_SPIRV_TOOLS_INSTALL "Skip installation" ${ SKIP_SPIRV_TOOLS_INSTALL } )
if ( NOT ${ SKIP_SPIRV_TOOLS_INSTALL } )
set ( ENABLE_SPIRV_TOOLS_INSTALL ON )
endif ( )
2017-09-25 16:45:48 +00:00
option ( SPIRV_BUILD_COMPRESSION "Build SPIR-V compressing codec" OFF )
2019-05-24 19:43:59 +00:00
if ( SPIRV_BUILD_COMPRESSION )
message ( FATAL_ERROR "SPIR-V compression codec has been removed from SPIR-V tools. "
" P l e a s e r e m o v e S P I R V _ B U I L D _ C O M P R E S S I O N f r o m y o u r b u i l d o p t i o n s . " )
endif ( SPIRV_BUILD_COMPRESSION )
2017-09-25 16:45:48 +00:00
2020-09-09 08:56:32 +00:00
option ( SPIRV_BUILD_FUZZER "Build spirv-fuzz" OFF )
2021-09-02 22:55:30 +00:00
set ( SPIRV_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to control, via link options, which fuzzing engine should be used" )
2021-08-05 08:11:21 +00:00
option ( SPIRV_BUILD_LIBFUZZER_TARGETS "Build libFuzzer targets" OFF )
2015-11-19 14:22:53 +00:00
option ( SPIRV_WERROR "Enable error on warning" ON )
2018-08-07 13:15:20 +00:00
if ( ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" ) OR ( ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) AND ( NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC" ) ) )
2016-02-29 06:01:04 +00:00
set ( COMPILER_IS_LIKE_GNU TRUE )
endif ( )
if ( ${ COMPILER_IS_LIKE_GNU } )
2018-08-03 12:06:07 +00:00
set ( SPIRV_WARNINGS -Wall -Wextra -Wnon-virtual-dtor -Wno-missing-field-initializers )
if ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
set ( SPIRV_WARNINGS ${ SPIRV_WARNINGS } -Wno-self-assign )
endif ( )
2015-10-15 20:43:14 +00:00
2015-12-09 16:40:56 +00:00
option ( SPIRV_WARN_EVERYTHING "Enable -Weverything" ${ SPIRV_WARN_EVERYTHING } )
2015-11-18 14:22:10 +00:00
if ( ${ SPIRV_WARN_EVERYTHING } )
2015-12-09 16:40:56 +00:00
if ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
set ( SPIRV_WARNINGS ${ SPIRV_WARNINGS }
- W e v e r y t h i n g - W n o - c + + 9 8 - c o m p a t - W n o - c + + 9 8 - c o m p a t - p e d a n t i c - W n o - p a d d e d )
elseif ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
set ( SPIRV_WARNINGS ${ SPIRV_WARNINGS } -Wpedantic -pedantic-errors )
else ( )
message ( STATUS "Unknown compiler ${CMAKE_CXX_COMPILER_ID}, "
" s o S P I R V _ W A R N _ E V E R Y T H I N G h a s n o e f f e c t " )
endif ( )
2015-10-15 20:43:14 +00:00
endif ( )
2015-11-18 14:22:10 +00:00
if ( ${ SPIRV_WERROR } )
set ( SPIRV_WARNINGS ${ SPIRV_WARNINGS } -Werror )
2015-05-22 17:26:19 +00:00
endif ( )
2016-02-29 06:01:04 +00:00
elseif ( MSVC )
2022-01-11 16:11:06 +00:00
set ( SPIRV_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS /wd4800 /wd4819 )
2015-11-19 14:22:53 +00:00
if ( ${ SPIRV_WERROR } )
set ( SPIRV_WARNINGS ${ SPIRV_WARNINGS } /WX )
endif ( )
2015-05-22 17:26:19 +00:00
endif ( )
2018-07-11 14:27:34 +00:00
include_directories ( ${ CMAKE_CURRENT_SOURCE_DIR } / )
2016-06-02 22:51:05 +00:00
2015-11-12 16:44:42 +00:00
option ( SPIRV_COLOR_TERMINAL "Enable color terminal output" ON )
if ( ${ SPIRV_COLOR_TERMINAL } )
add_definitions ( -DSPIRV_COLOR_TERMINAL )
2015-05-22 17:26:19 +00:00
endif ( )
2016-09-08 15:43:48 +00:00
option ( SPIRV_LOG_DEBUG "Enable excessive debug output" OFF )
if ( ${ SPIRV_LOG_DEBUG } )
add_definitions ( -DSPIRV_LOG_DEBUG )
endif ( )
2017-08-16 20:42:50 +00:00
if ( DEFINED SPIRV_TOOLS_EXTRA_DEFINITIONS )
add_definitions ( ${ SPIRV_TOOLS_EXTRA_DEFINITIONS } )
endif ( )
2020-10-29 13:25:26 +00:00
# Library build setting definitions:
#
# * SPIRV_TOOLS_BUILD_STATIC - ON or OFF - Defaults to ON.
# If enabled the following targets will be created:
# ${SPIRV_TOOLS}-static - STATIC library.
# Has full public symbol visibility.
# ${SPIRV_TOOLS}-shared - SHARED library.
# Has default-hidden symbol visibility.
# ${SPIRV_TOOLS} - will alias to one of above, based on BUILD_SHARED_LIBS.
# If disabled the following targets will be created:
# ${SPIRV_TOOLS} - either STATIC or SHARED based on SPIRV_TOOLS_LIBRARY_TYPE.
# Has full public symbol visibility.
# ${SPIRV_TOOLS}-shared - SHARED library.
# Has default-hidden symbol visibility.
#
# * SPIRV_TOOLS_LIBRARY_TYPE - SHARED or STATIC.
# Specifies the library type used for building SPIRV-Tools libraries.
# Defaults to SHARED when BUILD_SHARED_LIBS=1, otherwise STATIC.
#
# * SPIRV_TOOLS_FULL_VISIBILITY - "${SPIRV_TOOLS}-static" or "${SPIRV_TOOLS}"
# Evaluates to the SPIRV_TOOLS target library name that has no hidden symbols.
# This is used by internal targets for accessing symbols that are non-public.
# Note this target provides no API stability guarantees.
#
# Ideally, all of these will go away - see https://github.com/KhronosGroup/SPIRV-Tools/issues/3909.
2021-10-29 18:04:59 +00:00
option ( ENABLE_EXCEPTIONS_ON_MSVC "Build SPIRV-TOOLS with c++ exceptions enabled in MSVC" ON )
2020-10-29 13:25:26 +00:00
option ( SPIRV_TOOLS_BUILD_STATIC "Build ${SPIRV_TOOLS}-static target. ${SPIRV_TOOLS} will alias to ${SPIRV_TOOLS}-static or ${SPIRV_TOOLS}-shared based on BUILD_SHARED_LIBS" ON )
if ( SPIRV_TOOLS_BUILD_STATIC )
set ( SPIRV_TOOLS_FULL_VISIBILITY ${ SPIRV_TOOLS } -static )
set ( SPIRV_TOOLS_LIBRARY_TYPE "STATIC" )
else ( SPIRV_TOOLS_BUILD_STATIC )
set ( SPIRV_TOOLS_FULL_VISIBILITY ${ SPIRV_TOOLS } )
if ( NOT DEFINED SPIRV_TOOLS_LIBRARY_TYPE )
if ( BUILD_SHARED_LIBS )
set ( SPIRV_TOOLS_LIBRARY_TYPE "SHARED" )
else ( )
set ( SPIRV_TOOLS_LIBRARY_TYPE "STATIC" )
endif ( )
endif ( )
endif ( SPIRV_TOOLS_BUILD_STATIC )
2016-01-26 23:04:55 +00:00
function ( spvtools_default_compile_options TARGET )
2015-11-18 14:22:10 +00:00
target_compile_options ( ${ TARGET } PRIVATE ${ SPIRV_WARNINGS } )
2016-02-29 06:01:04 +00:00
if ( ${ COMPILER_IS_LIKE_GNU } )
2016-01-11 15:54:20 +00:00
target_compile_options ( ${ TARGET } PRIVATE
- W a l l - W e x t r a - W n o - l o n g - l o n g - W s h a d o w - W u n d e f - W c o n v e r s i o n
2023-01-20 14:17:34 +00:00
- W n o - s i g n - c o n v e r s i o n - f n o - e x c e p t i o n s )
2021-07-16 20:30:04 +00:00
if ( NOT ENABLE_RTTI )
add_compile_options ( -fno-rtti )
endif ( )
2015-11-18 14:22:10 +00:00
# For good call stacks in profiles, keep the frame pointers.
if ( NOT "${SPIRV_PERF}" STREQUAL "" )
target_compile_options ( ${ TARGET } PRIVATE -fno-omit-frame-pointer )
endif ( )
2022-11-04 21:27:10 +00:00
if ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" )
2015-11-18 14:22:10 +00:00
set ( SPIRV_USE_SANITIZER "" CACHE STRING
" U s e t h e c l a n g s a n i t i z e r [ a d d r e s s | m e m o r y | t h r e a d | . . . ] " )
if ( NOT "${SPIRV_USE_SANITIZER}" STREQUAL "" )
target_compile_options ( ${ TARGET } PRIVATE
- f s a n i t i z e = $ { S P I R V _ U S E _ S A N I T I Z E R } )
2019-04-11 20:33:26 +00:00
set_target_properties ( ${ TARGET } PROPERTIES
L I N K _ F L A G S - f s a n i t i z e = $ { S P I R V _ U S E _ S A N I T I Z E R } )
2015-11-18 14:22:10 +00:00
endif ( )
2018-10-19 15:59:01 +00:00
target_compile_options ( ${ TARGET } PRIVATE
- f t e m p l a t e - d e p t h = 1 0 2 4 )
2016-01-11 15:54:20 +00:00
else ( )
target_compile_options ( ${ TARGET } PRIVATE
- W n o - m i s s i n g - f i e l d - i n i t i a l i z e r s )
2015-11-18 14:22:10 +00:00
endif ( )
2015-05-22 17:26:19 +00:00
endif ( )
2016-02-29 06:01:04 +00:00
2017-04-03 17:41:20 +00:00
if ( MSVC )
# Specify /EHs for exception handling. This makes using SPIRV-Tools as
# dependencies in other projects easier.
2021-10-29 18:04:59 +00:00
if ( ENABLE_EXCEPTIONS_ON_MSVC )
target_compile_options ( ${ TARGET } PRIVATE /EHs )
endif ( )
2017-04-03 17:41:20 +00:00
endif ( )
2016-02-29 06:01:04 +00:00
# For MinGW cross compile, statically link to the C++ runtime.
# But it still depends on MSVCRT.dll.
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Windows" )
2023-07-20 14:09:23 +00:00
if ( NOT MSVC )
2016-08-05 17:46:45 +00:00
set_target_properties ( ${ TARGET } PROPERTIES
L I N K _ F L A G S - s t a t i c - s t a t i c - l i b g c c - s t a t i c - l i b s t d c + + )
2016-02-29 06:01:04 +00:00
endif ( )
endif ( )
2015-11-18 14:22:10 +00:00
endfunction ( )
2015-05-22 17:26:19 +00:00
2016-02-24 15:11:07 +00:00
if ( NOT COMMAND find_host_package )
macro ( find_host_package )
find_package ( ${ ARGN } )
endmacro ( )
endif ( )
if ( NOT COMMAND find_host_program )
macro ( find_host_program )
find_program ( ${ ARGN } )
endmacro ( )
endif ( )
2019-04-12 12:23:19 +00:00
# Tests require Python3
2023-06-19 19:02:41 +00:00
find_host_package ( Python3 REQUIRED )
2016-02-24 15:11:07 +00:00
2018-07-19 14:27:12 +00:00
# Check for symbol exports on Linux.
# At the moment, this check will fail on the OSX build machines for the Android NDK.
# It appears they don't have objdump.
if ( "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" )
2017-11-22 22:03:55 +00:00
macro ( spvtools_check_symbol_exports TARGET )
2018-07-04 18:20:52 +00:00
if ( NOT "${SPIRV_SKIP_TESTS}" )
add_test ( NAME spirv-tools-symbol-exports- ${ TARGET }
2023-06-19 19:02:41 +00:00
C O M M A N D P y t h o n 3 : : I n t e r p r e t e r
2018-07-04 18:20:52 +00:00
$ { s p i r v - t o o l s _ S O U R C E _ D I R } / u t i l s / c h e c k _ s y m b o l _ e x p o r t s . p y " $ < T A R G E T _ F I L E : $ { T A R G E T } > " )
endif ( )
2017-11-22 22:03:55 +00:00
endmacro ( )
else ( )
macro ( spvtools_check_symbol_exports TARGET )
2018-07-04 18:20:52 +00:00
if ( NOT "${SPIRV_SKIP_TESTS}" )
message ( "Skipping symbol exports test for ${TARGET}" )
endif ( )
2017-11-22 22:03:55 +00:00
endmacro ( )
endif ( )
2016-02-22 21:07:19 +00:00
2019-10-17 15:36:55 +00:00
if ( ENABLE_SPIRV_TOOLS_INSTALL )
2023-03-03 15:53:23 +00:00
if ( WIN32 AND NOT MINGW )
2019-10-17 15:36:55 +00:00
macro ( spvtools_config_package_dir TARGET PATH )
set ( ${ PATH } ${ TARGET } /cmake )
endmacro ( )
else ( )
macro ( spvtools_config_package_dir TARGET PATH )
2019-11-22 16:02:25 +00:00
set ( ${ PATH } ${ CMAKE_INSTALL_LIBDIR } /cmake/ ${ TARGET } )
2019-10-17 15:36:55 +00:00
endmacro ( )
endif ( )
macro ( spvtools_generate_config_file TARGET )
file ( WRITE ${ CMAKE_BINARY_DIR } / ${ TARGET } Config.cmake
" include ( CMakeFindDependencyMacro ) \ n "
" find_dependency ( ${ SPIRV_TOOLS } ) \ n "
" include ( \${CMAKE_CURRENT_LIST_DIR}/${TARGET}Targets.cmake)\n"
" set ( ${ TARGET } _LIBRARIES ${ TARGET } ) \ n "
" get_target_property ( ${ TARGET } _INCLUDE_DIRS ${ TARGET } INTERFACE_INCLUDE_DIRECTORIES ) \ n " )
endmacro ( )
endif ( )
2023-11-28 15:53:56 +00:00
# Currently iOS and Android are very similar.
# They both have their own packaging (APP/APK).
# Which makes regular executables/testing problematic.
#
# Currently the only deliverables for these platforms are
# libraries (either STATIC or SHARED).
#
# Furthermore testing is equally problematic.
if ( IOS OR ANDROID )
set ( SPIRV_SKIP_EXECUTABLES ON )
endif ( )
option ( SPIRV_SKIP_EXECUTABLES "Skip building the executable and tests along with the library" )
if ( SPIRV_SKIP_EXECUTABLES )
2016-08-05 17:46:45 +00:00
set ( SPIRV_SKIP_TESTS ON )
endif ( )
2023-11-28 15:53:56 +00:00
option ( SPIRV_SKIP_TESTS "Skip building tests along with the library" )
2015-09-04 19:13:57 +00:00
2017-11-09 16:24:41 +00:00
# Defaults to ON. The checks can be time consuming.
# Turn off if they take too long.
option ( SPIRV_CHECK_CONTEXT "In a debug build, check if the IR context is in a valid state." ON )
if ( ${ SPIRV_CHECK_CONTEXT } )
2021-08-30 13:39:40 +00:00
add_compile_options ( $< $<CONFIG:Debug > :-DSPIRV_CHECK_CONTEXT> )
2017-11-09 16:24:41 +00:00
endif ( )
2018-11-06 14:26:23 +00:00
# Precompiled header macro. Parameters are source file list and filename for pch cpp file.
2018-11-07 14:15:04 +00:00
macro ( spvtools_pch SRCS PCHPREFIX )
2020-04-09 18:46:08 +00:00
if ( MSVC AND CMAKE_GENERATOR MATCHES "^Visual Studio" AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
2018-11-06 14:26:23 +00:00
set ( PCH_NAME "$(IntDir)\\${PCHPREFIX}.pch" )
# make source files use/depend on PCH_NAME
set_source_files_properties ( ${ ${SRCS } } PROPERTIES COMPILE_FLAGS "/Yu${PCHPREFIX}.h /FI${PCHPREFIX}.h /Fp${PCH_NAME} /Zm300" OBJECT_DEPENDS "${PCH_NAME}" )
# make PCHPREFIX.cpp file compile and generate PCH_NAME
set_source_files_properties ( "${PCHPREFIX}.cpp" PROPERTIES COMPILE_FLAGS "/Yc${PCHPREFIX}.h /Fp${PCH_NAME} /Zm300" OBJECT_OUTPUTS "${PCH_NAME}" )
list ( APPEND ${ SRCS } "${PCHPREFIX}.cpp" )
endif ( )
2018-11-07 14:15:04 +00:00
endmacro ( spvtools_pch )
2018-11-06 14:26:23 +00:00
2016-03-17 02:43:31 +00:00
add_subdirectory ( external )
2015-11-18 14:22:10 +00:00
2019-08-07 15:09:55 +00:00
# Warning about extra semi-colons.
#
# This is not supported on all compilers/versions. so enabling only
# for clang, since that works for all versions that our bots run.
#
# This is intentionally done after adding the external subdirectory,
# so we don't enforce this flag on our dependencies, some of which do
# not pass it.
#
# If the minimum version of CMake supported is updated to 3.0 or
# later, then check_cxx_compiler_flag could be used instead.
if ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
add_compile_options ( "-Wextra-semi" )
endif ( )
2016-03-17 02:43:31 +00:00
add_subdirectory ( source )
add_subdirectory ( tools )
2015-05-22 17:26:19 +00:00
2016-03-17 02:43:31 +00:00
add_subdirectory ( test )
2016-09-28 14:50:43 +00:00
add_subdirectory ( examples )
2015-05-22 17:26:19 +00:00
2017-07-04 13:11:40 +00:00
if ( ENABLE_SPIRV_TOOLS_INSTALL )
install (
F I L E S
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / i n c l u d e / s p i r v - t o o l s / l i b s p i r v . h
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / i n c l u d e / s p i r v - t o o l s / l i b s p i r v . h p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / i n c l u d e / s p i r v - t o o l s / o p t i m i z e r . h p p
2017-07-13 00:16:51 +00:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / i n c l u d e / s p i r v - t o o l s / l i n k e r . h p p
2018-11-08 18:54:54 +00:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / i n c l u d e / s p i r v - t o o l s / i n s t r u m e n t . h p p
2017-07-04 13:11:40 +00:00
D E S T I N A T I O N
$ { C M A K E _ I N S T A L L _ I N C L U D E D I R } / s p i r v - t o o l s / )
endif ( ENABLE_SPIRV_TOOLS_INSTALL )
2016-09-02 13:29:52 +00:00
2017-09-28 01:22:05 +00:00
if ( NOT "${SPIRV_SKIP_TESTS}" )
add_test ( NAME spirv-tools-copyrights
2023-06-19 19:02:41 +00:00
C O M M A N D P y t h o n 3 : : I n t e r p r e t e r u t i l s / c h e c k _ c o p y r i g h t . p y
2017-09-28 01:22:05 +00:00
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } )
2017-11-22 22:03:55 +00:00
endif ( )
2017-11-25 17:58:50 +00:00
2020-02-20 15:54:54 +00:00
set ( SPIRV_LIBRARIES "-lSPIRV-Tools-opt -lSPIRV-Tools -lSPIRV-Tools-link" )
2018-02-02 22:37:14 +00:00
set ( SPIRV_SHARED_LIBRARIES "-lSPIRV-Tools-shared" )
2017-11-25 17:58:50 +00:00
# Build pkg-config file
# Use a first-class target so it's regenerated when relevant files are updated.
2024-03-25 21:21:09 +00:00
add_custom_command (
O U T P U T $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / S P I R V - T o o l s . p c
2018-02-14 23:27:22 +00:00
C O M M A N D $ { C M A K E _ C O M M A N D }
- D C H A N G E S _ F I L E = $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / C H A N G E S
2017-11-25 17:58:50 +00:00
- D T E M P L A T E _ F I L E = $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / S P I R V - T o o l s . p c . i n
- D O U T _ F I L E = $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / S P I R V - T o o l s . p c
- D C M A K E _ I N S T A L L _ P R E F I X = $ { C M A K E _ I N S T A L L _ P R E F I X }
2018-02-09 11:30:08 +00:00
- D C M A K E _ I N S T A L L _ L I B D I R = $ { C M A K E _ I N S T A L L _ L I B D I R }
- D C M A K E _ I N S T A L L _ I N C L U D E D I R = $ { C M A K E _ I N S T A L L _ I N C L U D E D I R }
2017-11-25 17:58:50 +00:00
- D S P I R V _ L I B R A R I E S = $ { S P I R V _ L I B R A R I E S }
- P $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / w r i t e _ p k g _ c o n f i g . c m a k e
2024-03-25 21:21:09 +00:00
D E P E N D S " C H A N G E S " " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / S P I R V - T o o l s . p c . i n " " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / w r i t e _ p k g _ c o n f i g . c m a k e " )
add_custom_command (
O U T P U T $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / S P I R V - T o o l s - s h a r e d . p c
2018-02-14 23:27:22 +00:00
C O M M A N D $ { C M A K E _ C O M M A N D }
- D C H A N G E S _ F I L E = $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / C H A N G E S
2018-02-02 22:37:14 +00:00
- D T E M P L A T E _ F I L E = $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / S P I R V - T o o l s - s h a r e d . p c . i n
- D O U T _ F I L E = $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / S P I R V - T o o l s - s h a r e d . p c
- D C M A K E _ I N S T A L L _ P R E F I X = $ { C M A K E _ I N S T A L L _ P R E F I X }
2018-02-09 11:30:08 +00:00
- D C M A K E _ I N S T A L L _ L I B D I R = $ { C M A K E _ I N S T A L L _ L I B D I R }
- D C M A K E _ I N S T A L L _ I N C L U D E D I R = $ { C M A K E _ I N S T A L L _ I N C L U D E D I R }
2018-02-02 22:37:14 +00:00
- D S P I R V _ S H A R E D _ L I B R A R I E S = $ { S P I R V _ S H A R E D _ L I B R A R I E S }
- P $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / w r i t e _ p k g _ c o n f i g . c m a k e
2024-03-25 21:21:09 +00:00
D E P E N D S " C H A N G E S " " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / S P I R V - T o o l s - s h a r e d . p c . i n " " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / w r i t e _ p k g _ c o n f i g . c m a k e " )
add_custom_target ( spirv-tools-pkg-config
A L L
D E P E N D S $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / S P I R V - T o o l s - s h a r e d . p c $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / S P I R V - T o o l s . p c )
2017-11-25 17:58:50 +00:00
# Install pkg-config file
if ( ENABLE_SPIRV_TOOLS_INSTALL )
install (
F I L E S
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / S P I R V - T o o l s . p c
2018-02-02 22:37:14 +00:00
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / S P I R V - T o o l s - s h a r e d . p c
2017-11-25 17:58:50 +00:00
D E S T I N A T I O N
$ { C M A K E _ I N S T A L L _ L I B D I R } / p k g c o n f i g )
endif ( )