Skip to content
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

glfw: limit xorg library dependencies #23272

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions recipes/glfw/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand Down
Loading