From 8af26e3af0d93232fbe0752318531a69764ca2d5 Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Mon, 18 Sep 2023 17:08:08 +0200 Subject: [PATCH] Set `PKG_CONFIG_ALLOW_SYSTEM_(CFLAGS|LIBS)` by default (cherry picked from commit 9f1504590d4e9fa533265ae9035668a3ef4dbc9c) --- Cabal/src/Distribution/Simple/Program/Builtin.hs | 14 +++++++++++--- changelog.d/pkgconfig-envvars | 8 ++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 changelog.d/pkgconfig-envvars diff --git a/Cabal/src/Distribution/Simple/Program/Builtin.hs b/Cabal/src/Distribution/Simple/Program/Builtin.hs index 5c615fd5f51..5bb324f388f 100644 --- a/Cabal/src/Distribution/Simple/Program/Builtin.hs +++ b/Cabal/src/Distribution/Simple/Program/Builtin.hs @@ -343,6 +343,14 @@ cppProgram :: Program cppProgram = simpleProgram "cpp" pkgConfigProgram :: Program -pkgConfigProgram = (simpleProgram "pkg-config") { - programFindVersion = findProgramVersion "--version" id - } +pkgConfigProgram = + (simpleProgram "pkg-config") + { programFindVersion = findProgramVersion "--version" id + , programPostConf = \_ pkgConfProg -> + let programOverrideEnv' = + programOverrideEnv pkgConfProg + ++ [ ("PKG_CONFIG_ALLOW_SYSTEM_CFLAGS", Just "1") + , ("PKG_CONFIG_ALLOW_SYSTEM_LIBS", Just "1") + ] + in pure $ pkgConfProg{programOverrideEnv = programOverrideEnv'} + } diff --git a/changelog.d/pkgconfig-envvars b/changelog.d/pkgconfig-envvars new file mode 100644 index 00000000000..9b570693a44 --- /dev/null +++ b/changelog.d/pkgconfig-envvars @@ -0,0 +1,8 @@ +synopsis: PkgConfig environment variables +prs: #9134 + +description: { + +- `cabal` invokes `pkg-config` with `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS` and `PKG_CONFIG_ALLOW_SYSTEM_LIBS` set + +}