summaryrefslogtreecommitdiffstats
path: root/Source/cmServerProtocol.cxx
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2017-03-22 15:52:08 (GMT)
committerTobias Hunger <tobias.hunger@qt.io>2017-03-22 16:31:02 (GMT)
commit8285ad511a92416f0e99fcda27de98435316173b (patch)
treefb2f65b4e88086e74a69204447c90f58db384de9 /Source/cmServerProtocol.cxx
parent12bea47fa4d47b8e887ddbaf4c4fcc312d3052dc (diff)
downloadCMake-8285ad511a92416f0e99fcda27de98435316173b.zip
CMake-8285ad511a92416f0e99fcda27de98435316173b.tar.gz
CMake-8285ad511a92416f0e99fcda27de98435316173b.tar.bz2
server-mode: Make CMAKE_HOME_DIRECTORY more reliable
Make CMAKE_HOME_DIRECTORY detection work more reliably in the face of symlinks. Closes #16736
Diffstat (limited to 'Source/cmServerProtocol.cxx')
-rw-r--r--Source/cmServerProtocol.cxx24
1 files changed, 22 insertions, 2 deletions
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index e159c8f..8317018 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -251,6 +251,27 @@ static void setErrorMessage(std::string* errorMessage, const std::string& text)
}
}
+static bool testHomeDirectory(cmState* state, std::string& value,
+ std::string* errorMessage)
+{
+ const std::string cachedValue =
+ std::string(state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY"));
+ const std::string suffix = "/CMakeLists.txt";
+ const std::string cachedValueCML = cachedValue + suffix;
+ const std::string valueCML = value + suffix;
+ if (!cmSystemTools::SameFile(valueCML, cachedValueCML)) {
+ setErrorMessage(errorMessage,
+ std::string("\"CMAKE_HOME_DIRECTORY\" is set but "
+ "incompatible with configured "
+ "source directory value."));
+ return false;
+ }
+ if (value.empty()) {
+ value = cachedValue;
+ }
+ return true;
+}
+
static bool testValue(cmState* state, const std::string& key,
std::string& value, const std::string& keyDescription,
std::string* errorMessage)
@@ -310,8 +331,7 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request,
}
// check sourcedir:
- if (!testValue(state, "CMAKE_HOME_DIRECTORY", sourceDirectory,
- "source directory", errorMessage)) {
+ if (!testHomeDirectory(state, sourceDirectory, errorMessage)) {
return false;
}