ENH: Implement additional make clean files as a directory property instead of cmake variable
This commit is contained in:
parent
17d6f9e170
commit
3031467e33
|
@ -146,7 +146,8 @@ MACRO(SWIG_ADD_MODULE name language)
|
|||
SWIG_ADD_SOURCE_TO_MODULE(${name} swig_generated_source ${it})
|
||||
SET(swig_generated_sources ${swig_generated_sources} "${swig_generated_source}")
|
||||
ENDFOREACH(it)
|
||||
SET(ADDITIONAL_MAKE_CLEAN_FILES ${ADDITIONAL_MAKE_CLEAN_FILES} ${swig_generated_sources})
|
||||
SET_DIRECTORY_PROPERTIES(PROPERTIES
|
||||
ADDITIONAL_MAKE_CLEAN_FILES "${ADDITIONAL_MAKE_CLEAN_FILES};${swig_generated_sources}")
|
||||
ADD_LIBRARY(${SWIG_MODULE_${name}_REAL_NAME}
|
||||
MODULE
|
||||
${swig_generated_sources}
|
||||
|
|
|
@ -95,6 +95,12 @@ bool cmGetDirectoryPropertyCommand::InitialPass(
|
|||
}
|
||||
else
|
||||
{
|
||||
const char *prop = m_Makefile->GetProperty(args[1].c_str());
|
||||
if (prop)
|
||||
{
|
||||
m_Makefile->AddDefinition(variable.c_str(), prop);
|
||||
return true;
|
||||
}
|
||||
std::string emsg = "Unknown directory property: " + args[1];
|
||||
this->SetError(emsg.c_str());
|
||||
return false;
|
||||
|
|
|
@ -646,7 +646,7 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
|
|||
}
|
||||
fout << "\n\n";
|
||||
const char * additional_clean_files =
|
||||
m_Makefile->GetDefinition("ADDITIONAL_MAKE_CLEAN_FILES");
|
||||
m_Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES");
|
||||
if ( additional_clean_files && strlen(additional_clean_files) > 0 )
|
||||
{
|
||||
std::string arg = additional_clean_files;
|
||||
|
@ -659,6 +659,7 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
|
|||
}
|
||||
fout << "\n\n";
|
||||
}
|
||||
|
||||
const char * qt_files = m_Makefile->GetDefinition("GENERATED_QT_FILES");
|
||||
if (qt_files != NULL &&
|
||||
strlen(m_Makefile->GetDefinition("GENERATED_QT_FILES"))>0)
|
||||
|
|
|
@ -2400,3 +2400,38 @@ bool cmMakefile::CheckInfiniteLoops()
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void cmMakefile::SetProperty(const char* prop, const char* value)
|
||||
{
|
||||
if (!prop)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!value)
|
||||
{
|
||||
value = "NOTFOUND";
|
||||
}
|
||||
m_Properties[prop] = value;
|
||||
}
|
||||
|
||||
const char *cmMakefile::GetProperty(const char* prop) const
|
||||
{
|
||||
std::map<cmStdString,cmStdString>::const_iterator i =
|
||||
m_Properties.find(prop);
|
||||
if (i != m_Properties.end())
|
||||
{
|
||||
return i->second.c_str();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool cmMakefile::GetPropertyAsBool(const char* prop) const
|
||||
{
|
||||
std::map<cmStdString,cmStdString>::const_iterator i =
|
||||
m_Properties.find(prop);
|
||||
if (i != m_Properties.end())
|
||||
{
|
||||
return cmSystemTools::IsOn(i->second.c_str());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -667,6 +667,11 @@ public:
|
|||
///! Return true if the directory is preorder.
|
||||
bool IsDirectoryPreOrder(const char* dir);
|
||||
|
||||
///! Set/Get a property of this directory
|
||||
void SetProperty(const char *prop, const char *value);
|
||||
const char *GetProperty(const char *prop) const;
|
||||
bool GetPropertyAsBool(const char *prop) const;
|
||||
|
||||
protected:
|
||||
// add link libraries and directories to the target
|
||||
void AddGlobalLinkInformation(const char* name, cmTarget& target);
|
||||
|
@ -743,6 +748,8 @@ private:
|
|||
DefinitionMap::key_type m_TemporaryDefinitionKey;
|
||||
|
||||
cmsys::RegularExpression m_cmDefineRegex;
|
||||
|
||||
std::map<cmStdString,cmStdString> m_Properties;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -68,9 +68,15 @@ bool cmSetDirectoryPropertiesCommand::InitialPass(
|
|||
}
|
||||
else
|
||||
{
|
||||
std::string emsg = "Unknown directory property: " + args[1];
|
||||
this->SetError(emsg.c_str());
|
||||
return false;
|
||||
if ( prop == "ADDITIONAL_MAKE_CLEAN_FILES" )
|
||||
{
|
||||
// This property is not inherrited
|
||||
if ( strcmp(m_Makefile->GetCurrentDirectory(), m_Makefile->GetStartDirectory()) != 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
m_Makefile->SetProperty(prop.c_str(), value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,12 @@ public:
|
|||
*/
|
||||
virtual bool InitialPass(std::vector<std::string> const& args);
|
||||
|
||||
/**
|
||||
* This determines if the command gets propagated down
|
||||
* to makefiles located in subdirectories.
|
||||
*/
|
||||
virtual bool IsInherited() {return true;}
|
||||
|
||||
/**
|
||||
* The name of the command as specified in CMakeList.txt.
|
||||
*/
|
||||
|
@ -55,8 +61,10 @@ public:
|
|||
" SET_DIRECTORY_PROPERTIES(PROPERTIES prop1 value1 prop2 value2)\n"
|
||||
"Set a property for the current directory and subdirectories. If the "
|
||||
"property is not found, CMake will report an error. The properties "
|
||||
"include: INCLUDE_DIRECTORIES, LINK_DIRECTORIES, and "
|
||||
"INCLUDE_REGULAR_EXPRESSION.";
|
||||
"include: INCLUDE_DIRECTORIES, LINK_DIRECTORIES, "
|
||||
"INCLUDE_REGULAR_EXPRESSION, and ADDITIONAL_MAKE_CLEAN_FILES.\n"
|
||||
"ADDITIONAL_MAKE_CLEAN_FILES is a list of files that will be cleaned "
|
||||
"as a part of \"make clean\" stage.";
|
||||
}
|
||||
|
||||
cmTypeMacro(cmSetDirectoryPropertiesCommand, cmCommand);
|
||||
|
|
Loading…
Reference in New Issue