ENH: allow source file properties to chain to Directories and up
This commit is contained in:
parent
e1a142f033
commit
5d11564c35
|
@ -69,8 +69,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass
|
||||||
// add the file as a class file so
|
// add the file as a class file so
|
||||||
// depends can be done
|
// depends can be done
|
||||||
cmSourceFile cmfile;
|
cmSourceFile cmfile;
|
||||||
cmfile.GetProperties().SetCMakeInstance
|
cmfile.SetMakefile(this->Makefile);
|
||||||
(this->Makefile->GetCMakeInstance());
|
|
||||||
cmfile.SetName(fullname.c_str(),
|
cmfile.SetName(fullname.c_str(),
|
||||||
this->Makefile->GetCurrentDirectory(),
|
this->Makefile->GetCurrentDirectory(),
|
||||||
this->Makefile->GetSourceExtensions(),
|
this->Makefile->GetSourceExtensions(),
|
||||||
|
|
|
@ -511,7 +511,7 @@ void * CCONV cmCreateNewSourceFile(void *arg)
|
||||||
{
|
{
|
||||||
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
||||||
cmSourceFile *sf = new cmSourceFile;
|
cmSourceFile *sf = new cmSourceFile;
|
||||||
sf->GetProperties().SetCMakeInstance(mf->GetCMakeInstance());
|
sf->SetMakefile(mf);
|
||||||
return (void *)sf;
|
return (void *)sf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args)
|
||||||
|
|
||||||
// Create the source list
|
// Create the source list
|
||||||
cmSourceFile cfile;
|
cmSourceFile cfile;
|
||||||
cfile.GetProperties().SetCMakeInstance(this->Makefile->GetCMakeInstance());
|
cfile.SetMakefile(this->Makefile);
|
||||||
std::string sourceListValue;
|
std::string sourceListValue;
|
||||||
|
|
||||||
cfile.SetProperty("ABSTRACT","0");
|
cfile.SetProperty("ABSTRACT","0");
|
||||||
|
@ -186,8 +186,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args)
|
||||||
for(i = testsBegin; i != tests.end(); ++i)
|
for(i = testsBegin; i != tests.end(); ++i)
|
||||||
{
|
{
|
||||||
cmSourceFile icfile;
|
cmSourceFile icfile;
|
||||||
icfile.GetProperties().
|
icfile.SetMakefile(this->Makefile);
|
||||||
SetCMakeInstance(this->Makefile->GetCMakeInstance());
|
|
||||||
icfile.SetProperty("ABSTRACT","0");
|
icfile.SetProperty("ABSTRACT","0");
|
||||||
icfile.SetName(i->c_str(),
|
icfile.SetName(i->c_str(),
|
||||||
this->Makefile->GetCurrentDirectory(),
|
this->Makefile->GetCurrentDirectory(),
|
||||||
|
|
|
@ -54,8 +54,7 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args)
|
||||||
if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE"))
|
if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE"))
|
||||||
{
|
{
|
||||||
cmSourceFile header_file;
|
cmSourceFile header_file;
|
||||||
header_file.GetProperties().SetCMakeInstance
|
header_file.SetMakefile(this->Makefile);
|
||||||
(this->Makefile->GetCMakeInstance());
|
|
||||||
std::string srcName = cmSystemTools::GetFilenameWithoutExtension(*i);
|
std::string srcName = cmSystemTools::GetFilenameWithoutExtension(*i);
|
||||||
const bool headerFileOnly = true;
|
const bool headerFileOnly = true;
|
||||||
header_file.SetName(srcName.c_str(),
|
header_file.SetName(srcName.c_str(),
|
||||||
|
|
|
@ -2281,7 +2281,7 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName,
|
||||||
|
|
||||||
// we must create one
|
// we must create one
|
||||||
cmSourceFile file;
|
cmSourceFile file;
|
||||||
file.GetProperties().SetCMakeInstance(this->GetCMakeInstance());
|
file.SetMakefile(this);
|
||||||
std::string path = cmSystemTools::GetFilenamePath(src);
|
std::string path = cmSystemTools::GetFilenamePath(src);
|
||||||
if(generated)
|
if(generated)
|
||||||
{
|
{
|
||||||
|
@ -2329,12 +2329,15 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName,
|
||||||
this->AddSource(file);
|
this->AddSource(file);
|
||||||
src = file.GetFullPath();
|
src = file.GetFullPath();
|
||||||
ret = this->GetSource(src.c_str());
|
ret = this->GetSource(src.c_str());
|
||||||
ret->GetProperties().SetCMakeInstance(this->GetCMakeInstance());
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error(
|
cmSystemTools::Error(
|
||||||
"CMake failed to properly look up cmSourceFile: ", sourceName);
|
"CMake failed to properly look up cmSourceFile: ", sourceName);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret->SetMakefile(this);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "cmake.h"
|
#include "cmake.h"
|
||||||
|
|
||||||
// define STRICT to get checking of all set and get property calls
|
// define STRICT to get checking of all set and get property calls
|
||||||
//#define STRICT
|
#define STRICT
|
||||||
|
|
||||||
cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name)
|
cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
#include "cmake.h"
|
#include "cmake.h"
|
||||||
|
#include "cmMakefile.h"
|
||||||
|
|
||||||
// Set the name of the class and the full path to the file.
|
// Set the name of the class and the full path to the file.
|
||||||
// The class must be found in dir and end in name.cxx, name.txx,
|
// The class must be found in dir and end in name.cxx, name.txx,
|
||||||
|
@ -193,8 +194,14 @@ const char *cmSourceFile::GetProperty(const char* prop) const
|
||||||
}
|
}
|
||||||
|
|
||||||
bool chain = false;
|
bool chain = false;
|
||||||
return this->Properties.GetPropertyValue(prop,cmProperty::SOURCE_FILE,
|
const char *retVal =
|
||||||
chain);
|
this->Properties.GetPropertyValue(prop, cmProperty::SOURCE_FILE, chain);
|
||||||
|
if (chain)
|
||||||
|
{
|
||||||
|
return this->Makefile->GetProperty(prop,cmProperty::SOURCE_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmSourceFile::GetPropertyAsBool(const char* prop) const
|
bool cmSourceFile::GetPropertyAsBool(const char* prop) const
|
||||||
|
@ -223,9 +230,20 @@ const std::string& cmSourceFile::GetSourceNameWithoutLastExtension()
|
||||||
|
|
||||||
cmSourceFile::cmSourceFile()
|
cmSourceFile::cmSourceFile()
|
||||||
{
|
{
|
||||||
|
this->Makefile = 0;
|
||||||
this->CustomCommand = 0;
|
this->CustomCommand = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmSourceFile::SetMakefile(cmMakefile* mf)
|
||||||
|
{
|
||||||
|
// Set our makefile.
|
||||||
|
this->Makefile = mf;
|
||||||
|
|
||||||
|
// set the cmake instance of the properties
|
||||||
|
this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
|
||||||
|
}
|
||||||
|
|
||||||
// define properties
|
// define properties
|
||||||
void cmSourceFile::DefineProperties(cmake *cm)
|
void cmSourceFile::DefineProperties(cmake *cm)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "cmPropertyMap.h"
|
#include "cmPropertyMap.h"
|
||||||
|
|
||||||
class cmake;
|
class cmake;
|
||||||
|
class cmMakefile;
|
||||||
|
|
||||||
/** \class cmSourceFile
|
/** \class cmSourceFile
|
||||||
* \brief Represent a class loaded from a makefile.
|
* \brief Represent a class loaded from a makefile.
|
||||||
|
@ -114,6 +115,10 @@ public:
|
||||||
// Define the properties
|
// Define the properties
|
||||||
static void DefineProperties(cmake *cm);
|
static void DefineProperties(cmake *cm);
|
||||||
|
|
||||||
|
///! Set the cmMakefile that owns this target
|
||||||
|
void SetMakefile(cmMakefile *mf);
|
||||||
|
cmMakefile *GetMakefile() { return this->Makefile;};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cmPropertyMap Properties;
|
cmPropertyMap Properties;
|
||||||
cmCustomCommand *CustomCommand;
|
cmCustomCommand *CustomCommand;
|
||||||
|
@ -122,6 +127,10 @@ private:
|
||||||
std::string SourceExtension;
|
std::string SourceExtension;
|
||||||
std::vector<std::string> Depends;
|
std::vector<std::string> Depends;
|
||||||
std::string SourceNameWithoutLastExtension;
|
std::string SourceNameWithoutLastExtension;
|
||||||
|
|
||||||
|
// The cmMakefile instance that owns this source file. This should
|
||||||
|
// always be set.
|
||||||
|
cmMakefile* Makefile;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue