[cmake-commits] king committed cmGetPropertyCommand.cxx 1.6 1.7
cmGetSourceFilePropertyCommand.cxx 1.13 1.14 cmSourceFile.cxx
1.44 1.45 cmSourceFile.h 1.24 1.25
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Jan 30 11:21:56 EST 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv11231/Source
Modified Files:
cmGetPropertyCommand.cxx cmGetSourceFilePropertyCommand.cxx
cmSourceFile.cxx cmSourceFile.h
Log Message:
BUG: Add cmSourceFile::GetPropertyForUser to centralize the LOCATION property hack. This fixes the LOCATION property when retrieved via the get_property command.
Index: cmSourceFile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSourceFile.cxx,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- cmSourceFile.cxx 17 Jan 2008 23:13:55 -0000 1.44
+++ cmSourceFile.cxx 30 Jan 2008 16:21:54 -0000 1.45
@@ -281,6 +281,33 @@
}
//----------------------------------------------------------------------------
+const char* cmSourceFile::GetPropertyForUser(const char *prop)
+{
+ // This method is a consequence of design history and backwards
+ // compatibility. GetProperty is (and should be) a const method.
+ // Computed properties should not be stored back in the property map
+ // but instead reference information already known. If they need to
+ // cache information in a mutable ivar to provide the return string
+ // safely then so be it.
+ //
+ // The LOCATION property is particularly problematic. The CMake
+ // language has very loose restrictions on the names that will match
+ // a given source file (for historical reasons). Implementing
+ // lookups correctly with such loose naming requires the
+ // cmSourceFileLocation class to commit to a particular full path to
+ // the source file as late as possible. If the users requests the
+ // LOCATION property we must commit now.
+ if(strcmp(prop, "LOCATION") == 0)
+ {
+ // Commit to a location.
+ this->GetFullPath();
+ }
+
+ // Perform the normal property lookup.
+ return this->GetProperty(prop);
+}
+
+//----------------------------------------------------------------------------
const char* cmSourceFile::GetProperty(const char* prop) const
{
// Check for computed properties.
Index: cmGetPropertyCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGetPropertyCommand.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cmGetPropertyCommand.cxx 28 Jan 2008 13:38:35 -0000 1.6
+++ cmGetPropertyCommand.cxx 30 Jan 2008 16:21:54 -0000 1.7
@@ -287,7 +287,8 @@
if(cmSourceFile* sf =
this->Makefile->GetOrCreateSource(this->Name.c_str()))
{
- return this->StoreResult(sf->GetProperty(this->PropertyName.c_str()));
+ return
+ this->StoreResult(sf->GetPropertyForUser(this->PropertyName.c_str()));
}
else
{
Index: cmSourceFile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSourceFile.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- cmSourceFile.h 17 Jan 2008 23:13:55 -0000 1.24
+++ cmSourceFile.h 30 Jan 2008 16:21:54 -0000 1.25
@@ -53,6 +53,10 @@
const char *GetProperty(const char *prop) const;
bool GetPropertyAsBool(const char *prop) const;
+ /** Implement getting a property when called from a CMake language
+ command like get_property or get_source_file_property. */
+ const char* GetPropertyForUser(const char *prop);
+
/**
* The full path to the file. The non-const version of this method
* may attempt to locate the file on disk and finalize its location.
Index: cmGetSourceFilePropertyCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGetSourceFilePropertyCommand.cxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- cmGetSourceFilePropertyCommand.cxx 23 Jan 2008 15:27:59 -0000 1.13
+++ cmGetSourceFilePropertyCommand.cxx 30 Jan 2008 16:21:54 -0000 1.14
@@ -38,24 +38,12 @@
}
if(sf)
{
- if(args[2] == "LOCATION")
- {
- // Make sure the location is known. Update: this is a hack to work
- // around a problem with const methods in cmSourceFile, by design
- // GetProperty("LOCATION") should work but right now it has to be
- // "primed" by calling GetFullPath() first on a non-const cmSourceFile
- // instance. This is because LOCATION is a computed-on-demand
- // property. Either GetProperty needs to be non-const or the map
- // needs to be changed to be mutable etc. for computed properties to
- // work properly.
- sf->GetFullPath();
- }
- else if(args[2] == "LANGUAGE")
+ if(args[2] == "LANGUAGE")
{
this->Makefile->AddDefinition(var, sf->GetLanguage());
return true;
}
- const char *prop = sf->GetProperty(args[2].c_str());
+ const char *prop = sf->GetPropertyForUser(args[2].c_str());
if (prop)
{
this->Makefile->AddDefinition(var, prop);
More information about the Cmake-commits
mailing list