mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 11:49:55 -06:00
cmServerProtocol: fix test of empty values
If a required value is in the cache, it is not necessary to set it explicitly. Fixes: #16948, #16988
This commit is contained in:
@@ -277,7 +277,9 @@ Giving the "major" version of the requested protocol version will make the serve
|
||||
use the latest minor version of that protocol. Use this if you do not explicitly
|
||||
need to depend on a specific minor version.
|
||||
|
||||
Each protocol version may request additional attributes to be present.
|
||||
If the build directory already contains a CMake cache, it is sufficient to set
|
||||
the "buildDirectory" attribute. To create a fresh build directory, additional
|
||||
attributes are required depending on the protocol version.
|
||||
|
||||
Protocol version 1.0 requires the following attributes to be set:
|
||||
|
||||
|
||||
@@ -269,6 +269,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;
|
||||
@@ -279,9 +283,6 @@ static bool testHomeDirectory(cmState* state, std::string& value,
|
||||
"source directory value."));
|
||||
return false;
|
||||
}
|
||||
if (value.empty()) {
|
||||
value = cachedValue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -292,15 +293,15 @@ static bool testValue(cmState* state, const std::string& key,
|
||||
const char* entry = state->GetCacheEntryValue(key);
|
||||
const std::string cachedValue =
|
||||
entry == nullptr ? std::string() : std::string(entry);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user