Skip to content
Snippets Groups Projects
Commit 8285ad51 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

server-mode: Make CMAKE_HOME_DIRECTORY more reliable

Make CMAKE_HOME_DIRECTORY detection work more reliably in the face
of symlinks.

Closes #16736
parent 12bea47f
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment