Merge topic 'fix-variable_watch-cases'

647745b variable_watch: Print accesses as "CMake Debug Log" messages
515f9af variable_watch: Remove leftover debugging code (#14187)
c63d300 variable_watch: Add test for MODIFIED_ACCESS report
3d5bb38 variable_watch: Add missing string enumeration entry (#14188)
This commit is contained in:
Brad King 2013-06-04 09:03:00 -04:00 committed by CMake Topic Stage
commit d3971ee603
9 changed files with 32 additions and 18 deletions

View File

@ -15,6 +15,7 @@ static const char* const cmVariableWatchAccessStrings[] =
{
"READ_ACCESS",
"UNKNOWN_READ_ACCESS",
"UNKNOWN_DEFINED_ACCESS",
"ALLOWED_UNKNOWN_READ_ACCESS",
"MODIFIED_ACCESS",
"REMOVED_ACCESS",

View File

@ -117,24 +117,9 @@ void cmVariableWatchCommand::VariableAccessed(const std::string& variable,
if ( !processed )
{
cmOStringStream msg;
msg << "* Variable \"" << variable.c_str() << "\" was accessed using "
<< accessString << " in: " << currentListFile << std::endl;
msg << " The value of the variable: \"" << newValue << "\"" << std::endl;
msg << " The list file stack: " << stack.c_str();
cmSystemTools::Message(msg.str().c_str());
std::vector<std::string> vars = makefile->GetDefinitions();
cmOStringStream msg2;
size_t cc;
for ( cc = 0; cc < vars.size(); cc ++ )
{
if ( vars[cc] == variable )
{
continue;
}
msg2 << vars[cc] << " = \""
<< makefile->GetDefinition(vars[cc].c_str()) << "\"" << std::endl;
}
//cmSystemTools::Message(msg2.str().c_str());
msg << "Variable \"" << variable.c_str() << "\" was accessed using "
<< accessString << " with value \"" << newValue << "\".";
makefile->IssueMessage(cmake::LOG, msg.str());
}
this->InCallback = false;
}

View File

@ -77,6 +77,7 @@ add_RunCMake_test(include)
add_RunCMake_test(include_directories)
add_RunCMake_test(list)
add_RunCMake_test(try_compile)
add_RunCMake_test(variable_watch)
add_RunCMake_test(CMP0004)
find_package(Qt4 QUIET)

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -0,0 +1,4 @@
CMake Debug Log at ModifiedAccess.cmake:3 \(set\):
Variable "b" was accessed using MODIFIED_ACCESS with value "b".
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$

View File

@ -0,0 +1,3 @@
set(b "a")
variable_watch(b)
set(b "b")

View File

@ -0,0 +1,5 @@
my_func
CMake Debug Log at NoWatcher.cmake:8 \(set\):
Variable "b" was accessed using MODIFIED_ACCESS with value "".
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$

View File

@ -0,0 +1,8 @@
function(my_func)
message("my_func")
endfunction()
variable_watch(a my_func)
set(a "")
variable_watch(b)
set(b "")

View File

@ -0,0 +1,4 @@
include(RunCMake)
run_cmake(ModifiedAccess)
run_cmake(NoWatcher)