From 1ce7ee30b7b73c7f1bde423977499a8c23d2cf98 Mon Sep 17 00:00:00 2001 From: Jens Weggemann Date: Fri, 12 Oct 2018 06:27:22 +0200 Subject: [PATCH] [shaderc] Fix for build (#4398) * [shaderc] Fix for build * [glslang] Use 'd' debug suffix on all platforms * [shaderc][spirv-tools] Restore missing cmake options --- .../0001-Fix-export-symbol-for-Windows.patch | 86 ------------------- ports/glslang/CONTROL | 2 +- ports/glslang/portfile.cmake | 7 +- ports/shaderc/CMakeLists.txt | 4 +- ports/shaderc/CMakeLists_spirv.txt | 12 +-- ports/shaderc/CONTROL | 2 +- ports/shaderc/portfile.cmake | 19 +--- ports/spirv-tools/portfile.cmake | 11 ++- 8 files changed, 19 insertions(+), 124 deletions(-) delete mode 100644 ports/glslang/0001-Fix-export-symbol-for-Windows.patch diff --git a/ports/glslang/0001-Fix-export-symbol-for-Windows.patch b/ports/glslang/0001-Fix-export-symbol-for-Windows.patch deleted file mode 100644 index 80ce58da48..0000000000 --- a/ports/glslang/0001-Fix-export-symbol-for-Windows.patch +++ /dev/null @@ -1,86 +0,0 @@ -From 1ccadd2cb6db3ce5a00635f65db21e561eb7f705 Mon Sep 17 00:00:00 2001 -From: vlj -Date: Fri, 25 Nov 2016 17:12:35 +0100 -Subject: [PATCH] Fix export symbol for Windows. - ---- - StandAlone/CMakeLists.txt | 1 + - StandAlone/ResourceLimits.cpp | 3 +++ - StandAlone/ResourceLimits.h | 10 ++++++++++ - 3 files changed, 14 insertions(+) - -diff --git a/StandAlone/CMakeLists.txt b/StandAlone/CMakeLists.txt -index 231ba27..3aff02e 100644 ---- a/StandAlone/CMakeLists.txt -+++ b/StandAlone/CMakeLists.txt -@@ -2,6 +2,7 @@ add_library(glslang-default-resource-limits - ${CMAKE_CURRENT_SOURCE_DIR}/ResourceLimits.cpp - ) - set_property(TARGET glslang-default-resource-limits PROPERTY FOLDER glslang) -+set_property(TARGET glslang-default-resource-limits PROPERTY COMPILE_DEFINITIONS DLLEXPORT) - - target_include_directories(glslang-default-resource-limits - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} -diff --git a/StandAlone/ResourceLimits.cpp b/StandAlone/ResourceLimits.cpp -index e22ec80..634d9c9 100644 ---- a/StandAlone/ResourceLimits.cpp -+++ b/StandAlone/ResourceLimits.cpp -@@ -41,6 +41,7 @@ - - namespace glslang { - -+DLL_EXPORT - const TBuiltInResource DefaultTBuiltInResource = { - /* .MaxLights = */ 32, - /* .MaxClipPlanes = */ 6, -@@ -137,6 +138,7 @@ const TBuiltInResource DefaultTBuiltInResource = { - /* .generalConstantMatrixVectorIndexing = */ 1, - }}; - -+DLL_EXPORT - std::string GetDefaultTBuiltInResourceString() - { - std::ostringstream ostream; -@@ -239,6 +241,7 @@ std::string GetDefaultTBuiltInResourceString() - return ostream.str(); - } - -+DLL_EXPORT - void DecodeResourceLimits(TBuiltInResource* resources, char* config) - { - static const char* delims = " \t\n\r"; -diff --git a/StandAlone/ResourceLimits.h b/StandAlone/ResourceLimits.h -index 9c3eb3e..932a59f 100644 ---- a/StandAlone/ResourceLimits.h -+++ b/StandAlone/ResourceLimits.h -@@ -39,17 +39,27 @@ - - #include "glslang/Include/ResourceLimits.h" - -+#ifdef DLLEXPORT -+#define DLL_EXPORT __declspec(dllexport) -+#else -+#define DLL_EXPORT __declspec(dllimport) -+#endif -+ - namespace glslang { - - // These are the default resources for TBuiltInResources, used for both - // - parsing this string for the case where the user didn't supply one, - // - dumping out a template for user construction of a config file. -+ -+DLL_EXPORT - extern const TBuiltInResource DefaultTBuiltInResource; - - // Returns the DefaultTBuiltInResource as a human-readable string. -+DLL_EXPORT - std::string GetDefaultTBuiltInResourceString(); - - // Decodes the resource limits from |config| to |resources|. -+DLL_EXPORT - void DecodeResourceLimits(TBuiltInResource* resources, char* config); - - } // end namespace glslang --- -2.10.2.windows.1 - diff --git a/ports/glslang/CONTROL b/ports/glslang/CONTROL index 22d5a054ec..c924828436 100644 --- a/ports/glslang/CONTROL +++ b/ports/glslang/CONTROL @@ -1,3 +1,3 @@ Source: glslang -Version: 2018-03-02 +Version: 2018-03-02-1 Description: Khronos reference front-end for GLSL and ESSL, and sample SPIR-V generator diff --git a/ports/glslang/portfile.cmake b/ports/glslang/portfile.cmake index 2182d9bcd0..b7cbdb98e2 100644 --- a/ports/glslang/portfile.cmake +++ b/ports/glslang/portfile.cmake @@ -1,8 +1,6 @@ include(vcpkg_common_functions) -if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - message(WARNING "Dynamic not supported. Building static") - set(VCPKG_LIBRARY_LINKAGE "static") -endif() + +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH @@ -15,6 +13,7 @@ vcpkg_from_github( vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA + OPTIONS -DCMAKE_DEBUG_POSTFIX=d ) vcpkg_install_cmake() diff --git a/ports/shaderc/CMakeLists.txt b/ports/shaderc/CMakeLists.txt index 580ffa1d13..7ecdd03f91 100644 --- a/ports/shaderc/CMakeLists.txt +++ b/ports/shaderc/CMakeLists.txt @@ -15,8 +15,8 @@ ENDIF() add_library(glslang STATIC IMPORTED GLOBAL) set_property(TARGET glslang PROPERTY IMPORTED_LOCATION "${GLSLANG}") -set(glslang_SOURCE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include" CACHE STRING "glslang source dir") -set_property(TARGET glslang APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") +find_path(glslang_SOURCE_DIR glslang/Include/Common) +set_property(TARGET glslang APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${glslang_SOURCE_DIR}") add_library(OSDependent STATIC IMPORTED GLOBAL) set_property(TARGET OSDependent PROPERTY IMPORTED_LOCATION "${OSDEPENDENT}") diff --git a/ports/shaderc/CMakeLists_spirv.txt b/ports/shaderc/CMakeLists_spirv.txt index 618177fa65..d9e0136012 100644 --- a/ports/shaderc/CMakeLists_spirv.txt +++ b/ports/shaderc/CMakeLists_spirv.txt @@ -1,14 +1,8 @@ -option(SUFFIX_D "Add d Suffix to lib" ${SUFFIX_D}) -if(NOT SUFFIX_D) - find_library(SPIRVTOOLSOPT spirv-tools-opt) - find_library(SPIRVTOOLS spirv-tools) -ELSE() - find_library(SPIRVTOOLSOPT spirv-tools-opt) - find_library(SPIRVTOOLS spirv-tools) -ENDIF() +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}") \ No newline at end of file +set_property(TARGET SPIRV-Tools PROPERTY IMPORTED_LOCATION "${SPIRVTOOLS}") diff --git a/ports/shaderc/CONTROL b/ports/shaderc/CONTROL index 5a5c2c5800..c428c0ea9e 100644 --- a/ports/shaderc/CONTROL +++ b/ports/shaderc/CONTROL @@ -1,4 +1,4 @@ Source: shaderc -Version: 12fb656ab20ea9aa06e7084a74e5ff832b7ce2da-1 +Version: 12fb656ab20ea9aa06e7084a74e5ff832b7ce2da-2 Description: A collection of tools, libraries and tests for shader compilation. Build-Depends: glslang, spirv-tools diff --git a/ports/shaderc/portfile.cmake b/ports/shaderc/portfile.cmake index 2b925455b5..d3ed5d0238 100644 --- a/ports/shaderc/portfile.cmake +++ b/ports/shaderc/portfile.cmake @@ -1,11 +1,3 @@ -# Common Ambient Variables: -# VCPKG_ROOT_DIR = -# TARGET_TRIPLET is the current triplet (x86-windows, etc) -# PORT is the current port name (zlib, etc) -# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT} -# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET} -# - include(vcpkg_common_functions) vcpkg_from_github( @@ -14,11 +6,8 @@ vcpkg_from_github( REF 12fb656ab20ea9aa06e7084a74e5ff832b7ce2da SHA512 6fb45a0b01e6709c44a11658648b9271fe06bd94023dcc5042c47b5f2a04889c2efb0ab4c166f18728594ac9b9aa9f8b354af46d88eb7f7c39c7246f52f5a933 HEAD_REF master -) - -vcpkg_apply_patches( - SOURCE_PATH ${SOURCE_PATH} - PATCHES ${CMAKE_CURRENT_LIST_DIR}/0001-Do-not-generate-build-version.inc.patch + PATCHES + 0001-Do-not-generate-build-version.inc.patch ) file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}/third_party/glslang) @@ -36,11 +25,11 @@ endif() # shaderc uses python to manipulate copyright information vcpkg_find_acquire_program(PYTHON3) get_filename_component(PYTHON3_EXE_PATH ${PYTHON3} DIRECTORY) -set(ENV{PATH} "${PYTHON3_EXE_PATH};$ENV{PATH}") +vcpkg_add_to_path(PREPEND "${PYTHON3_EXE_PATH}") vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} - OPTIONS -DSHADERC_SKIP_TESTS=true ${OPTIONS} + OPTIONS -DSHADERC_SKIP_TESTS=true ${OPTIONS} -Dglslang_SOURCE_DIR=${CURRENT_INSTALLED_DIR}/include OPTIONS_DEBUG -DSUFFIX_D=true OPTIONS_RELEASE -DSUFFIX_D=false ) diff --git a/ports/spirv-tools/portfile.cmake b/ports/spirv-tools/portfile.cmake index 5120dc4f1b..11d332a392 100644 --- a/ports/spirv-tools/portfile.cmake +++ b/ports/spirv-tools/portfile.cmake @@ -1,9 +1,6 @@ include(vcpkg_common_functions) -if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - message(WARNING "Dynamic not supported. Building static") - set(VCPKG_LIBRARY_LINKAGE "static") -endif() +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH @@ -23,12 +20,14 @@ vcpkg_from_github( vcpkg_find_acquire_program(PYTHON3) get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY) -set(ENV{PATH} "$ENV{PATH};${PYTHON3_DIR}") +vcpkg_add_to_path("${PYTHON3_DIR}") vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA - OPTIONS -DSPIRV-Headers_SOURCE_DIR=${SPIRV_HEADERS_PATH} + OPTIONS + -DSPIRV-Headers_SOURCE_DIR=${SPIRV_HEADERS_PATH} + -DSPIRV_WERROR=OFF ) vcpkg_install_cmake()