[shaderc, spirv-tools] Fix cmake config, add usage, minor fixes (#31912)

* [spirv-tools] Lower-case dirs for cmake config

* Simplify CMake config fixup

* Add usage

* Update versions

* [shaderc] Minor fixes

* Fix package imports in build and exported config

* Add usage - shaderc_util is a private lib

The port never installed this lib's headers.

* Fix pc file installation

* Update versions

* [spirv-tools] Add tools feature

* [spirv-tools] Fix exported cmake config

* [shaderc] Fis SPIRV-Tools target

* Fix tools feature
This commit is contained in:
Kai Pastor 2023-06-14 05:48:27 +02:00 committed by GitHub
parent 1895329838
commit 4cca179bd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 249 additions and 213 deletions

View File

@ -0,0 +1,70 @@
diff --git a/libshaderc/CMakeLists.txt b/libshaderc/CMakeLists.txt
index d3bc639..6432a9b 100644
--- a/libshaderc/CMakeLists.txt
+++ b/libshaderc/CMakeLists.txt
@@ -28,7 +28,9 @@ if (NOT BUILD_SHARED_LIBS)
add_library(shaderc STATIC ${SHADERC_SOURCES})
shaderc_default_compile_options(shaderc)
target_include_directories(shaderc
- PUBLIC include
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:include>
PRIVATE ${glslang_SOURCE_DIR}
${SPIRV-Headers_SOURCE_DIR}/include)
set(shaderc_install_target shaderc)
@@ -37,7 +39,9 @@ else()
add_library(shaderc_shared SHARED ${SHADERC_SOURCES})
shaderc_default_compile_options(shaderc_shared)
target_include_directories(shaderc_shared
- PUBLIC include
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:include>
PRIVATE ${glslang_SOURCE_DIR}
${SPIRV-Headers_SOURCE_DIR}/include)
target_compile_definitions(shaderc_shared
@@ -60,9 +64,14 @@ if(SHADERC_ENABLE_INSTALL)
${CMAKE_INSTALL_INCLUDEDIR}/shaderc)
install(TARGETS ${shaderc_install_target} shaderc_util
+ EXPORT unofficial-shaderc-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(EXPORT unofficial-shaderc-targets
+ NAMESPACE unofficial::shaderc::
+ DESTINATION share/unofficial-shaderc
+ )
endif(SHADERC_ENABLE_INSTALL)
find_package(Threads)
@@ -79,6 +88,15 @@ else()
target_link_libraries(shaderc_shared PRIVATE ${SHADERC_LIBS})
endif()
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-shaderc-config.cmake" [[
+include(CMakeFindDependencyMacro)
+find_dependency(glslang CONFIG)
+find_dependency(SPIRV-Tools CONFIG)
+find_dependency(SPIRV-Tools-opt CONFIG)
+include("${CMAKE_CURRENT_LIST_DIR}/unofficial-shaderc-targets.cmake")
+]])
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-shaderc-config.cmake DESTINATION share/unofficial-shaderc)
+
shaderc_add_tests(
TEST_PREFIX shaderc
LINK_LIBS shaderc
diff --git a/libshaderc_util/CMakeLists.txt b/libshaderc_util/CMakeLists.txt
index 99ce3c4..3d5a222 100644
--- a/libshaderc_util/CMakeLists.txt
+++ b/libshaderc_util/CMakeLists.txt
@@ -39,7 +39,7 @@ add_library(shaderc_util STATIC
shaderc_default_compile_options(shaderc_util)
target_include_directories(shaderc_util
- PUBLIC include PRIVATE ${glslang_SOURCE_DIR})
+ PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> PRIVATE ${glslang_SOURCE_DIR})
# We use parts of Glslang's HLSL compilation interface, which
# now requires this preprocessor definition.
add_definitions(-DENABLE_HLSL)

View File

@ -0,0 +1,16 @@
set(SHADERC_GLSLANG_DIR "" CACHE STRING "unused")
find_package(glslang CONFIG REQUIRED)
add_library(glslang ALIAS glslang::glslang)
add_library(HLSL ALIAS glslang::HLSL)
add_library(MachineIndependent ALIAS glslang::MachineIndependent)
add_library(OSDependent ALIAS glslang::OSDependent)
add_library(OGLCompiler ALIAS glslang::OGLCompiler)
add_library(SPIRV ALIAS glslang::SPIRV)
find_path(glslang_SOURCE_DIR glslang/Public/ShaderLang.h REQUIRED)
set(glslang_SOURCE_DIR "${glslang_SOURCE_DIR}/glslang" "${glslang_SOURCE_DIR}" CACHE STRING "" FORCE)
set(SHADERC_SPIRV_TOOLS_DIR "" CACHE STRING "unused")
find_package(SPIRV-Tools CONFIG REQUIRED)
add_library(SPIRV-Tools ALIAS SPIRV-Tools-static) # as linked by SPIRV-Tools-opt
find_package(SPIRV-Tools-opt CONFIG REQUIRED)

View File

@ -1,5 +1,19 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 52ebd1c..f73252f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -144,6 +144,8 @@ function(define_pkg_config_file NAME LIBS)
endif()
endfunction()
+if(BUILD_SHARED_LIBS)
define_pkg_config_file(shaderc -lshaderc_shared)
+else()
define_pkg_config_file(shaderc_static "-lshaderc ${EXTRA_STATIC_PKGCONFIG_LIBS} -lshaderc_util")
-define_pkg_config_file(shaderc_combined -lshaderc_combined)
+endif()
diff --git a/libshaderc/CMakeLists.txt b/libshaderc/CMakeLists.txt
index 3ada419..f3277f0 100644
index 3ada419..d3bc639 100644
--- a/libshaderc/CMakeLists.txt
+++ b/libshaderc/CMakeLists.txt
@@ -24,13 +24,16 @@ set(SHADERC_SOURCES
@ -33,7 +47,7 @@ index 3ada419..f3277f0 100644
${CMAKE_INSTALL_INCLUDEDIR}/shaderc)
- install(TARGETS shaderc shaderc_shared
+ install(TARGETS ${shaderc_install_target}
+ install(TARGETS ${shaderc_install_target} shaderc_util
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@ -1,93 +0,0 @@
diff --git a/libshaderc/CMakeLists.txt b/libshaderc/CMakeLists.txt
index f3277f0..5fd58ef 100644
--- a/libshaderc/CMakeLists.txt
+++ b/libshaderc/CMakeLists.txt
@@ -28,7 +28,9 @@ if (NOT BUILD_SHARED_LIBS)
add_library(shaderc STATIC ${SHADERC_SOURCES})
shaderc_default_compile_options(shaderc)
target_include_directories(shaderc
- PUBLIC include
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
+ $<INSTALL_INTERFACE:include/>
PRIVATE ${glslang_SOURCE_DIR}
${SPIRV-Headers_SOURCE_DIR}/include)
set(shaderc_install_target shaderc)
@@ -37,7 +39,9 @@ else()
add_library(shaderc_shared SHARED ${SHADERC_SOURCES})
shaderc_default_compile_options(shaderc_shared)
target_include_directories(shaderc_shared
- PUBLIC include
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
+ $<INSTALL_INTERFACE:include/>
PRIVATE ${glslang_SOURCE_DIR}
${SPIRV-Headers_SOURCE_DIR}/include)
target_compile_definitions(shaderc_shared
@@ -59,10 +63,14 @@ if(SHADERC_ENABLE_INSTALL)
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/shaderc)
- install(TARGETS ${shaderc_install_target}
+ install(TARGETS ${shaderc_install_target} EXPORT unofficial-shadercTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(EXPORT unofficial-shadercTargets
+ NAMESPACE unofficial::shaderc::
+ DESTINATION share/unofficial-shaderc
+ )
endif(SHADERC_ENABLE_INSTALL)
find_package(Threads)
@@ -79,6 +87,11 @@ else()
target_link_libraries(shaderc_shared PRIVATE ${SHADERC_LIBS})
endif()
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-shaderc-config.cmake.in"
+[[include("${CMAKE_CURRENT_LIST_DIR}/unofficial-shadercTargets.cmake")]])
+configure_file("${CMAKE_CURRENT_BINARY_DIR}/unofficial-shaderc-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/unofficial-shaderc-config.cmake" @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-shaderc-config.cmake DESTINATION share/unofficial-shaderc)
+
shaderc_add_tests(
TEST_PREFIX shaderc
LINK_LIBS shaderc
diff --git a/libshaderc_util/CMakeLists.txt b/libshaderc_util/CMakeLists.txt
index 4926203..b152d7b 100644
--- a/libshaderc_util/CMakeLists.txt
+++ b/libshaderc_util/CMakeLists.txt
@@ -39,7 +39,10 @@ add_library(shaderc_util STATIC
shaderc_default_compile_options(shaderc_util)
target_include_directories(shaderc_util
- PUBLIC include PRIVATE ${glslang_SOURCE_DIR})
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
+ $<INSTALL_INTERFACE:include/>
+ PRIVATE ${glslang_SOURCE_DIR})
# We use parts of Glslang's HLSL compilation interface, which
# now requires this preprocessor definition.
add_definitions(-DENABLE_HLSL)
@@ -50,12 +53,21 @@ target_link_libraries(shaderc_util PRIVATE
SPIRV-Tools-opt ${CMAKE_THREAD_LIBS_INIT})
if(SHADERC_ENABLE_INSTALL AND NOT BUILD_SHARED_LIBS)
- install(TARGETS shaderc_util
+ install(TARGETS shaderc_util EXPORT unofficial-shaderc_utilTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(EXPORT unofficial-shaderc_utilTargets
+ NAMESPACE unofficial::shaderc_util::
+ DESTINATION share/unofficial-shaderc_util
+ )
endif(SHADERC_ENABLE_INSTALL)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-shaderc_util-config.cmake.in"
+[[include("${CMAKE_CURRENT_LIST_DIR}/unofficial-shaderc_utilTargets.cmake")]])
+configure_file("${CMAKE_CURRENT_BINARY_DIR}/unofficial-shaderc_util-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/unofficial-shaderc_util-config.cmake" @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-shaderc_util-config.cmake DESTINATION share/unofficial-shaderc_util)
+
shaderc_add_tests(
TEST_PREFIX shaderc_util
LINK_LIBS shaderc_util

View File

@ -1,18 +0,0 @@
diff --git a/libshaderc_util/CMakeLists.txt b/libshaderc_util/CMakeLists.txt
index 99ce3c4..4926203 100644
--- a/libshaderc_util/CMakeLists.txt
+++ b/libshaderc_util/CMakeLists.txt
@@ -49,6 +49,13 @@ target_link_libraries(shaderc_util PRIVATE
glslang OSDependent OGLCompiler HLSL glslang SPIRV
SPIRV-Tools-opt ${CMAKE_THREAD_LIBS_INIT})
+if(SHADERC_ENABLE_INSTALL AND NOT BUILD_SHARED_LIBS)
+ install(TARGETS shaderc_util
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+endif(SHADERC_ENABLE_INSTALL)
+
shaderc_add_tests(
TEST_PREFIX shaderc_util
LINK_LIBS shaderc_util

View File

@ -1,22 +0,0 @@
cmake_minimum_required(VERSION 3.11)
find_package(glslang CONFIG REQUIRED)
set_property(TARGET glslang::glslang PROPERTY IMPORTED_GLOBAL TRUE)
set_property(TARGET glslang::OSDependent PROPERTY IMPORTED_GLOBAL TRUE)
set_property(TARGET glslang::OGLCompiler PROPERTY IMPORTED_GLOBAL TRUE)
set_property(TARGET glslang::HLSL PROPERTY IMPORTED_GLOBAL TRUE)
set_property(TARGET glslang::SPIRV PROPERTY IMPORTED_GLOBAL TRUE)
set_property(TARGET glslang::MachineIndependent PROPERTY IMPORTED_GLOBAL TRUE)
add_library(glslang ALIAS glslang::glslang)
add_library(OSDependent ALIAS glslang::OSDependent)
add_library(OGLCompiler ALIAS glslang::OGLCompiler)
add_library(HLSL ALIAS glslang::HLSL)
add_library(SPIRV ALIAS glslang::SPIRV)
add_library(MachineIndependent ALIAS glslang::MachineIndependent)
find_package(Threads REQUIRED)
find_path(glslang_SOURCE_DIR glslang/Public/ShaderLang.h)
set(glslang_SOURCE_DIR "${glslang_SOURCE_DIR}/glslang" "${glslang_SOURCE_DIR}" CACHE STRING "" FORCE)

View File

@ -10,42 +10,40 @@ vcpkg_from_github(
PATCHES
disable-update-version.patch
fix-build-type.patch
fix-install-shaderc_util.patch
fix-export-cmakefiles.patch
cmake-config-export.patch
# NOTE: This should be removed when shaderc gets updated to use glslang 11.12.0
fix-tbuiltinresource-for-glslang-11-12.patch
)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/build-version.inc" DESTINATION "${SOURCE_PATH}/glslc/src")
set(OPTIONS)
set(OPTIONS "")
if(VCPKG_CRT_LINKAGE STREQUAL "dynamic")
list(APPEND OPTIONS -DSHADERC_ENABLE_SHARED_CRT=ON)
endif()
# shaderc uses python to manipulate copyright information
vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_EXE_PATH ${PYTHON3} DIRECTORY)
get_filename_component(PYTHON3_EXE_PATH "${PYTHON3}" DIRECTORY)
vcpkg_add_to_path(PREPEND "${PYTHON3_EXE_PATH}")
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${OPTIONS}
-DSHADERC_SKIP_TESTS=true
-DSHADERC_GLSLANG_DIR=${CMAKE_CURRENT_LIST_DIR}/glslang
-DSHADERC_SPIRV_TOOLS_DIR=${CMAKE_CURRENT_LIST_DIR}/spirv-tools
"-DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_LIST_DIR}/cmake-project-include.cmake"
-DSHADERC_ENABLE_EXAMPLES=OFF
-DSHADERC_SKIP_TESTS=true
)
vcpkg_cmake_install()
vcpkg_fixup_pkgconfig()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-shaderc CONFIG_PATH share/unofficial-shaderc)
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-shaderc_util CONFIG_PATH share/unofficial-shaderc_util)
vcpkg_copy_tools(TOOL_NAMES glslc AUTO_CLEAN)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

View File

@ -1,8 +0,0 @@
find_library(SPIRVTOOLSOPT SPIRV-Tools-opt)
find_library(SPIRVTOOLS SPIRV-Tools)
add_library(SPIRV-Tools-opt STATIC IMPORTED GLOBAL)
set_property(TARGET SPIRV-Tools-opt PROPERTY IMPORTED_LOCATION "${SPIRVTOOLSOPT}")
add_library(SPIRV-Tools STATIC IMPORTED GLOBAL)
set_property(TARGET SPIRV-Tools PROPERTY IMPORTED_LOCATION "${SPIRVTOOLS}")

4
ports/shaderc/usage Normal file
View File

@ -0,0 +1,4 @@
shaderc provides CMake targets:
find_package(unofficial-shaderc CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::shaderc::shaderc)

View File

@ -1,7 +1,7 @@
{
"name": "shaderc",
"version": "2021.1",
"port-version": 3,
"port-version": 4,
"description": "A collection of tools, libraries and tests for shader compilation.",
"homepage": "https://github.com/google/shaderc",
"license": "Apache-2.0",

View File

@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1b8fe92..8f3f91a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -269,7 +269,7 @@ else()
endif()
if(ENABLE_SPIRV_TOOLS_INSTALL)
- if(WIN32)
+ if(0)
macro(spvtools_config_package_dir TARGET PATH)
set(${PATH} ${TARGET}/cmake)
endmacro()

View File

@ -0,0 +1,18 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2cf1e40..5f2a86c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -280,8 +280,13 @@ if(ENABLE_SPIRV_TOOLS_INSTALL)
endif()
macro(spvtools_generate_config_file TARGET)
+ set(sgcf_find_extra "")
+ if(NOT "${TARGET}" STREQUAL "SPIRV-Tools-opt")
+ set(sgcf_find_extra "find_dependency(SPIRV-Tools-opt)\n")
+ endif()
file(WRITE ${CMAKE_BINARY_DIR}/${TARGET}Config.cmake
"include(CMakeFindDependencyMacro)\n"
+ ${sgcf_find_extra}
"find_dependency(${SPIRV_TOOLS})\n"
"include(\${CMAKE_CURRENT_LIST_DIR}/${TARGET}Targets.cmake)\n"
"set(${TARGET}_LIBRARIES ${TARGET})\n"

View File

@ -3,86 +3,57 @@ vcpkg_from_github(
REPO KhronosGroup/SPIRV-Tools
REF v2022.4
SHA512 d93e97e168c50f545cc42418603ffc5fa6299bb3cc30d927444e4de0d955abc5dd481c9662a59cd49fc379da6bcc6df6fb747947e3dc144cee9b489aff7c4785
PATCHES
cmake-config-dir.diff
spirv-tools-shared.diff
fix-tool-deps.diff
)
vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
vcpkg_add_to_path("${PYTHON3_DIR}")
if(VCPKG_TARGET_IS_IOS)
message(STATUS "Using iOS trplet. Executables won't be created...")
set(TOOLS_INSTALL OFF)
set(SKIP_EXECUTABLES ON)
else()
set(TOOLS_INSTALL ON)
set(SKIP_EXECUTABLES OFF)
endif()
vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
INVERTED_FEATURES
tools SPIRV_SKIP_EXECUTABLES
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DSPIRV-Headers_SOURCE_DIR=${CURRENT_INSTALLED_DIR}
-DSPIRV_WERROR=OFF
${FEATURE_OPTIONS}
"-DSPIRV-Headers_SOURCE_DIR=${CURRENT_INSTALLED_DIR}"
-DSPIRV_SKIP_TESTS=ON
-DSPIRV_SKIP_EXECUTABLES=${SKIP_EXECUTABLES}
-DENABLE_SPIRV_TOOLS_INSTALL=${TOOLS_INSTALL}
-DSPIRV_TOOLS_BUILD_STATIC=ON
-DENABLE_SPIRV_TOOLS_INSTALL=ON
-DSPIRV_WERROR=OFF
OPTIONS_DEBUG
-DSPIRV_SKIP_EXECUTABLES=ON
)
vcpkg_cmake_install()
# the directory name is capitalized as opposed to the port name
if(WIN32)
vcpkg_cmake_config_fixup(CONFIG_PATH SPIRV-Tools/cmake PACKAGE_NAME SPIRV-Tools)
vcpkg_cmake_config_fixup(CONFIG_PATH SPIRV-Tools-link/cmake PACKAGE_NAME SPIRV-Tools-link)
vcpkg_cmake_config_fixup(CONFIG_PATH SPIRV-Tools-lint/cmake PACKAGE_NAME SPIRV-Tools-lint)
vcpkg_cmake_config_fixup(CONFIG_PATH SPIRV-Tools-opt/cmake PACKAGE_NAME SPIRV-Tools-opt)
vcpkg_cmake_config_fixup(CONFIG_PATH SPIRV-Tools-reduce/cmake PACKAGE_NAME SPIRV-Tools-reduce)
else()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools PACKAGE_NAME SPIRV-Tools DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-link PACKAGE_NAME SPIRV-Tools-link DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-lint PACKAGE_NAME SPIRV-Tools-lint DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-opt PACKAGE_NAME SPIRV-Tools-opt DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-reduce PACKAGE_NAME SPIRV-Tools-reduce) # now delete
endif()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools PACKAGE_NAME spirv-tools DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-link PACKAGE_NAME spirv-tools-link DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-lint PACKAGE_NAME spirv-tools-lint DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-opt PACKAGE_NAME spirv-tools-opt DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-reduce PACKAGE_NAME spirv-tools-reduce) # now delete
vcpkg_fixup_pkgconfig()
if(TOOLS_INSTALL)
vcpkg_copy_tools(
TOOL_NAMES
spirv-as
spirv-cfg
spirv-dis
spirv-link
spirv-lint
spirv-opt
spirv-reduce
spirv-val
AUTO_CLEAN
)
if("tools" IN_LIST FEATURES)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
file(RENAME "${CURRENT_PACKAGES_DIR}/bin/spirv-lesspipe.sh" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/spirv-lesspipe.sh")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/spirv-lesspipe.sh")
set(tools spirv-as spirv-cfg spirv-dis spirv-link spirv-lint spirv-opt spirv-val)
if(NOT VCPKG_TARGET_IS_IOS)
list(APPEND tools spirv-reduce)
endif()
vcpkg_copy_tools(TOOL_NAMES ${tools} AUTO_CLEAN)
endif()
if(WIN32)
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/SPIRV-Tools"
"${CURRENT_PACKAGES_DIR}/debug/SPIRV-Tools-link"
"${CURRENT_PACKAGES_DIR}/debug/SPIRV-Tools-lint"
"${CURRENT_PACKAGES_DIR}/debug/SPIRV-Tools-opt"
"${CURRENT_PACKAGES_DIR}/debug/SPIRV-Tools-reduce"
"${CURRENT_PACKAGES_DIR}/SPIRV-Tools"
"${CURRENT_PACKAGES_DIR}/SPIRV-Tools-link"
"${CURRENT_PACKAGES_DIR}/SPIRV-Tools-lint"
"${CURRENT_PACKAGES_DIR}/SPIRV-Tools-opt"
"${CURRENT_PACKAGES_DIR}/SPIRV-Tools-reduce"
)
endif()
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
# lesspipe.sh is the only file there
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

View File

@ -0,0 +1,35 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8f3f91a..2cf1e40 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -389,10 +389,14 @@ add_custom_target(spirv-tools-shared-pkg-config ALL
# Install pkg-config file
if (ENABLE_SPIRV_TOOLS_INSTALL)
+ set(shared_pc "")
+ if(BUILD_SHARED_LIBS)
+ set(shared_pc "${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc")
+ endif()
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc
- ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc
+ ${shared_pc}
DESTINATION
${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 668579a..7874c1a 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -421,6 +421,10 @@ if (ANDROID)
endif()
if(ENABLE_SPIRV_TOOLS_INSTALL)
+ if(NOT BUILD_SHARED_LIBS)
+ set_target_properties(${SPIRV_TOOLS}-shared PROPERTIES EXCLUDE_FROM_ALL 1)
+ list(REMOVE_ITEM SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-shared)
+ endif()
install(TARGETS ${SPIRV_TOOLS_TARGETS} EXPORT ${SPIRV_TOOLS}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

22
ports/spirv-tools/usage Normal file
View File

@ -0,0 +1,22 @@
spirv-tools provides CMake targets:
find_package(SPIRV-Tools CONFIG REQUIRED)
# The static libary is always available.
# It offers full public symbol visibility.
target_link_libraries(main PRIVATE SPIRV-Tools-static)
# In triplets with dynamic library linkage, there is also a shared libary.
target_link_libraries(main PRIVATE SPIRV-Tools-shared)
# The following libraries are static and depend on SPIRV-Tools-static.
find_package(SPIRV-Tools-link CONFIG REQUIRED)
target_link_libraries(main PRIVATE SPIRV-Tools-link)
find_package(SPIRV-Tools-lint CONFIG REQUIRED)
target_link_libraries(main PRIVATE SPIRV-Tools-lint)
find_package(SPIRV-Tools-opt CONFIG REQUIRED)
target_link_libraries(main PRIVATE SPIRV-Tools-opt)
find_package(SPIRV-Tools-reduce CONFIG REQUIRED)
target_link_libraries(main PRIVATE SPIRV-Tools-reduce)

View File

@ -1,6 +1,7 @@
{
"name": "spirv-tools",
"version": "2022.4",
"port-version": 1,
"description": "API and commands for processing SPIR-V modules",
"homepage": "https://github.com/KhronosGroup/SPIRV-Tools",
"license": "Apache-2.0",
@ -14,5 +15,10 @@
"name": "vcpkg-cmake-config",
"host": true
}
]
],
"features": {
"tools": {
"description": "Build tools."
}
}
}

View File

@ -7434,7 +7434,7 @@
},
"shaderc": {
"baseline": "2021.1",
"port-version": 3
"port-version": 4
},
"shaderwriter": {
"baseline": "2.6.0",
@ -7698,7 +7698,7 @@
},
"spirv-tools": {
"baseline": "2022.4",
"port-version": 0
"port-version": 1
},
"spix": {
"baseline": "0.5",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "3a6e1c8ff08a6437170e17cc7b9c6c0bc0113ba2",
"version": "2021.1",
"port-version": 4
},
{
"git-tree": "b33d795ee7bc7bb9a02f904dc4d8e08e5f5f4900",
"version": "2021.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "082a2b7ca21aeafe82dc89765facb7c34675b7b9",
"version": "2022.4",
"port-version": 1
},
{
"git-tree": "38e7ee249f19adf3574548ce895be13919960fdf",
"version": "2022.4",