Drop CMAKE_STRICT mode
With our modern development workflow it is less likely a property will be added to C++ code without documentation. This mode only existed to support the DocTest which had very limited coverage of the properties anyway.
This commit is contained in:
parent
678aaad133
commit
277bd1db98
|
@ -536,10 +536,6 @@ configure_file(
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/DartLocal.conf"
|
"${CMAKE_CURRENT_BINARY_DIR}/DartLocal.conf"
|
||||||
COPYONLY)
|
COPYONLY)
|
||||||
|
|
||||||
option(CMAKE_STRICT
|
|
||||||
"Perform strict testing to record property and variable access. Can be used to report any undefined properties or variables" OFF)
|
|
||||||
mark_as_advanced(CMAKE_STRICT)
|
|
||||||
|
|
||||||
if(NOT CMake_VERSION_IS_RELEASE)
|
if(NOT CMake_VERSION_IS_RELEASE)
|
||||||
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND
|
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND
|
||||||
NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2)
|
NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2)
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#cmakedefine HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE
|
#cmakedefine HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE
|
||||||
#cmakedefine HAVE_UNSETENV
|
#cmakedefine HAVE_UNSETENV
|
||||||
#cmakedefine CMAKE_USE_ELF_PARSER
|
#cmakedefine CMAKE_USE_ELF_PARSER
|
||||||
#cmakedefine CMAKE_STRICT
|
|
||||||
#define CMAKE_ROOT_DIR "${CMake_SOURCE_DIR}"
|
#define CMAKE_ROOT_DIR "${CMake_SOURCE_DIR}"
|
||||||
#define CMAKE_BUILD_DIR "${CMake_BINARY_DIR}"
|
#define CMAKE_BUILD_DIR "${CMake_BINARY_DIR}"
|
||||||
#define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@"
|
#define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@"
|
||||||
|
|
|
@ -1778,14 +1778,6 @@ void cmMakefile::AddDefinition(const char* name, const char* value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CMAKE_STRICT
|
|
||||||
if (this->GetCMakeInstance())
|
|
||||||
{
|
|
||||||
this->GetCMakeInstance()->
|
|
||||||
RecordPropertyAccess(name,cmProperty::VARIABLE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
this->Internal->VarStack.top().Set(name, value);
|
this->Internal->VarStack.top().Set(name, value);
|
||||||
if (this->Internal->VarUsageStack.size() &&
|
if (this->Internal->VarUsageStack.size() &&
|
||||||
this->VariableInitialized(name))
|
this->VariableInitialized(name))
|
||||||
|
@ -2448,13 +2440,6 @@ bool cmMakefile::IsDefinitionSet(const char* name) const
|
||||||
|
|
||||||
const char* cmMakefile::GetDefinition(const char* name) const
|
const char* cmMakefile::GetDefinition(const char* name) const
|
||||||
{
|
{
|
||||||
#ifdef CMAKE_STRICT
|
|
||||||
if (this->GetCMakeInstance())
|
|
||||||
{
|
|
||||||
this->GetCMakeInstance()->
|
|
||||||
RecordPropertyAccess(name,cmProperty::VARIABLE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (this->WarnUnused)
|
if (this->WarnUnused)
|
||||||
{
|
{
|
||||||
this->Internal->VarUsageStack.top().insert(name);
|
this->Internal->VarUsageStack.top().insert(name);
|
||||||
|
|
|
@ -40,19 +40,7 @@ void cmPropertyMap::SetProperty(const char *name, const char *value,
|
||||||
this->erase(name);
|
this->erase(name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef CMAKE_STRICT
|
|
||||||
if (!this->CMakeInstance)
|
|
||||||
{
|
|
||||||
cmSystemTools::Error("CMakeInstance not set on a property map!");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->CMakeInstance->RecordPropertyAccess(name,scope);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
(void)scope;
|
(void)scope;
|
||||||
#endif
|
|
||||||
|
|
||||||
cmProperty *prop = this->GetOrCreateProperty(name);
|
cmProperty *prop = this->GetOrCreateProperty(name);
|
||||||
prop->Set(name,value);
|
prop->Set(name,value);
|
||||||
|
@ -66,19 +54,7 @@ void cmPropertyMap::AppendProperty(const char* name, const char* value,
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef CMAKE_STRICT
|
|
||||||
if (!this->CMakeInstance)
|
|
||||||
{
|
|
||||||
cmSystemTools::Error("CMakeInstance not set on a property map!");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->CMakeInstance->RecordPropertyAccess(name,scope);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
(void)scope;
|
(void)scope;
|
||||||
#endif
|
|
||||||
|
|
||||||
cmProperty *prop = this->GetOrCreateProperty(name);
|
cmProperty *prop = this->GetOrCreateProperty(name);
|
||||||
prop->Append(name,value,asString);
|
prop->Append(name,value,asString);
|
||||||
|
@ -95,19 +71,6 @@ const char *cmPropertyMap
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// has the property been defined?
|
|
||||||
#ifdef CMAKE_STRICT
|
|
||||||
if (!this->CMakeInstance)
|
|
||||||
{
|
|
||||||
cmSystemTools::Error("CMakeInstance not set on a property map!");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->CMakeInstance->RecordPropertyAccess(name,scope);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cmPropertyMap::const_iterator it = this->find(name);
|
cmPropertyMap::const_iterator it = this->find(name);
|
||||||
if (it == this->end())
|
if (it == this->end())
|
||||||
{
|
{
|
||||||
|
|
111
Source/cmake.cxx
111
Source/cmake.cxx
|
@ -1865,11 +1865,6 @@ int cmake::Generate()
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (this->GetProperty("REPORT_UNDEFINED_PROPERTIES"))
|
|
||||||
{
|
|
||||||
this->ReportUndefinedPropertyAccesses
|
|
||||||
(this->GetProperty("REPORT_UNDEFINED_PROPERTIES"));
|
|
||||||
}
|
|
||||||
// Save the cache again after a successful Generate so that any internal
|
// Save the cache again after a successful Generate so that any internal
|
||||||
// variables created during Generate are saved. (Specifically target GUIDs
|
// variables created during Generate are saved. (Specifically target GUIDs
|
||||||
// for the Visual Studio and Xcode generators.)
|
// for the Visual Studio and Xcode generators.)
|
||||||
|
@ -2646,112 +2641,6 @@ cmPropertyDefinition *cmake
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmake::RecordPropertyAccess(const char *name,
|
|
||||||
cmProperty::ScopeType scope)
|
|
||||||
{
|
|
||||||
this->AccessedProperties.insert
|
|
||||||
(std::pair<cmStdString,cmProperty::ScopeType>(name,scope));
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmake::ReportUndefinedPropertyAccesses(const char *filename)
|
|
||||||
{
|
|
||||||
if(!this->GlobalGenerator)
|
|
||||||
{ return; }
|
|
||||||
FILE *progFile = fopen(filename,"w");
|
|
||||||
if(!progFile)
|
|
||||||
{ return; }
|
|
||||||
|
|
||||||
// what are the enabled languages?
|
|
||||||
std::vector<std::string> enLangs;
|
|
||||||
this->GlobalGenerator->GetEnabledLanguages(enLangs);
|
|
||||||
|
|
||||||
// Common configuration names.
|
|
||||||
// TODO: Compute current configuration(s).
|
|
||||||
std::vector<std::string> enConfigs;
|
|
||||||
enConfigs.push_back("");
|
|
||||||
enConfigs.push_back("DEBUG");
|
|
||||||
enConfigs.push_back("RELEASE");
|
|
||||||
enConfigs.push_back("MINSIZEREL");
|
|
||||||
enConfigs.push_back("RELWITHDEBINFO");
|
|
||||||
|
|
||||||
// take all the defined properties and add definitions for all the enabled
|
|
||||||
// languages
|
|
||||||
std::set<std::pair<cmStdString,cmProperty::ScopeType> > aliasedProperties;
|
|
||||||
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::iterator i;
|
|
||||||
i = this->PropertyDefinitions.begin();
|
|
||||||
for (;i != this->PropertyDefinitions.end(); ++i)
|
|
||||||
{
|
|
||||||
cmPropertyDefinitionMap::iterator j;
|
|
||||||
for (j = i->second.begin(); j != i->second.end(); ++j)
|
|
||||||
{
|
|
||||||
// TODO: What if both <LANG> and <CONFIG> appear?
|
|
||||||
if (j->first.find("<CONFIG>") != std::string::npos)
|
|
||||||
{
|
|
||||||
std::vector<std::string>::const_iterator k;
|
|
||||||
for (k = enConfigs.begin(); k != enConfigs.end(); ++k)
|
|
||||||
{
|
|
||||||
std::string tmp = j->first;
|
|
||||||
cmSystemTools::ReplaceString(tmp, "<CONFIG>", k->c_str());
|
|
||||||
// add alias
|
|
||||||
aliasedProperties.insert
|
|
||||||
(std::pair<cmStdString,cmProperty::ScopeType>(tmp,i->first));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (j->first.find("<LANG>") != std::string::npos)
|
|
||||||
{
|
|
||||||
std::vector<std::string>::const_iterator k;
|
|
||||||
for (k = enLangs.begin(); k != enLangs.end(); ++k)
|
|
||||||
{
|
|
||||||
std::string tmp = j->first;
|
|
||||||
cmSystemTools::ReplaceString(tmp, "<LANG>", k->c_str());
|
|
||||||
// add alias
|
|
||||||
aliasedProperties.insert
|
|
||||||
(std::pair<cmStdString,cmProperty::ScopeType>(tmp,i->first));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::set<std::pair<cmStdString,cmProperty::ScopeType> >::const_iterator ap;
|
|
||||||
ap = this->AccessedProperties.begin();
|
|
||||||
for (;ap != this->AccessedProperties.end(); ++ap)
|
|
||||||
{
|
|
||||||
if (!this->IsPropertyDefined(ap->first.c_str(),ap->second) &&
|
|
||||||
aliasedProperties.find(std::pair<cmStdString,cmProperty::ScopeType>
|
|
||||||
(ap->first,ap->second)) ==
|
|
||||||
aliasedProperties.end())
|
|
||||||
{
|
|
||||||
const char *scopeStr = "";
|
|
||||||
switch (ap->second)
|
|
||||||
{
|
|
||||||
case cmProperty::TARGET:
|
|
||||||
scopeStr = "TARGET";
|
|
||||||
break;
|
|
||||||
case cmProperty::SOURCE_FILE:
|
|
||||||
scopeStr = "SOURCE_FILE";
|
|
||||||
break;
|
|
||||||
case cmProperty::DIRECTORY:
|
|
||||||
scopeStr = "DIRECTORY";
|
|
||||||
break;
|
|
||||||
case cmProperty::TEST:
|
|
||||||
scopeStr = "TEST";
|
|
||||||
break;
|
|
||||||
case cmProperty::VARIABLE:
|
|
||||||
scopeStr = "VARIABLE";
|
|
||||||
break;
|
|
||||||
case cmProperty::CACHED_VARIABLE:
|
|
||||||
scopeStr = "CACHED_VARIABLE";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
scopeStr = "unknown";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
fprintf(progFile, "%s with scope %s\n", ap->first.c_str(), scopeStr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(progFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cmake::IsPropertyDefined(const char *name, cmProperty::ScopeType scope)
|
bool cmake::IsPropertyDefined(const char *name, cmProperty::ScopeType scope)
|
||||||
{
|
{
|
||||||
return this->PropertyDefinitions[scope].IsPropertyDefined(name);
|
return this->PropertyDefinitions[scope].IsPropertyDefined(name);
|
||||||
|
|
|
@ -358,10 +358,6 @@ class cmake
|
||||||
debugging configurations.*/
|
debugging configurations.*/
|
||||||
std::vector<std::string> const& GetDebugConfigs();
|
std::vector<std::string> const& GetDebugConfigs();
|
||||||
|
|
||||||
// record accesses of properties and variables
|
|
||||||
void RecordPropertyAccess(const char *name, cmProperty::ScopeType scope);
|
|
||||||
void ReportUndefinedPropertyAccesses(const char *filename);
|
|
||||||
|
|
||||||
// Define the properties
|
// Define the properties
|
||||||
static void DefineProperties(cmake *cm);
|
static void DefineProperties(cmake *cm);
|
||||||
|
|
||||||
|
|
|
@ -508,9 +508,6 @@ if(BUILD_TESTING)
|
||||||
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubProject")
|
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubProject")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_STRICT)
|
|
||||||
ADD_TEST_MACRO(DocTest DocTest)
|
|
||||||
endif ()
|
|
||||||
# macro to add a test that will build a nightly release
|
# macro to add a test that will build a nightly release
|
||||||
# of CMake for given platform using the release scripts
|
# of CMake for given platform using the release scripts
|
||||||
macro(ADD_NIGHTLY_BUILD_TEST name script)
|
macro(ADD_NIGHTLY_BUILD_TEST name script)
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
cmake_minimum_required (VERSION 2.6)
|
|
||||||
project (DocTest)
|
|
||||||
|
|
||||||
add_executable (DocTest DocTest.cxx)
|
|
||||||
|
|
||||||
set_property(GLOBAL PROPERTY REPORT_UNDEFINED_PROPERTIES
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/UndefinedProperties.txt")
|
|
|
@ -1,33 +0,0 @@
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int main ()
|
|
||||||
{
|
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
// parse the dart test file
|
|
||||||
std::ifstream fin("UndefinedProperties.txt");
|
|
||||||
if(!fin)
|
|
||||||
{
|
|
||||||
fprintf(stderr,"failed to find undefined properties file");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
char buffer[1024];
|
|
||||||
while ( fin )
|
|
||||||
{
|
|
||||||
buffer[0] = 0;
|
|
||||||
fin.getline(buffer, 1023);
|
|
||||||
buffer[1023] = 0;
|
|
||||||
std::string line = buffer;
|
|
||||||
if(line.size() && line.find("with scope VARIABLE") == std::string::npos)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s\n", line.c_str());
|
|
||||||
result = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fin.close();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
Loading…
Reference in New Issue