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 15if (NOT ${SPIRV_SKIP_EXECUTABLES}) 16 add_subdirectory(lesspipe) 17endif() 18add_subdirectory(emacs) 19 20# Add a SPIR-V Tools command line tool. Signature: 21# add_spvtools_tool( 22# TARGET target_name 23# SRCS src_file1.cpp src_file2.cpp 24# LIBS lib_target1 lib_target2 25# ) 26function(add_spvtools_tool) 27 set(one_value_args TARGET) 28 set(multi_value_args SRCS LIBS) 29 cmake_parse_arguments( 30 ARG "" "${one_value_args}" "${multi_value_args}" ${ARGN}) 31 32 add_executable(${ARG_TARGET} ${ARG_SRCS}) 33 spvtools_default_compile_options(${ARG_TARGET}) 34 target_link_libraries(${ARG_TARGET} PRIVATE ${ARG_LIBS}) 35 target_include_directories(${ARG_TARGET} PRIVATE 36 ${spirv-tools_SOURCE_DIR} 37 ${spirv-tools_BINARY_DIR} 38 ) 39 set_property(TARGET ${ARG_TARGET} PROPERTY FOLDER "SPIRV-Tools executables") 40endfunction() 41 42if (NOT ${SPIRV_SKIP_EXECUTABLES}) 43 add_spvtools_tool(TARGET spirv-as SRCS as/as.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) 44 add_spvtools_tool(TARGET spirv-dis SRCS dis/dis.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) 45 add_spvtools_tool(TARGET spirv-val SRCS val/val.cpp util/cli_consumer.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) 46 add_spvtools_tool(TARGET spirv-opt SRCS opt/opt.cpp util/cli_consumer.cpp LIBS SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) 47 if (NOT DEFINED IOS_PLATFORM) # iOS does not allow std::system calls which spirv-reduce requires 48 add_spvtools_tool(TARGET spirv-reduce SRCS reduce/reduce.cpp util/cli_consumer.cpp LIBS SPIRV-Tools-reduce ${SPIRV_TOOLS_FULL_VISIBILITY}) 49 endif() 50 add_spvtools_tool(TARGET spirv-link SRCS link/linker.cpp LIBS SPIRV-Tools-link ${SPIRV_TOOLS_FULL_VISIBILITY}) 51 add_spvtools_tool(TARGET spirv-cfg 52 SRCS cfg/cfg.cpp 53 cfg/bin_to_dot.h 54 cfg/bin_to_dot.cpp 55 LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) 56 target_include_directories(spirv-cfg PRIVATE ${spirv-tools_SOURCE_DIR} 57 ${SPIRV_HEADER_INCLUDE_DIR}) 58 set(SPIRV_INSTALL_TARGETS spirv-as spirv-dis spirv-val spirv-opt 59 spirv-cfg spirv-link) 60 if(NOT DEFINED IOS_PLATFORM) 61 set(SPIRV_INSTALL_TARGETS ${SPIRV_INSTALL_TARGETS} spirv-reduce) 62 endif() 63 64 if(SPIRV_BUILD_FUZZER) 65 add_spvtools_tool(TARGET spirv-fuzz SRCS fuzz/fuzz.cpp util/cli_consumer.cpp LIBS SPIRV-Tools-fuzz ${SPIRV_TOOLS_FULL_VISIBILITY}) 66 set(SPIRV_INSTALL_TARGETS ${SPIRV_INSTALL_TARGETS} spirv-fuzz) 67 endif(SPIRV_BUILD_FUZZER) 68 69 if(ENABLE_SPIRV_TOOLS_INSTALL) 70 install(TARGETS ${SPIRV_INSTALL_TARGETS} 71 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 72 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 73 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) 74 endif(ENABLE_SPIRV_TOOLS_INSTALL) 75endif() 76