cmake: fix strictDeps
patch cmake to implement a NIXPKGS_CMAKE_PREFIX_PATH env variable which is similar to CMAKE_PREFIX_PATH except it is not searched for programs. This is required because cmake will search CMAKE_PREFIX_PATH for programs before PATH which is problematic as that means buildInputs gets searched before nativeBuildInputs which can break things when the binaries in PATH are covered or the order re-arranged.
This commit is contained in:
parent
f9a7cf528b
commit
8c9c8ade2f
28
pkgs/by-name/cm/cmake/000-nixpkgs-cmake-prefix-path.diff
Normal file
28
pkgs/by-name/cm/cmake/000-nixpkgs-cmake-prefix-path.diff
Normal file
@ -0,0 +1,28 @@
|
||||
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
|
||||
index 8840cdcb..c34b7ee9 100644
|
||||
--- a/Source/cmFindBase.cxx
|
||||
+++ b/Source/cmFindBase.cxx
|
||||
@@ -280,6 +280,11 @@ void cmFindBase::FillCMakeEnvironmentPath()
|
||||
// Add CMAKE_*_PATH environment variables
|
||||
std::string var = cmStrCat("CMAKE_", this->CMakePathName, "_PATH");
|
||||
paths.AddEnvPrefixPath("CMAKE_PREFIX_PATH");
|
||||
+ if (this->CMakePathName != "PROGRAM") {
|
||||
+ // Like CMAKE_PREFIX_PATH except when searching for programs. Programs need
|
||||
+ // to be located via PATH
|
||||
+ paths.AddEnvPrefixPath("NIXPKGS_CMAKE_PREFIX_PATH");
|
||||
+ }
|
||||
paths.AddEnvPath(var);
|
||||
|
||||
if (this->CMakePathName == "PROGRAM") {
|
||||
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
|
||||
index 9b51b1ad..6acc676c 100644
|
||||
--- a/Source/cmFindPackageCommand.cxx
|
||||
+++ b/Source/cmFindPackageCommand.cxx
|
||||
@@ -2039,6 +2039,7 @@ void cmFindPackageCommand::FillPrefixesCMakeEnvironment()
|
||||
|
||||
// And now the general CMake environment variables
|
||||
paths.AddEnvPath("CMAKE_PREFIX_PATH");
|
||||
+ paths.AddEnvPath("NIXPKGS_CMAKE_PREFIX_PATH");
|
||||
if (this->DebugMode) {
|
||||
debugBuffer = cmStrCat(debugBuffer,
|
||||
"CMAKE_PREFIX_PATH env variable "
|
@ -56,6 +56,9 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
};
|
||||
|
||||
patches = [
|
||||
# Add NIXPKGS_CMAKE_PREFIX_PATH to cmake which is like CMAKE_PREFIX_PATH
|
||||
# except it is not searched for programs
|
||||
./000-nixpkgs-cmake-prefix-path.diff
|
||||
# Don't search in non-Nix locations such as /usr, but do search in our libc.
|
||||
./001-search-path.diff
|
||||
# Don't depend on frameworks.
|
||||
|
@ -1,5 +1,7 @@
|
||||
addCMakeParams() {
|
||||
addToSearchPath CMAKE_PREFIX_PATH $1
|
||||
# NIXPKGS_CMAKE_PREFIX_PATH is like CMAKE_PREFIX_PATH except cmake
|
||||
# will not search it for programs
|
||||
addToSearchPath NIXPKGS_CMAKE_PREFIX_PATH $1
|
||||
}
|
||||
|
||||
fixCmakeFiles() {
|
||||
|
Loading…
Reference in New Issue
Block a user