Commit 62864a76 authored by Daniel Pfeifer's avatar Daniel Pfeifer
Browse files

cmServerProtocol: fix test of empty values

If a required value is in the cache, it is not necessary to set it
explicitly.

Fixes: #16988
parent 1363a0cb
Pipeline #62433 passed with stage
......@@ -264,6 +264,10 @@ static bool testHomeDirectory(cmState* state, std::string& value,
{
const std::string cachedValue =
std::string(state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY"));
if (value.empty()) {
value = cachedValue;
return true;
}
const std::string suffix = "/CMakeLists.txt";
const std::string cachedValueCML = cachedValue + suffix;
const std::string valueCML = value + suffix;
......@@ -274,9 +278,6 @@ static bool testHomeDirectory(cmState* state, std::string& value,
"source directory value."));
return false;
}
if (value.empty()) {
value = cachedValue;
}
return true;
}
......@@ -285,15 +286,15 @@ static bool testValue(cmState* state, const std::string& key,
std::string* errorMessage)
{
const std::string cachedValue = std::string(state->GetCacheEntryValue(key));
if (!cachedValue.empty() && !value.empty() && cachedValue != value) {
if (value.empty()) {
value = cachedValue;
}
if (!cachedValue.empty() && cachedValue != value) {
setErrorMessage(errorMessage, std::string("\"") + key +
"\" is set but incompatible with configured " +
keyDescription + " value.");
return false;
}
if (value.empty()) {
value = cachedValue;
}
return true;
}
......
  • Looks sensible to me:-)

    IIRC this is something that came from the CMake side: Steven insisted that server-mode should always get build- and source directory set explicitly.

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment