Skip to content

Commit

Permalink
(conan-io#23500) libglvnd: Set the default datadir appropriately for …
Browse files Browse the repository at this point in the history
…the system

Currently, ICD discovery doesn't work properly for the system.
This is because `datadir` is either configured to the package directory for Conan versions before 1.64 and 2.2 or not set at all for later versions.
When the datadir is not set, it results in the default search path for ICD discovery using /share/glvnd/egl_vendor.d, which is not correct for any platform.
This is due to the empty `prefix`.
This PR sets datadir to `/usr/share` on Linux, fixing the search path to include `/usr/share/glvnd/egl_vendor.d`.
The `prefix` is not modified to avoid installing everything under `/usr` in the install step.
On FreeBSD, the `datadir` is set to `/usr/local/share`, where I assume that the Mesa package's vendor configs are installed.
I haven't confirmed this for FreeBSD.

These changes can be verified by checking the generated `compile_commands.json` file in the build directory.
The value for `-DDEFAULT_EGL_VENDOR_CONFIG_DIRS=` will include the default search paths that libglvnd is built with.
The first path which is under `sysconfigdir`, should be correct for Linux, as it is `/etc`.
Under FreeBSD, this should be `/usr/local/etc`.
  • Loading branch information
jwillikers authored and franramirez688 committed Apr 23, 2024
1 parent ed96036 commit 544f52a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions recipes/libglvnd/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import textwrap

required_conan_version = ">=1.50.0"
required_conan_version = ">=1.64.0 <2 || >=2.2.0"

class LibGlvndConan(ConanFile):
name = "libglvnd"
Expand Down Expand Up @@ -59,7 +59,7 @@ def validate(self):
raise ConanInvalidConfiguration(f"{self.name} is only compatible with Linux and FreeBSD")

def build_requirements(self):
self.tool_requires("meson/1.3.2")
self.tool_requires("meson/1.4.0")
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
self.tool_requires("pkgconf/2.1.0")

Expand Down Expand Up @@ -87,6 +87,10 @@ def generate(self):
tc.project_options["headers"] = self.options.headers
tc.project_options["entrypoint-patching"] = "enabled" if self.options.entrypoint_patching else "disabled"
tc.project_options["libdir"] = "lib"
# Configure the data directory so that it defaults to the correct location for ICD discovery on the local system.
tc.project_options["datadir"] = os.path.join("usr", "share") if self.settings.os == "Linux" else os.path.join("usr", "local", "share")
if self.settings.os == "FreeBSD":
tc.project_options["sysconfdir"] = os.path.join("usr", "local", "etc")
tc.generate()

def build(self):
Expand Down

0 comments on commit 544f52a

Please sign in to comment.