[Cmake-commits] [cmake-commits] king committed cmGlobalGenerator.cxx 1.248 1.249 cmGlobalGenerator.h 1.117 1.118 cmSourceFile.cxx 1.53 1.54 cmTarget.cxx 1.233 1.234
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue Feb 10 08:50:24 EST 2009
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv9217/Source
Modified Files:
cmGlobalGenerator.cxx cmGlobalGenerator.h cmSourceFile.cxx
cmTarget.cxx
Log Message:
ENH: Define target and source property LABELS
This creates a new LABELS property for targets and source files. We
write the labels of each target and its source files in target-specific
locations in the build tree for future use.
Index: cmSourceFile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSourceFile.cxx,v
retrieving revision 1.53
retrieving revision 1.54
diff -C 2 -d -r1.53 -r1.54
*** cmSourceFile.cxx 22 Sep 2008 13:42:27 -0000 1.53
--- cmSourceFile.cxx 10 Feb 2009 13:50:21 -0000 1.54
***************
*** 478,481 ****
--- 478,488 ----
cm->DefineProperty
+ ("LABELS", cmProperty::SOURCE_FILE,
+ "Specify a list of text labels associated with a source file.",
+ "This property has meaning only when the source file is listed in "
+ "a target whose LABELS property is also set. "
+ "No other semantics are currently specified.");
+
+ cm->DefineProperty
("LANGUAGE", cmProperty::SOURCE_FILE,
"What programming language is the file.",
Index: cmGlobalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.h,v
retrieving revision 1.117
retrieving revision 1.118
diff -C 2 -d -r1.117 -r1.118
*** cmGlobalGenerator.h 2 Feb 2009 18:28:12 -0000 1.117
--- cmGlobalGenerator.h 10 Feb 2009 13:50:21 -0000 1.118
***************
*** 329,332 ****
--- 329,335 ----
void CheckRuleHashes();
+ void WriteTargetLabels();
+ bool WriteTargetLabels(cmTarget* target, std::string& file);
+
cmExternalMakefileProjectGenerator* ExtraGenerator;
Index: cmGlobalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.cxx,v
retrieving revision 1.248
retrieving revision 1.249
diff -C 2 -d -r1.248 -r1.249
*** cmGlobalGenerator.cxx 2 Feb 2009 19:36:45 -0000 1.248
--- cmGlobalGenerator.cxx 10 Feb 2009 13:50:21 -0000 1.249
***************
*** 898,901 ****
--- 898,903 ----
this->CheckRuleHashes();
+ this->WriteTargetLabels();
+
if (this->ExtraGenerator != 0)
{
***************
*** 2121,2122 ****
--- 2123,2212 ----
#endif
}
+
+ //----------------------------------------------------------------------------
+ void cmGlobalGenerator::WriteTargetLabels()
+ {
+ cmMakefile* mf = this->LocalGenerators[0]->GetMakefile();
+
+ // Record generated per-target label files in a central location.
+ std::string fname = mf->GetHomeOutputDirectory();
+ fname += cmake::GetCMakeFilesDirectory();
+ fname += "/LabelFiles.txt";
+ bool opened = false;
+ cmGeneratedFileStream fout;
+
+ // Generate a label file for each target.
+ std::string file;
+ for(std::map<cmStdString,cmTarget *>::const_iterator ti =
+ this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
+ {
+ if(this->WriteTargetLabels(ti->second, file))
+ {
+ if(!opened)
+ {
+ fout.Open(fname.c_str());
+ }
+ fout << file << "\n";
+ }
+ }
+ if(!opened)
+ {
+ cmSystemTools::RemoveFile(fname.c_str());
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ bool cmGlobalGenerator::WriteTargetLabels(cmTarget* target, std::string& file)
+ {
+ // Place the labels file in a per-target support directory.
+ std::string dir = target->GetSupportDirectory();
+ file = dir;
+ file += "/Labels.txt";
+
+ // Check whether labels are enabled for this target.
+ if(const char* value = target->GetProperty("LABELS"))
+ {
+ cmSystemTools::MakeDirectory(dir.c_str());
+ cmGeneratedFileStream fout(file.c_str());
+
+ // List the target-wide labels. All sources in the target get
+ // these labels.
+ std::vector<std::string> labels;
+ cmSystemTools::ExpandListArgument(value, labels);
+ if(!labels.empty())
+ {
+ fout << "# Target labels\n";
+ for(std::vector<std::string>::const_iterator li = labels.begin();
+ li != labels.end(); ++li)
+ {
+ fout << " " << *li << "\n";
+ }
+ }
+
+ // List the source files with any per-source labels.
+ fout << "# Source files and their labels\n";
+ std::vector<cmSourceFile*> const& sources = target->GetSourceFiles();
+ for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
+ si != sources.end(); ++si)
+ {
+ cmSourceFile* sf = *si;
+ fout << sf->GetFullPath() << "\n";
+ if(const char* svalue = sf->GetProperty("LABELS"))
+ {
+ labels.clear();
+ cmSystemTools::ExpandListArgument(svalue, labels);
+ for(std::vector<std::string>::const_iterator li = labels.begin();
+ li != labels.end(); ++li)
+ {
+ fout << " " << *li << "\n";
+ }
+ }
+ }
+ return true;
+ }
+ else
+ {
+ cmSystemTools::RemoveFile(file.c_str());
+ return false;
+ }
+ }
Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.233
retrieving revision 1.234
diff -C 2 -d -r1.233 -r1.234
*** cmTarget.cxx 10 Feb 2009 13:50:09 -0000 1.233
--- cmTarget.cxx 10 Feb 2009 13:50:21 -0000 1.234
***************
*** 352,355 ****
--- 352,360 ----
cm->DefineProperty
+ ("LABELS", cmProperty::TARGET,
+ "Specify a list of text labels associated with a target.",
+ "Target label semantics are currently unspecified.");
+
+ cm->DefineProperty
("LINK_FLAGS", cmProperty::TARGET,
"Additional flags to use when linking this target.",
More information about the Cmake-commits
mailing list