From 925ca6f7f7514b5fdafbb5972d33909e9229e481 Mon Sep 17 00:00:00 2001 From: John Ingve Olsen Date: Tue, 26 Mar 2024 13:06:24 +0100 Subject: [PATCH 1/3] glfw: limit xorg library requirements Previously the glfw package would implicitly require linking with xorg::xorg, which includes all the libraries exposed by the xorg package. This commit explicitly declares the requirements of glfw, limiting the xorg libraries to only those needed. --- recipes/glfw/all/conanfile.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/recipes/glfw/all/conanfile.py b/recipes/glfw/all/conanfile.py index 90b0cfaeecdac..2686594ece66f 100644 --- a/recipes/glfw/all/conanfile.py +++ b/recipes/glfw/all/conanfile.py @@ -142,10 +142,10 @@ 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: @@ -217,6 +217,15 @@ def package_info(self): "CoreServices", "Foundation", "IOKit", ]) + self.cpp_info.requires = ["opengl::opengl"] + if self.options.get_safe("vulkan_static"): + self.cpp_info.requires.extend(["vulkan-loader::vulkan-loader"]) + if self.settings.os in ["Linux", "FreeBSD"]: + if self.options.get_safe("with_x11", True): + self.cpp_info.requires.extend(["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" From 58f9f7e22dd2fe12390f1af1965b2e845dd25c10 Mon Sep 17 00:00:00 2001 From: John Ingve Olsen Date: Tue, 26 Mar 2024 13:49:58 +0100 Subject: [PATCH 2/3] glfw: remove vulkan_static option for version 3.4 The ability to link to a static Vulkan loader was removed in glfw version 3.4. --- recipes/glfw/all/conanfile.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/glfw/all/conanfile.py b/recipes/glfw/all/conanfile.py index 2686594ece66f..acabf490f87b2 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() @@ -148,7 +150,7 @@ def _patch_sources(self): "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, From c05ac9dbdb4ad9a5508a7f6c8575e8098ac60fbd Mon Sep 17 00:00:00 2001 From: John Ingve Olsen Date: Tue, 26 Mar 2024 14:14:19 +0100 Subject: [PATCH 3/3] glfw: don't link platform libraries from version 3.4 From version 3.4, glfw loads platform libraries at runtime, and so it is not necessary to link with these. --- recipes/glfw/all/conanfile.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/recipes/glfw/all/conanfile.py b/recipes/glfw/all/conanfile.py index acabf490f87b2..7c18d08f2128a 100644 --- a/recipes/glfw/all/conanfile.py +++ b/recipes/glfw/all/conanfile.py @@ -219,14 +219,18 @@ def package_info(self): "CoreServices", "Foundation", "IOKit", ]) - self.cpp_info.requires = ["opengl::opengl"] - if self.options.get_safe("vulkan_static"): - self.cpp_info.requires.extend(["vulkan-loader::vulkan-loader"]) - if self.settings.os in ["Linux", "FreeBSD"]: - if self.options.get_safe("with_x11", True): - self.cpp_info.requires.extend(["xorg::x11"]) - if self.options.get_safe("with_wayland"): - self.cpp_info.requires.extend(["wayland::wayland", "xkbcommon::xkbcommon"]) + # 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"