Skip to content

vulkan-validationlayers: Fix compilation with CMakeConfigDeps #27969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AbrilRBS
Copy link
Member

@AbrilRBS AbrilRBS commented Jul 21, 2025

The recipe currently tries to copy the config file generated for spirv-tools so that upstream can do find_package(SPIRV-Tools-opt), as the current recipe for spriv-tools only generates one filename.

Instead of copying files, patch the find_packages out and assume that all necessary targets come from the global file for spirv-tools find_package(SPIRV-Tools REQUIRED CONFIG QUIET).

(Note that CMAKE_DISABLE_FIND_PACKAGE_ is not usable here as all SPIRV-Tools-opt calls have a REQUIRED attribute, so we can't easily disable it)

Closes #27170

@jcar87
Copy link
Contributor

jcar87 commented Jul 21, 2025

In the upstream packages, what is the difference between SPIRV-Tools-opt and SPIRV-Tools?

@AbrilRBS
Copy link
Member Author

In the upstream packages, what is the difference between SPIRV-Tools-opt and SPIRV-Tools?

@jcar87 each file just exposes the target for the library it references, instead of being different components under the same package.
image

In Conan, all of these are generated as components (And the current generators nevertheless don't support splitting into various config files)

@jcar87
Copy link
Contributor

jcar87 commented Jul 21, 2025

Thanks @AbrilRBS !

For the sake of avoiding the patch storm, the following should work for both generators

        save(self, os.path.join(self.generators_folder, "SPIRV-Tools-optConfig.cmake"),
             """include(CMakeFindDependencyMacro)
             find_dependency(SPIRV-Tools)""")

(also defining the relevant SPIRV-Tools-opt_DIR. Note how the first two lines are actually the same as the upstream file - looks like all of the others do require this one). FWIW, the spirv-tools recipe could package SPIRV-Tools-diffConfig.cmake, SPIRV-Tools-lintConfig.cmake, SPIRV-Tools-linkConfig.cmake, SPIRV-Tools-reduceConfig.cmake, SPIRV-Tools-optConfig.cmake, all with identical contents (just these two lines), and have the recipe make those available transparently to consumers: so long as SPIRV-ToolsConfig.cmake generated by Conan is available, all the others will work too.

Full patch:

diff --git a/recipes/vulkan-validationlayers/all/conanfile.py b/recipes/vulkan-validationlayers/all/conanfile.py
index 8e8fd30935..c21892c20e 100644
--- a/recipes/vulkan-validationlayers/all/conanfile.py
+++ b/recipes/vulkan-validationlayers/all/conanfile.py
@@ -4,7 +4,7 @@ from conan.tools.apple import fix_apple_shared_install_name
 from conan.tools.build import check_min_cppstd
 from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
 from conan.tools.env import VirtualBuildEnv
-from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, rename, replace_in_file, rm
+from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, rename, replace_in_file, rm, save
 from conan.tools.gnu import PkgConfigDeps
 from conan.tools.scm import Version
 import functools
@@ -172,11 +172,16 @@ class VulkanValidationLayersConan(ConanFile):
         tc.variables["INSTALL_TESTS"] = False
         tc.variables["BUILD_LAYERS"] = True
         tc.variables["BUILD_LAYER_SUPPORT_FILES"] = True
+        tc.cache_variables["SPIRV-Tools-opt_DIR"] = self.generators_folder.replace("\\", "/")
         tc.generate()
 
         deps = CMakeDeps(self)
         deps.generate()
 
+        save(self, os.path.join(self.generators_folder, "SPIRV-Tools-optConfig.cmake"),
+             """include(CMakeFindDependencyMacro)
+             find_dependency(SPIRV-Tools)""")
+
         if self._needs_pkg_config:
             deps = PkgConfigDeps(self)
             deps.generate()
@@ -195,13 +200,6 @@ class VulkanValidationLayersConan(ConanFile):
                 "set(JSON_API_VERSION ${VulkanHeaders_VERSION})",
                 f"set(JSON_API_VERSION \"{sanitized_vk_version}\")",
             )
-        # FIXME: two CMake module/config files should be generated (SPIRV-ToolsConfig.cmake and SPIRV-Tools-optConfig.cmake),
-        # but it can't be modeled right now in spirv-tools recipe
-        if not os.path.exists(os.path.join(self.generators_folder, "SPIRV-Tools-optConfig.cmake")):
-            shutil.copy(
-                os.path.join(self.generators_folder, "SPIRV-ToolsConfig.cmake"),
-                os.path.join(self.generators_folder, "SPIRV-Tools-optConfig.cmake"),
-            )
         if self.settings.os == "Android":
             # INFO: libVkLayer_utils.a: error: undefined symbol: __android_log_print
             # https://github.com/KhronosGroup/Vulkan-ValidationLayers/commit/a26638ae9fdd8c40b56d4c7b72859a5b9a0952c9

@AbrilRBS AbrilRBS force-pushed the ar/validation-layers-new-cmake-config-deps branch from d78a4af to e650f00 Compare July 22, 2025 11:09
---------

Co-authored-by: Luis Caro Campos <3535649+jcar87@users.noreply.github.com>
@AbrilRBS AbrilRBS force-pushed the ar/validation-layers-new-cmake-config-deps branch from e650f00 to 3d0b59c Compare July 22, 2025 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[package] vulkan-validationlayers/1.3.243.0: Fails to build using new CMakeConfigDeps
2 participants