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