diff --git a/recipes/glslang/all/conandata.yml b/recipes/glslang/all/conandata.yml index c41da7c94f094..091cef7cb2d40 100644 --- a/recipes/glslang/all/conandata.yml +++ b/recipes/glslang/all/conandata.yml @@ -1,55 +1,20 @@ +# Add only the SDK release versions from https://github.com/KhronosGroup/glslang/tags for consistency sources: + "1.3.268.0": + url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/vulkan-sdk-1.3.268.0.tar.gz" + sha256: "8cfb4824f185bc246cd41cceedbfcdf14abd3d2fa861512baf81df8a263b9283" + "1.3.261.1": + url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.3.261.1.tar.gz" + sha256: "eb1f9c2ff0a1409151d7749fb37bc1988dc1fd908444c1e4f43d4190c90befcd" + "1.3.243.0": + url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.3.243.0.tar.gz" + sha256: "18b8f296874ac19d034bfb9060238c87b6d67a39af0dfd305d3252762c265f9f" "1.3.239.0": url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.3.239.0.tar.gz" sha256: "8b040328c18399b7bbf5bef84fac3d7b7376b39ec6833b7e19b7961bf7a72017" "1.3.236.0": url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.3.236.0.tar.gz" sha256: "fb6f323a36efcd98766bb72f598008f73c4c92bce69c79fc98ad2b3cdca0c263" - "1.3.231.1": - url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.3.231.1.tar.gz" - sha256: "df3857f01c1aa9ee1927d2feaaa431406d243958e07791e9aed4cb5ab22a5f2b" - "1.3.224.0": - url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.3.224.0.tar.gz" - sha256: "c43c6aa149fa1165e01b375b4d95cbc23b4fc72bd9972a89c55dd1eaa8a360ca" - "1.3.216.0": - url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.3.216.0.tar.gz" - sha256: "3f80a926390faedd33e6ed17ec68340abace83913b285174e2dee87156577be5" - "1.3.211.0": - url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.3.211.0.tar.gz" - sha256: "4335eec84b87d64130e860dad5d6dc1f722277d4e0ff5027153e2743628cb221" - "1.3.204.0": - url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.3.204.0.tar.gz" - sha256: "c6bec993194377944fb8d6d585a90e1288994660782d709e30fa1d91810d6820" - "11.7.0": - url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/11.7.0.tar.gz" - sha256: "b6c83864c3606678d11675114fa5f358c519fe1dad9a781802bcc87fb8fa32d5" - "11.6.0": - url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/11.6.0.tar.gz" - sha256: "99ecd3a0c2c2219293d76723846f762a9f3e7dd0dc2a4f346d0fc3a05a0ce000" - "11.5.0": - url: "https://github.com/KhronosGroup/glslang/archive/11.5.0.tar.gz" - sha256: "fd0b5e3bda591bb08bd3049655a99a0a55f0de4059b9c8f7b397e4b19cf5d51f" - "8.13.3559": - url: "https://github.com/KhronosGroup/glslang/archive/8.13.3559.tar.gz" - sha256: "c58fdcf7e00943ba10f9ae565b2725ec9d5be7dab7c8e82cac72fcaa83c652ca" -patches: - "1.3.239.0": - - patch_file: "patches/1.3.236.0-0001-no-force-glslang-pic.patch" - "1.3.236.0": - - patch_file: "patches/1.3.236.0-0001-no-force-glslang-pic.patch" - "1.3.231.1": - - patch_file: "patches/0001-no-force-glslang-pic.patch" - "1.3.224.0": - - patch_file: "patches/0001-no-force-glslang-pic.patch" - "1.3.216.0": - - patch_file: "patches/0001-no-force-glslang-pic.patch" - "1.3.211.0": - - patch_file: "patches/0001-no-force-glslang-pic.patch" - "1.3.204.0": - - patch_file: "patches/0001-no-force-glslang-pic.patch" - "11.7.0": - - patch_file: "patches/0001-no-force-glslang-pic.patch" - "11.6.0": - - patch_file: "patches/0001-no-force-glslang-pic.patch" - "11.5.0": - - patch_file: "patches/0001-no-force-glslang-pic.patch" + "1.2.198.0": + url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.2.198.0.tar.gz" + sha256: "b2a0541caf01de4fc411cbb32c805a3bd0f6578432e532c5fa6336d187a4a1b1" diff --git a/recipes/glslang/all/conanfile.py b/recipes/glslang/all/conanfile.py index 7d393607fb969..6582079e3edd8 100644 --- a/recipes/glslang/all/conanfile.py +++ b/recipes/glslang/all/conanfile.py @@ -1,11 +1,13 @@ +import os +import re + from conan import ConanFile -from conan.errors import ConanInvalidConfiguration -from conan.tools.apple import is_apple_os +from conan.errors import ConanInvalidConfiguration, ConanException from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rmdir from conan.tools.scm import Version -import os required_conan_version = ">=1.54.0" @@ -14,7 +16,7 @@ class GlslangConan(ConanFile): name = "glslang" description = "Khronos-reference front end for GLSL/ESSL, partial front " \ "end for HLSL, and a SPIR-V generator." - license = ["BSD-3-Clause", "NVIDIA"] + license = "DocumentRef-LICENSE.txt:LicenseRef-glslang" topics = ("glsl", "hlsl", "spirv", "spir-v", "validation", "translation") homepage = "https://github.com/KhronosGroup/glslang" url = "https://github.com/conan-io/conan-center-index" @@ -42,7 +44,6 @@ class GlslangConan(ConanFile): def export_sources(self): copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) - export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -55,30 +56,18 @@ def configure(self): def layout(self): cmake_layout(self, src_folder="src") - @property - def _get_compatible_spirv_tools_version(self): - return { - "11.7.0": "2021.4", - "11.6.0": "2021.3", - "11.5.0": "2021.2", - "8.13.3559": "2020.5", - }.get(str(self.version), self.version) - def requirements(self): if self.options.enable_optimizer: - self.requires(f"spirv-tools/{self._get_compatible_spirv_tools_version}") + self.requires(f"spirv-tools/{self.version}") def validate(self): if self.settings.compiler.get_safe("cppstd"): check_min_cppstd(self, 11) # see https://github.com/KhronosGroup/glslang/issues/2283 - glslang_version = Version(self.version) - if (self.options.shared and - (self.settings.os == "Windows" or \ - (glslang_version >= "7.0.0" and glslang_version < "11.0.0" and is_apple_os(self))) - ): - raise ConanInvalidConfiguration(f"{self.ref} shared library build is broken on {self.settings.os}") + if self.options.shared: + if self.settings.os == "Windows": + raise ConanInvalidConfiguration(f"{self.ref} shared library build is broken on {self.settings.os}") if self.options.enable_optimizer and self.dependencies["spirv-tools"].options.shared: raise ConanInvalidConfiguration( @@ -86,70 +75,56 @@ def validate(self): "because SPIRV-Tools-opt is not built if shared" ) + def build_requirements(self): + if Version(self.version) >= "1.3.261": + self.tool_requires("cmake/[>=3.17.2 <4]") + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) def generate(self): + venv = VirtualBuildEnv(self) + venv.generate() + tc = CMakeToolchain(self) tc.variables["BUILD_EXTERNAL"] = False tc.variables["SKIP_GLSLANG_INSTALL"] = False tc.variables["ENABLE_SPVREMAPPER"] = self.options.spv_remapper tc.variables["ENABLE_GLSLANG_BINARIES"] = self.options.build_executables - glslang_version = Version(self.version) - if glslang_version < "7.0.0" or glslang_version >= "8.13.3743": - tc.variables["ENABLE_GLSLANG_JS"] = False - tc.variables["ENABLE_GLSLANG_WEBMIN"] = False - tc.variables["ENABLE_GLSLANG_WEBMIN_DEVEL"] = False - else: - tc.variables["ENABLE_GLSLANG_WEB"] = False - tc.variables["ENABLE_GLSLANG_WEB_DEVEL"] = False + tc.variables["ENABLE_GLSLANG_JS"] = False + tc.variables["ENABLE_GLSLANG_WEBMIN"] = False + tc.variables["ENABLE_GLSLANG_WEBMIN_DEVEL"] = False tc.variables["ENABLE_EMSCRIPTEN_SINGLE_FILE"] = False tc.variables["ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE"] = False tc.variables["ENABLE_HLSL"] = self.options.hlsl - if glslang_version < "7.0.0" or glslang_version >= "8.13.3743": - tc.variables["ENABLE_RTTI"] = True + tc.variables["ENABLE_RTTI"] = True tc.variables["ENABLE_OPT"] = self.options.enable_optimizer if self.options.enable_optimizer: tc.variables["spirv-tools_SOURCE_DIR"] = self.dependencies["spirv-tools"].package_folder.replace("\\", "/") tc.variables["ENABLE_PCH"] = False tc.variables["ENABLE_CTEST"] = False tc.variables["USE_CCACHE"] = False - if (glslang_version < "7.0.0" or glslang_version >= "11.6.0") and self.settings.os == "Windows": - tc.variables["OVERRIDE_MSVCCRT"] = False - if is_apple_os(self): - tc.variables["CMAKE_MACOSX_BUNDLE"] = False - if glslang_version < "1.3.231" or glslang_version >= "7.0.0": - # Generate a relocatable shared lib on Macos - tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.variables["OVERRIDE_MSVCCRT"] = False + tc.variables["CMAKE_MACOSX_BUNDLE"] = False + # Generate a relocatable shared lib on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + # glslang builds intermediate static libs, but Conan does not set -fPIC for shared builds + tc.variables["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True) tc.generate() deps = CMakeDeps(self) deps.generate() def _patch_sources(self): - apply_conandata_patches(self) - # Do not force PIC if static (but keep it if shared, because OGLCompiler, OSDependent, - # GenericCodeGen and MachineIndependent are still static and linked to glslang shared) - if not self.options.shared: - cmake_files_to_fix = [ - {"target": "OGLCompiler", "relpath": os.path.join("OGLCompilersDLL", "CMakeLists.txt")}, - {"target": "SPIRV" , "relpath": os.path.join("SPIRV", "CMakeLists.txt")}, - {"target": "SPVRemapper", "relpath": os.path.join("SPIRV", "CMakeLists.txt")}, - {"target": "OSDependent", "relpath": os.path.join("glslang", "OSDependent", "Unix","CMakeLists.txt")}, - {"target": "OSDependent", "relpath": os.path.join("glslang", "OSDependent", "Windows","CMakeLists.txt")}, - {"target": "HLSL" , "relpath": os.path.join("hlsl", "CMakeLists.txt")}, - ] - glslang_version = Version(self.version) - if glslang_version >= "7.0.0" and glslang_version < "11.0.0": - cmake_files_to_fix.append({"target": "glslang", "relpath": os.path.join("glslang", "CMakeLists.txt")}) - else: - cmake_files_to_fix.append({"target": "glslang-default-resource-limits", "relpath": os.path.join("StandAlone" , "CMakeLists.txt")}) - cmake_files_to_fix.append({"target": "MachineIndependent", "relpath": os.path.join("glslang", "CMakeLists.txt")}) - cmake_files_to_fix.append({"target": "GenericCodeGen", "relpath": os.path.join("glslang", "CMakeLists.txt")}) - for cmake_file in cmake_files_to_fix: - replace_in_file(self, os.path.join(self.source_folder, cmake_file["relpath"]), - "set_property(TARGET {} PROPERTY POSITION_INDEPENDENT_CODE ON)".format(cmake_file["target"]), - "") + for cmake_file in sorted(self.source_path.rglob("CMakeLists.txt")): + content = cmake_file.read_text(encoding="utf8") + if "POSITION_INDEPENDENT_CODE ON" in content: + content = re.sub(r"set_property\(TARGET \S+ PROPERTY POSITION_INDEPENDENT_CODE ON\)\n", "", content) + content = content.replace("POSITION_INDEPENDENT_CODE ON", "") + cmake_file.write_text(content, encoding="utf8") + self.output.info(f"Patched fPIC handling in {cmake_file.relative_to(self.source_path)}") + if "POSITION_INDEPENDENT_CODE" in content: + raise ConanException(f"POSITION_INDEPENDENT_CODE found in {cmake_file}, please update the recipe") def build(self): self._patch_sources() @@ -158,7 +133,7 @@ def build(self): cmake.build() def package(self): - copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses")) cmake = CMake(self) cmake.install() rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) @@ -166,22 +141,21 @@ def package(self): def package_info(self): self.cpp_info.set_property("cmake_file_name", "glslang") - self.cpp_info.set_property("cmake_target_name", "glslang::glslang-do-not-use") # because glslang-core target is glslang::glslang + self.cpp_info.set_property("cmake_target_name", "glslang::_glslang-do-not-use") # because glslang-core target is glslang::glslang lib_suffix = "d" if self.settings.os == "Windows" and self.settings.build_type == "Debug" else "" - glslang_version = Version(self.version) - has_machineindependent = (glslang_version < "7.0.0" or glslang_version >= "11.0.0") and not self.options.shared - has_genericcodegen = (glslang_version < "7.0.0" or glslang_version >= "11.0.0") and not self.options.shared - has_osdependent = glslang_version < "1.3.231" or glslang_version >= "7.0.0" or not self.options.shared - has_oglcompiler = glslang_version < "1.3.231" or glslang_version >= "7.0.0" or not self.options.shared + has_machineindependent = not self.options.shared + has_genericcodegen = not self.options.shared + has_osdependent = not self.options.shared + has_oglcompiler = not self.options.shared # glslang self.cpp_info.components["glslang-core"].set_property("cmake_target_name", "glslang::glslang") self.cpp_info.components["glslang-core"].names["cmake_find_package"] = "glslang" self.cpp_info.components["glslang-core"].names["cmake_find_package_multi"] = "glslang" self.cpp_info.components["glslang-core"].libs = [f"glslang{lib_suffix}"] - if (glslang_version < "7.0.0" or glslang_version >= "11.0.0") and self.options.shared: + if self.options.shared: self.cpp_info.components["glslang-core"].defines.append("GLSLANG_IS_SHARED_LIBRARY") if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["glslang-core"].system_libs.extend(["m", "pthread"]) diff --git a/recipes/glslang/all/patches/0001-no-force-glslang-pic.patch b/recipes/glslang/all/patches/0001-no-force-glslang-pic.patch deleted file mode 100644 index 00e2266d3a9ae..0000000000000 --- a/recipes/glslang/all/patches/0001-no-force-glslang-pic.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/glslang/CMakeLists.txt -+++ b/glslang/CMakeLists.txt -@@ -167,7 +167,6 @@ - add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${GLSLANG_SOURCES} ${GLSLANG_HEADERS}) - set_target_properties(glslang PROPERTIES - FOLDER glslang -- POSITION_INDEPENDENT_CODE ON - VERSION "${GLSLANG_VERSION}" - SOVERSION "${GLSLANG_VERSION_MAJOR}") - target_link_libraries(glslang PRIVATE OGLCompiler OSDependent MachineIndependent) diff --git a/recipes/glslang/all/patches/1.3.236.0-0001-no-force-glslang-pic.patch b/recipes/glslang/all/patches/1.3.236.0-0001-no-force-glslang-pic.patch deleted file mode 100644 index 10a3ace245afd..0000000000000 --- a/recipes/glslang/all/patches/1.3.236.0-0001-no-force-glslang-pic.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/glslang/CMakeLists.txt -+++ b/glslang/CMakeLists.txt -@@ -169,7 +169,6 @@ set(GLSLANG_HEADERS - add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${GLSLANG_SOURCES} ${GLSLANG_HEADERS}) - set_target_properties(glslang PROPERTIES - FOLDER glslang -- POSITION_INDEPENDENT_CODE ON - VERSION "${GLSLANG_VERSION}" - SOVERSION "${GLSLANG_VERSION_MAJOR}") - target_link_libraries(glslang PRIVATE OGLCompiler OSDependent MachineIndependent) diff --git a/recipes/glslang/config.yml b/recipes/glslang/config.yml index 99298a61152e6..87519b61c9623 100644 --- a/recipes/glslang/config.yml +++ b/recipes/glslang/config.yml @@ -1,23 +1,13 @@ versions: - "1.3.239.0": - folder: all - "1.3.236.0": - folder: all - "1.3.231.1": - folder: all - "1.3.224.0": + "1.3.268.0": folder: all - "1.3.216.0": + "1.3.261.1": folder: all - "1.3.211.0": + "1.3.243.0": folder: all - "1.3.204.0": - folder: all - "11.7.0": - folder: all - "11.6.0": + "1.3.239.0": folder: all - "11.5.0": + "1.3.236.0": folder: all - "8.13.3559": + "1.2.198.0": folder: all