diff --git a/recipes/glfw/all/conanfile.py b/recipes/glfw/all/conanfile.py index 90b0cfaeecdac..7c18d08f2128a 100644 --- a/recipes/glfw/all/conanfile.py +++ b/recipes/glfw/all/conanfile.py @@ -52,6 +52,8 @@ def config_options(self): self.options.rm_safe("with_wayland") if self.settings.os not in ["Linux", "FreeBSD"] or Version(self.version) <= "3.3.8": self.options.rm_safe("with_x11") + if Version(self.version) >= "3.4": + self.options.rm_safe("vulkan_static") def configure(self): if self.options.shared: @@ -67,7 +69,7 @@ def layout(self): def requirements(self): self.requires("opengl/system") - if self.options.vulkan_static: + if self.options.get_safe("vulkan_static"): self.requires("vulkan-loader/1.3.268.0") if self.settings.os in ["Linux", "FreeBSD"]: if self.options.get_safe("with_x11", True): @@ -108,7 +110,7 @@ def generate(self): tc.cache_variables["GLFW_BUILD_WAYLAND"] = self.options.get_safe("with_wayland", False) else: tc.cache_variables["GLFW_USE_WAYLAND"] = self.options.get_safe("with_wayland", False) - tc.variables["GLFW_VULKAN_STATIC"] = self.options.vulkan_static + tc.variables["GLFW_VULKAN_STATIC"] = self.options.get_safe("vulkan_static", False) if is_msvc(self): tc.cache_variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) tc.generate() @@ -142,13 +144,13 @@ def _patch_sources(self): apply_conandata_patches(self) # don't force PIC replace_in_file(self, os.path.join(self.source_folder, "src", "CMakeLists.txt"), - "POSITION_INDEPENDENT_CODE ON", "") + "POSITION_INDEPENDENT_CODE ON", "") # don't force static link to libgcc if MinGW replace_in_file(self, os.path.join(self.source_folder, "src", "CMakeLists.txt"), - "target_link_libraries(glfw PRIVATE \"-static-libgcc\")", "") + "target_link_libraries(glfw PRIVATE \"-static-libgcc\")", "") # Allow to link vulkan-loader into shared glfw - if self.options.vulkan_static: + if self.options.get_safe("vulkan_static"): cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") replace_in_file( self, @@ -217,6 +219,19 @@ def package_info(self): "CoreServices", "Foundation", "IOKit", ]) + # Starting with version 3.4, glfw loads the platform libraries at runtime + # and hence does not need to link with them. + self.cpp_info.requires = [] + if Version(self.version) < "3.4": + self.cpp_info.requires.append("opengl::opengl") + if self.options.get_safe("vulkan_static"): + self.cpp_info.requires.append("vulkan-loader::vulkan-loader") + if self.settings.os in ["Linux", "FreeBSD"]: + if self.options.get_safe("with_x11", True): + self.cpp_info.requires.append("xorg::x11") + if self.options.get_safe("with_wayland"): + self.cpp_info.requires.extend(["wayland::wayland", "xkbcommon::xkbcommon"]) + # backward support of cmake_find_package, cmake_find_package_multi & pkg_config generators self.cpp_info.filenames["cmake_find_package"] = "glfw3" self.cpp_info.filenames["cmake_find_package_multi"] = "glfw3"