From 54d591b2b4a7b29479e04ffde0f1338d208a4171 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Fri, 30 Aug 2024 21:48:43 -0400 Subject: [PATCH] cmake: undo `/var/empty` workaround for Darwin SDK paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this workaround enabled, CMake looks for SDK headers and libraries in `${SDKROOT}/var/empty`, which ensures it will not find them. Disabling the workaround in just this case allows CMake’s SDK support to work with the SDKs in nixpkgs while still not including other, impure paths in its search paths. --- pkgs/by-name/cm/cmake/package.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/by-name/cm/cmake/package.nix b/pkgs/by-name/cm/cmake/package.nix index 985b07cfb8a6..4ccac7799541 100644 --- a/pkgs/by-name/cm/cmake/package.nix +++ b/pkgs/by-name/cm/cmake/package.nix @@ -181,6 +181,14 @@ stdenv.mkDerivation (finalAttrs: { sed -i 's|bin/cmake|${buildPackages.cmakeMinimal}/bin/cmake|g' Makefile ''; + # Undo some of `fixCmakeFiles` for Darwin to make sure that checks for libraries in the SDK find them + # (e.g., `find_library(MATH_LIBRARY m)` should find `$SDKROOT/usr/lib/libm.tbd`). + postFixup = lib.optionalString stdenv.hostPlatform.isDarwin '' + substituteInPlace "$out/share/cmake-${lib.versions.majorMinor finalAttrs.version}/Modules/Platform/Darwin.cmake" \ + --replace-fail '/var/empty/include' '/usr/include' \ + --replace-fail '/var/empty/lib' '/usr/lib' + ''; + dontUseCmakeConfigure = true; enableParallelBuilding = true;