Merge topic 'suppress-unused-cli-with-value-in-cache'
273ecab CLI: Suppress the unused warning if the key value pair is cached.
This commit is contained in:
commit
21b1026541
@ -750,6 +750,10 @@ void cmCacheManager::AddCacheEntry(const char* key,
|
|||||||
}
|
}
|
||||||
e.SetProperty("HELPSTRING", helpString? helpString :
|
e.SetProperty("HELPSTRING", helpString? helpString :
|
||||||
"(This variable does not exist and should not be used)");
|
"(This variable does not exist and should not be used)");
|
||||||
|
if (this->Cache[key].Value == e.Value)
|
||||||
|
{
|
||||||
|
this->CMakeInstance->UnwatchUnusedCli(key);
|
||||||
|
}
|
||||||
this->Cache[key] = e;
|
this->Cache[key] = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,11 +383,22 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
|
|||||||
cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
|
cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
|
||||||
if(cmCacheManager::ParseEntry(entry.c_str(), var, value, type))
|
if(cmCacheManager::ParseEntry(entry.c_str(), var, value, type))
|
||||||
{
|
{
|
||||||
|
// The value is transformed if it is a filepath for example, so
|
||||||
|
// we can't compare whether the value is already in the cache until
|
||||||
|
// after we call AddCacheEntry.
|
||||||
|
const char *cachedValue =
|
||||||
|
this->CacheManager->GetCacheValue(var.c_str());
|
||||||
|
|
||||||
this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(),
|
this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(),
|
||||||
"No help, variable specified on the command line.", type);
|
"No help, variable specified on the command line.", type);
|
||||||
if(this->WarnUnusedCli)
|
if(this->WarnUnusedCli)
|
||||||
{
|
{
|
||||||
this->WatchUnusedCli(var.c_str());
|
if (!cachedValue
|
||||||
|
|| strcmp(this->CacheManager->GetCacheValue(var.c_str()),
|
||||||
|
cachedValue) != 0)
|
||||||
|
{
|
||||||
|
this->WatchUnusedCli(var.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1640,17 +1640,23 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
|
|||||||
FAIL_REGULAR_EXPRESSION "CMake Warning .*VariableUnusedViaUnset.CMakeLists.txt:5 \\(set\\):")
|
FAIL_REGULAR_EXPRESSION "CMake Warning .*VariableUnusedViaUnset.CMakeLists.txt:5 \\(set\\):")
|
||||||
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset")
|
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset")
|
||||||
|
|
||||||
add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND}
|
if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile")
|
||||||
--build-and-test
|
# Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails
|
||||||
"${CMake_SOURCE_DIR}/Tests/VariableUsage"
|
# this test. (See #13371)
|
||||||
"${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused"
|
# Apparently Visual Studio does not support it either. As the MakeClean
|
||||||
${build_generator_args}
|
# test above is only run with the Makefiles generator, only run this
|
||||||
--build-noclean
|
# test with the Makefiles generator also.
|
||||||
--build-project WarnUnusedCliUnused
|
add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND}
|
||||||
--build-options "-DUNUSED_CLI_VARIABLE=Unused")
|
--build-and-test
|
||||||
set_tests_properties(WarnUnusedCliUnused PROPERTIES
|
"${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused"
|
||||||
PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE")
|
"${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused"
|
||||||
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
|
${build_generator_args}
|
||||||
|
--build-project WarnUnusedCliUnused
|
||||||
|
--build-options "-DUNUSED_CLI_VARIABLE=Unused")
|
||||||
|
set_tests_properties(WarnUnusedCliUnused PROPERTIES
|
||||||
|
PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE")
|
||||||
|
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_test(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND}
|
add_test(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND}
|
||||||
--build-and-test
|
--build-and-test
|
||||||
|
9
Tests/WarnUnusedCliUnused/CMakeLists.txt
Normal file
9
Tests/WarnUnusedCliUnused/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
project(WarnUnusedCliUnused)
|
||||||
|
|
||||||
|
set_directory_properties(PROPERTIES
|
||||||
|
ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/CMakeCache.txt"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(dummy empty.cpp)
|
7
Tests/WarnUnusedCliUnused/empty.cpp
Normal file
7
Tests/WarnUnusedCliUnused/empty.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifdef _WIN32
|
||||||
|
__declspec(dllexport)
|
||||||
|
#endif
|
||||||
|
int empty(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user