ENH: add first cut and policies still need to add the doc support
This commit is contained in:
parent
32ca01bef0
commit
d49ef18f8a
|
@ -134,9 +134,7 @@ ENDMACRO(CMAKE_TEST_FOR_MFC)
|
||||||
# for testing. Simply to improve readability of the main script.
|
# for testing. Simply to improve readability of the main script.
|
||||||
#-----------------------------------------------------------------------
|
#-----------------------------------------------------------------------
|
||||||
MACRO(CMAKE_SETUP_TESTING)
|
MACRO(CMAKE_SETUP_TESTING)
|
||||||
IF (NOT DART_ROOT)
|
|
||||||
SET(MAKEPROGRAM ${CMAKE_MAKE_PROGRAM})
|
SET(MAKEPROGRAM ${CMAKE_MAKE_PROGRAM})
|
||||||
ENDIF (NOT DART_ROOT)
|
|
||||||
|
|
||||||
IF(BUILD_TESTING)
|
IF(BUILD_TESTING)
|
||||||
SET(CMAKE_TEST_GENERATOR "" CACHE STRING
|
SET(CMAKE_TEST_GENERATOR "" CACHE STRING
|
||||||
|
@ -190,11 +188,6 @@ MACRO(CMAKE_SETUP_TESTING)
|
||||||
${CMake_BINARY_DIR}/CTestCustom.cmake @ONLY)
|
${CMake_BINARY_DIR}/CTestCustom.cmake @ONLY)
|
||||||
CONFIGURE_FILE(${CMake_SOURCE_DIR}/CTestCustom.ctest.in
|
CONFIGURE_FILE(${CMake_SOURCE_DIR}/CTestCustom.ctest.in
|
||||||
${CMake_BINARY_DIR}/CTestCustom.ctest @ONLY)
|
${CMake_BINARY_DIR}/CTestCustom.ctest @ONLY)
|
||||||
IF(BUILD_TESTING AND DART_ROOT)
|
|
||||||
CONFIGURE_FILE(${CMake_SOURCE_DIR}/CMakeLogo.gif
|
|
||||||
${CMake_BINARY_DIR}/Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY)
|
|
||||||
ENDIF(BUILD_TESTING AND DART_ROOT)
|
|
||||||
MARK_AS_ADVANCED(DART_ROOT)
|
|
||||||
MARK_AS_ADVANCED(CURL_TESTING)
|
MARK_AS_ADVANCED(CURL_TESTING)
|
||||||
ENDMACRO(CMAKE_SETUP_TESTING)
|
ENDMACRO(CMAKE_SETUP_TESTING)
|
||||||
|
|
||||||
|
@ -365,7 +358,7 @@ SET(CMake_VERSION_FULL "${CMake_VERSION}.${CMake_VERSION_PATCH}")
|
||||||
|
|
||||||
# Include the standard Dart testing module
|
# Include the standard Dart testing module
|
||||||
ENABLE_TESTING()
|
ENABLE_TESTING()
|
||||||
INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake)
|
INCLUDE (${CMAKE_ROOT}/Modules/CTest.cmake)
|
||||||
|
|
||||||
# where to write the resulting executables and libraries
|
# where to write the resulting executables and libraries
|
||||||
SET(BUILD_SHARED_LIBS OFF)
|
SET(BUILD_SHARED_LIBS OFF)
|
||||||
|
|
|
@ -184,6 +184,8 @@ SET(SRCS
|
||||||
cmMakefileUtilityTargetGenerator.cxx
|
cmMakefileUtilityTargetGenerator.cxx
|
||||||
cmOrderDirectories.cxx
|
cmOrderDirectories.cxx
|
||||||
cmOrderDirectories.h
|
cmOrderDirectories.h
|
||||||
|
cmPolicies.h
|
||||||
|
cmPolicies.cxx
|
||||||
cmProperty.cxx
|
cmProperty.cxx
|
||||||
cmProperty.h
|
cmProperty.h
|
||||||
cmPropertyDefinition.cxx
|
cmPropertyDefinition.cxx
|
||||||
|
|
|
@ -29,22 +29,28 @@ bool cmAddCustomTargetCommand
|
||||||
// Check the target name.
|
// Check the target name.
|
||||||
if(args[0].find_first_of("/\\") != args[0].npos)
|
if(args[0].find_first_of("/\\") != args[0].npos)
|
||||||
{
|
{
|
||||||
int major = 0;
|
// slashes are not allowed anymore in taret names CMP_0001
|
||||||
int minor = 0;
|
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP_0001))
|
||||||
if(const char* versionValue =
|
|
||||||
this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"))
|
|
||||||
{
|
{
|
||||||
sscanf(versionValue, "%d.%d", &major, &minor);
|
case cmPolicies::WARN:
|
||||||
}
|
cmSystemTools::Message(
|
||||||
if(!major || major > 3 || (major == 2 && minor > 2))
|
this->Makefile->GetPolicies()->GetPolicyWarning
|
||||||
{
|
(cmPolicies::CMP_0001).c_str(),"Warning");
|
||||||
cmOStringStream e;
|
case cmPolicies::OLD:
|
||||||
e << "called with invalid target name \"" << args[0]
|
// if (this->Makefile->IsBWCompatibilityLessThan(2,2))
|
||||||
<< "\". Target names may not contain a slash. "
|
// {
|
||||||
<< "Use ADD_CUSTOM_COMMAND to generate files. "
|
// break;
|
||||||
<< "Set CMAKE_BACKWARDS_COMPATIBILITY to 2.2 "
|
// }
|
||||||
<< "or lower to skip this check.";
|
case cmPolicies::NEW:
|
||||||
this->SetError(e.str().c_str());
|
this->SetError("You included a / or \\ in your target name and "
|
||||||
|
"this is not allowed according to policy CMP_0001. Run "
|
||||||
|
"cmake --help-policy CMP_0001 for more information.");
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case cmPolicies::REQUIRED_IF_USED:
|
||||||
|
this->SetError(
|
||||||
|
this->Makefile->GetPolicies()->GetRequiredPolicyError
|
||||||
|
(cmPolicies::CMP_0001).c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "cmBreakCommand.cxx"
|
#include "cmBreakCommand.cxx"
|
||||||
#include "cmBuildCommand.cxx"
|
#include "cmBuildCommand.cxx"
|
||||||
#include "cmCMakeMinimumRequired.cxx"
|
#include "cmCMakeMinimumRequired.cxx"
|
||||||
|
#include "cmCMakePolicyCommand.cxx"
|
||||||
#include "cmCommandArgumentsHelper.cxx"
|
#include "cmCommandArgumentsHelper.cxx"
|
||||||
#include "cmConfigureFileCommand.cxx"
|
#include "cmConfigureFileCommand.cxx"
|
||||||
#include "cmCoreTryCompile.cxx"
|
#include "cmCoreTryCompile.cxx"
|
||||||
|
@ -105,6 +106,7 @@ void GetBootstrapCommands(std::list<cmCommand*>& commands)
|
||||||
commands.push_back(new cmBreakCommand);
|
commands.push_back(new cmBreakCommand);
|
||||||
commands.push_back(new cmBuildCommand);
|
commands.push_back(new cmBuildCommand);
|
||||||
commands.push_back(new cmCMakeMinimumRequired);
|
commands.push_back(new cmCMakeMinimumRequired);
|
||||||
|
commands.push_back(new cmCMakePolicyCommand);
|
||||||
commands.push_back(new cmConfigureFileCommand);
|
commands.push_back(new cmConfigureFileCommand);
|
||||||
commands.push_back(new cmCreateTestSourceList);
|
commands.push_back(new cmCreateTestSourceList);
|
||||||
commands.push_back(new cmDefinePropertyCommand);
|
commands.push_back(new cmDefinePropertyCommand);
|
||||||
|
|
|
@ -96,14 +96,6 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This determines if the method is deprecated or not.
|
|
||||||
*/
|
|
||||||
virtual bool IsDeprecated(int /*major*/, int /*minor*/)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This determines if usage of the method is discouraged or not.
|
* This determines if usage of the method is discouraged or not.
|
||||||
* This is currently only used for generating the documentation.
|
* This is currently only used for generating the documentation.
|
||||||
|
|
|
@ -61,7 +61,7 @@ bool cmIncludeDirectoryCommand
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->SetError(errorMessage);
|
this->SetError(errorMessage);
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -291,24 +291,14 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
|
||||||
this->GetCMakeInstance()->GetCommand(name.c_str());
|
this->GetCMakeInstance()->GetCommand(name.c_str());
|
||||||
if(rm)
|
if(rm)
|
||||||
{
|
{
|
||||||
const char* versionValue
|
// const char* versionValue
|
||||||
= this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
|
// = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
|
||||||
int major = 0;
|
// int major = 0;
|
||||||
int minor = 0;
|
// int minor = 0;
|
||||||
if ( versionValue )
|
// if ( versionValue )
|
||||||
{
|
// {
|
||||||
sscanf(versionValue, "%d.%d", &major, &minor);
|
// sscanf(versionValue, "%d.%d", &major, &minor);
|
||||||
}
|
// }
|
||||||
if ( rm->IsDeprecated(major, minor) )
|
|
||||||
{
|
|
||||||
cmOStringStream error;
|
|
||||||
error << "Error in cmake code at\n"
|
|
||||||
<< lff.FilePath << ":" << lff.Line << ":\n"
|
|
||||||
<< rm->GetError() << std::endl
|
|
||||||
<< " Called from: " << this->GetListFileStack().c_str();
|
|
||||||
cmSystemTools::Error(error.str().c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
cmCommand* usedCommand = rm->Clone();
|
cmCommand* usedCommand = rm->Clone();
|
||||||
usedCommand->SetMakefile(this);
|
usedCommand->SetMakefile(this);
|
||||||
bool keepCommand = false;
|
bool keepCommand = false;
|
||||||
|
@ -3148,8 +3138,24 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
|
||||||
msg = e.str();
|
msg = e.str();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if(!this->NeedBackwardsCompatibility(2, 4))
|
else
|
||||||
{
|
{
|
||||||
|
// target names must be globally unique
|
||||||
|
switch (this->GetPolicyStatus(cmPolicies::CMP_0002))
|
||||||
|
{
|
||||||
|
case cmPolicies::WARN:
|
||||||
|
msg = this->GetPolicies()->
|
||||||
|
GetPolicyWarning(cmPolicies::CMP_0002);
|
||||||
|
case cmPolicies::OLD:
|
||||||
|
return true;
|
||||||
|
case cmPolicies::REQUIRED_IF_USED:
|
||||||
|
msg = this->GetPolicies()->
|
||||||
|
GetRequiredPolicyError(cmPolicies::CMP_0002);
|
||||||
|
return false;
|
||||||
|
case cmPolicies::NEW:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// The conflict is with a non-imported target.
|
// The conflict is with a non-imported target.
|
||||||
// Allow this if the user has requested support.
|
// Allow this if the user has requested support.
|
||||||
cmake* cm =
|
cmake* cm =
|
||||||
|
@ -3225,3 +3231,107 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmPolicies::PolicyStatus cmMakefile
|
||||||
|
::GetPolicyStatus(cmPolicies::PolicyID id)
|
||||||
|
{
|
||||||
|
cmPolicies::PolicyStatus status;
|
||||||
|
PolicyMap::iterator mappos;
|
||||||
|
unsigned int vecpos;
|
||||||
|
bool done = false;
|
||||||
|
// check our policy stack first
|
||||||
|
for (vecpos = this->PolicyStack.size(); vecpos >= 0 && !done; vecpos--)
|
||||||
|
{
|
||||||
|
mappos = this->PolicyStack[vecpos].find(id);
|
||||||
|
if (mappos != this->PolicyStack[vecpos].end())
|
||||||
|
{
|
||||||
|
status = mappos->second;
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if not found then
|
||||||
|
if (!done)
|
||||||
|
{
|
||||||
|
// pass the buck to our parent if we have one
|
||||||
|
if (this->LocalGenerator->GetParent())
|
||||||
|
{
|
||||||
|
cmMakefile *parent =
|
||||||
|
this->LocalGenerator->GetParent()->GetMakefile();
|
||||||
|
return parent->GetPolicyStatus(id);
|
||||||
|
}
|
||||||
|
// otherwise use the default
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = this->GetPolicies()->GetPolicyStatus(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// warn if we see a REQUIRED_IF_USED above a OLD or WARN
|
||||||
|
if (!this->GetPolicies()->IsValidUsedPolicyStatus(id,status))
|
||||||
|
{
|
||||||
|
return cmPolicies::REQUIRED_IF_USED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cmMakefile::SetPolicy(const char *id,
|
||||||
|
cmPolicies::PolicyStatus status)
|
||||||
|
{
|
||||||
|
cmPolicies::PolicyID pid;
|
||||||
|
if (!this->GetPolicies()->GetPolicyID(id, /* out */ pid))
|
||||||
|
{
|
||||||
|
cmSystemTools::Error("Invalid policy string used. Invalid string was "
|
||||||
|
, id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return this->SetPolicy(pid,status);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
|
||||||
|
cmPolicies::PolicyStatus status)
|
||||||
|
{
|
||||||
|
// setting a REQUIRED_ALWAYS policy to WARN or OLD is an insta error
|
||||||
|
if (this->GetPolicies()->
|
||||||
|
IsValidPolicyStatus(id,status))
|
||||||
|
{
|
||||||
|
this->PolicyStack.back()[id] = status;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cmMakefile::PushPolicy()
|
||||||
|
{
|
||||||
|
// Allocate a new stack entry.
|
||||||
|
this->PolicyStack.push_back(PolicyMap());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cmMakefile::PopPolicy()
|
||||||
|
{
|
||||||
|
if (PolicyStack.size() == 0)
|
||||||
|
{
|
||||||
|
cmSystemTools::Error("Attempt to pop the policy stack past "
|
||||||
|
"it's beginning.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this->PolicyStack.pop_back();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cmMakefile::SetPolicyVersion(const char *version)
|
||||||
|
{
|
||||||
|
return this->GetCMakeInstance()->GetPolicies()->
|
||||||
|
ApplyPolicyVersion(this,version);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmPolicies *cmMakefile::GetPolicies()
|
||||||
|
{
|
||||||
|
if (!this->GetCMakeInstance())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return this->GetCMakeInstance()->GetPolicies();
|
||||||
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "cmData.h"
|
#include "cmData.h"
|
||||||
#include "cmExecutionStatus.h"
|
#include "cmExecutionStatus.h"
|
||||||
#include "cmListFileCache.h"
|
#include "cmListFileCache.h"
|
||||||
|
#include "cmPolicies.h"
|
||||||
#include "cmPropertyMap.h"
|
#include "cmPropertyMap.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmTarget.h"
|
#include "cmTarget.h"
|
||||||
|
@ -323,6 +324,23 @@ public:
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//@{
|
||||||
|
/**
|
||||||
|
* Set, Push, Pop policy values for CMake.
|
||||||
|
*/
|
||||||
|
bool SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
|
||||||
|
bool SetPolicy(const char *id, cmPolicies::PolicyStatus status);
|
||||||
|
cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
|
||||||
|
bool PushPolicy();
|
||||||
|
bool PopPolicy();
|
||||||
|
bool SetPolicyVersion(const char *version);
|
||||||
|
//@}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Policies Instance
|
||||||
|
*/
|
||||||
|
cmPolicies *GetPolicies();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an auxiliary directory to the build.
|
* Add an auxiliary directory to the build.
|
||||||
*/
|
*/
|
||||||
|
@ -861,6 +879,11 @@ private:
|
||||||
cmTarget* FindBasicTarget(const char* name);
|
cmTarget* FindBasicTarget(const char* name);
|
||||||
std::vector<cmTarget*> ImportedTargetsOwned;
|
std::vector<cmTarget*> ImportedTargetsOwned;
|
||||||
std::map<cmStdString, cmTarget*> ImportedTargets;
|
std::map<cmStdString, cmTarget*> ImportedTargets;
|
||||||
|
|
||||||
|
// stack of policy settings
|
||||||
|
typedef std::map<cmPolicies::PolicyID,
|
||||||
|
cmPolicies::PolicyStatus> PolicyMap;
|
||||||
|
std::vector<PolicyMap> PolicyStack;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,8 @@ cmake::cmake()
|
||||||
this->ClearBuildSystem = false;
|
this->ClearBuildSystem = false;
|
||||||
this->FileComparison = new cmFileTimeComparison;
|
this->FileComparison = new cmFileTimeComparison;
|
||||||
|
|
||||||
|
this->Policies = new cmPolicies();
|
||||||
|
|
||||||
this->Properties.SetCMakeInstance(this);
|
this->Properties.SetCMakeInstance(this);
|
||||||
|
|
||||||
// initialize properties
|
// initialize properties
|
||||||
|
@ -203,6 +205,7 @@ cmake::cmake()
|
||||||
cmake::~cmake()
|
cmake::~cmake()
|
||||||
{
|
{
|
||||||
delete this->CacheManager;
|
delete this->CacheManager;
|
||||||
|
delete this->Policies;
|
||||||
if (this->GlobalGenerator)
|
if (this->GlobalGenerator)
|
||||||
{
|
{
|
||||||
delete this->GlobalGenerator;
|
delete this->GlobalGenerator;
|
||||||
|
|
|
@ -53,6 +53,7 @@ class cmVariableWatch;
|
||||||
class cmFileTimeComparison;
|
class cmFileTimeComparison;
|
||||||
class cmExternalMakefileProjectGenerator;
|
class cmExternalMakefileProjectGenerator;
|
||||||
class cmDocumentationSection;
|
class cmDocumentationSection;
|
||||||
|
class cmPolicies;
|
||||||
|
|
||||||
class cmake
|
class cmake
|
||||||
{
|
{
|
||||||
|
@ -238,6 +239,8 @@ class cmake
|
||||||
///! this is called by generators to update the progress
|
///! this is called by generators to update the progress
|
||||||
void UpdateProgress(const char *msg, float prog);
|
void UpdateProgress(const char *msg, float prog);
|
||||||
|
|
||||||
|
///! get the cmake policies instance
|
||||||
|
cmPolicies *GetPolicies() {return this->Policies;} ;
|
||||||
|
|
||||||
///! Get the variable watch object
|
///! Get the variable watch object
|
||||||
cmVariableWatch* GetVariableWatch() { return this->VariableWatch; }
|
cmVariableWatch* GetVariableWatch() { return this->VariableWatch; }
|
||||||
|
@ -358,6 +361,7 @@ protected:
|
||||||
void AddExtraGenerator(const char* name,
|
void AddExtraGenerator(const char* name,
|
||||||
CreateExtraGeneratorFunctionType newFunction);
|
CreateExtraGeneratorFunctionType newFunction);
|
||||||
|
|
||||||
|
cmPolicies *Policies;
|
||||||
cmGlobalGenerator *GlobalGenerator;
|
cmGlobalGenerator *GlobalGenerator;
|
||||||
cmCacheManager *CacheManager;
|
cmCacheManager *CacheManager;
|
||||||
std::string cmHomeDirectory;
|
std::string cmHomeDirectory;
|
||||||
|
|
Loading…
Reference in New Issue