summaryrefslogtreecommitdiffstats
path: root/Source/cmServerProtocol.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-03-23 12:46:25 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-03-23 12:46:30 (GMT)
commit677b3cbf28eb528f18777276035a223c565d8add (patch)
tree8aa85df7d6659290cc3bf8217edcf58f57549491 /Source/cmServerProtocol.cxx
parentf673623130df6eafe5f691d67089cb75b320eea5 (diff)
parent8285ad511a92416f0e99fcda27de98435316173b (diff)
downloadCMake-677b3cbf28eb528f18777276035a223c565d8add.zip
CMake-677b3cbf28eb528f18777276035a223c565d8add.tar.gz
CMake-677b3cbf28eb528f18777276035a223c565d8add.tar.bz2
Merge topic 'server-mode-fix-home-dir-check'
8285ad51 server-mode: Make CMAKE_HOME_DIRECTORY more reliable Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !611
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 334a05a..a5c1a23 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -255,6 +255,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)
@@ -314,8 +335,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;
}