Skip to content

Commit

Permalink
libglvnd: Set the default datadir appropriately for the system
Browse files Browse the repository at this point in the history
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 committed Apr 12, 2024
1 parent 4522d7a commit c576303
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 c576303

Please sign in to comment.