summary refs log tree commit diff
path: root/pkgs/by-name/cm/cmake/check-pc-files-hook.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/cm/cmake/check-pc-files-hook.sh')
-rw-r--r--pkgs/by-name/cm/cmake/check-pc-files-hook.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/pkgs/by-name/cm/cmake/check-pc-files-hook.sh b/pkgs/by-name/cm/cmake/check-pc-files-hook.sh
new file mode 100644
index 00000000000..94d1b7b5355
--- /dev/null
+++ b/pkgs/by-name/cm/cmake/check-pc-files-hook.sh
@@ -0,0 +1,18 @@
+cmakePcfileCheckPhase() {
+    while IFS= read -rd $'\0' file; do
+        grepout=$(grep --line-number '}//nix/store' "$file" || true)
+        if [ -n "$grepout" ]; then
+            {
+            echo "Broken paths found in a .pc file! $file"
+            echo "The following lines have issues (specifically '//' in paths)."
+            echo "$grepout"
+            echo "It is very likely that paths are being joined improperly."
+            echo 'ex: "${prefix}/@CMAKE_INSTALL_LIBDIR@" should be "@CMAKE_INSTALL_FULL_LIBDIR@"'
+            echo "Please see https://github.com/NixOS/nixpkgs/issues/144170 for more details."
+            exit 1
+            } 1>&2
+        fi
+    done < <(find "${!outputDev}" -iname "*.pc" -print0)
+}
+
+postFixupHooks+=(cmakePcfileCheckPhase)