summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorRobert Maynard <rmaynard@nvidia.com>2021-02-22 16:58:52 (GMT)
committerRobert Maynard <rmaynard@nvidia.com>2021-03-09 18:53:16 (GMT)
commitb227a9565eb06dcc6e59bfa31e6939edf1ddbaad (patch)
tree622ff00179b0ee21bc86308aac5fd26f3ffb3f28 /Source/cmake.cxx
parent38140713ad24576f1c4e6253a1de91ff217dd475 (diff)
downloadCMake-b227a9565eb06dcc6e59bfa31e6939edf1ddbaad.zip
CMake-b227a9565eb06dcc6e59bfa31e6939edf1ddbaad.tar.gz
CMake-b227a9565eb06dcc6e59bfa31e6939edf1ddbaad.tar.bz2
cmake: configure preset add support for --install-prefix mapping
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx20
1 files changed, 17 insertions, 3 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index f96badd..b12eeee 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -28,6 +28,7 @@
#include "cm_sys_stat.h"
+#include "cmCMakePath.h"
#include "cmCMakePresetsFile.h"
#include "cmCommandLineArgument.h"
#include "cmCommands.h"
@@ -496,11 +497,16 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
auto PrefixLambda = [&](std::string const& path, cmake* state) -> bool {
const std::string var = "CMAKE_INSTALL_PREFIX";
cmStateEnums::CacheEntryType type = cmStateEnums::PATH;
+ cmCMakePath absolutePath(path);
+ if (absolutePath.IsAbsolute()) {
#ifndef CMAKE_BOOTSTRAP
- state->UnprocessedPresetVariables.erase(var);
+ state->UnprocessedPresetVariables.erase(var);
#endif
- state->ProcessCacheArg(var, path, type);
- return true;
+ state->ProcessCacheArg(var, path, type);
+ return true;
+ }
+ cmSystemTools::Error("Absolute paths are required for --install-prefix");
+ return false;
};
std::vector<CommandArgument> arguments = {
@@ -1224,6 +1230,14 @@ void cmake::SetArgs(const std::vector<std::string>& args)
this->UnprocessedPresetVariables = expandedPreset->CacheVariables;
this->UnprocessedPresetEnvironment = expandedPreset->Environment;
+ if (!expandedPreset->InstallDir.empty() &&
+ this->State->GetInitializedCacheValue("CMAKE_INSTALL_PREFIX") ==
+ nullptr) {
+ this->UnprocessedPresetVariables["CMAKE_INSTALL_PREFIX"] = {
+ "PATH", expandedPreset->InstallDir
+ };
+ }
+
if (!expandedPreset->ArchitectureStrategy ||
expandedPreset->ArchitectureStrategy ==
cmCMakePresetsFile::ArchToolsetStrategy::Set) {