summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx154
1 files changed, 83 insertions, 71 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index a715f06..f90c35c 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -116,7 +116,6 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals)
this->Targets = mf.Targets;
this->SourceFiles = mf.SourceFiles;
this->Tests = mf.Tests;
- this->IncludeDirectories = mf.IncludeDirectories;
this->LinkDirectories = mf.LinkDirectories;
this->SystemIncludeDirectories = mf.SystemIncludeDirectories;
this->ListFiles = mf.ListFiles;
@@ -278,8 +277,6 @@ void cmMakefile::Print()
this->cmHomeDirectory.c_str() << std::endl;
std::cout << " this->ProjectName; "
<< this->ProjectName.c_str() << std::endl;
- this->PrintStringVector("this->IncludeDirectories;",
- this->IncludeDirectories);
this->PrintStringVector("this->LinkDirectories", this->LinkDirectories);
#if defined(CMAKE_BUILD_WITH_CMAKE)
for( std::vector<cmSourceGroup>::const_iterator i =
@@ -1478,7 +1475,8 @@ void cmMakefile::InitializeFromParent()
this->Internal->VarStack.top() = parent->Internal->VarStack.top().Closure();
// copy include paths
- this->IncludeDirectories = parent->IncludeDirectories;
+ this->SetProperty("INCLUDE_DIRECTORIES",
+ parent->GetProperty("INCLUDE_DIRECTORIES"));
this->SystemIncludeDirectories = parent->SystemIncludeDirectories;
// define flags
@@ -1603,42 +1601,61 @@ void cmMakefile::AddSubDirectory(const char* srcPath, const char *binPath,
}
}
-void cmMakefile::AddIncludeDirectory(const char* inc, bool before)
+//----------------------------------------------------------------------------
+void AddStringToProperty(cmProperty *prop, const char* name, const char* s,
+ bool before)
{
- // if there is a newline then break it into multiple arguments
- if (!inc)
+ if (!prop)
{
return;
}
- // Don't add an include directory that is already present. Yes,
- // this linear search results in n^2 behavior, but n won't be
- // getting much bigger than 20. We cannot use a set because of
- // order dependency of the include path.
- std::vector<std::string>::iterator i =
- std::find(this->IncludeDirectories.begin(),
- this->IncludeDirectories.end(), inc);
- if(i == this->IncludeDirectories.end())
+ // Don't worry about duplicates at this point. We eliminate them when
+ // we convert the property to a vector in GetIncludeDirectories.
+
+ if (before)
{
- if (before)
+ const char *val = prop->GetValue();
+ cmOStringStream oss;
+
+ if(val && *val)
{
- // WARNING: this *is* expensive (linear time) since it's a vector
- this->IncludeDirectories.insert(this->IncludeDirectories.begin(), inc);
+ oss << s << ";" << val;
}
else
{
- this->IncludeDirectories.push_back(inc);
+ oss << s;
}
+
+ std::string newVal = oss.str();
+ prop->Set(name, newVal.c_str());
}
else
{
- if(before)
- {
- // if this before and already in the path then remove it
- this->IncludeDirectories.erase(i);
- // WARNING: this *is* expensive (linear time) since it's a vector
- this->IncludeDirectories.insert(this->IncludeDirectories.begin(), inc);
- }
+ prop->Append(name, s);
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmMakefile::AddIncludeDirectory(const char* inc, bool before)
+{
+ if (!inc)
+ {
+ return;
+ }
+
+ // Directory property:
+ cmProperty *prop =
+ this->GetProperties().GetOrCreateProperty("INCLUDE_DIRECTORIES");
+ AddStringToProperty(prop, "INCLUDE_DIRECTORIES", inc, before);
+
+ // Property on each target:
+ for (cmTargets::iterator l = this->Targets.begin();
+ l != this->Targets.end(); ++l)
+ {
+ cmTarget &t = l->second;
+ prop = t.GetProperties().GetOrCreateProperty("INCLUDE_DIRECTORIES");
+ AddStringToProperty(prop, "INCLUDE_DIRECTORIES", inc, before);
}
}
@@ -2093,17 +2110,37 @@ void cmMakefile::AddExtraDirectory(const char* dir)
}
-// expance CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR in the
+// expand CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR in the
// include and library directories.
void cmMakefile::ExpandVariables()
{
// Now expand variables in the include and link strings
- for(std::vector<std::string>::iterator d = this->IncludeDirectories.begin();
- d != this->IncludeDirectories.end(); ++d)
+
+ // May not be necessary anymore... But may need a policy for strict
+ // backwards compatibility
+ const char *includeDirs = this->GetProperty("INCLUDE_DIRECTORIES");
+ if (includeDirs)
{
- this->ExpandVariablesInString(*d, true, true);
+ std::string dirs = includeDirs;
+ this->ExpandVariablesInString(dirs, true, true);
+ this->SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
+ }
+
+ // Also for each target's INCLUDE_DIRECTORIES property:
+ for (cmTargets::iterator l = this->Targets.begin();
+ l != this->Targets.end(); ++l)
+ {
+ cmTarget &t = l->second;
+ includeDirs = t.GetProperty("INCLUDE_DIRECTORIES");
+ if (includeDirs)
+ {
+ std::string dirs = includeDirs;
+ this->ExpandVariablesInString(dirs, true, true);
+ t.SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
+ }
}
+
for(std::vector<std::string>::iterator d = this->LinkDirectories.begin();
d != this->LinkDirectories.end(); ++d)
{
@@ -3317,16 +3354,6 @@ void cmMakefile::SetProperty(const char* prop, const char* value)
// handle special props
std::string propname = prop;
- if ( propname == "INCLUDE_DIRECTORIES" )
- {
- std::vector<std::string> varArgsExpanded;
- if(value)
- {
- cmSystemTools::ExpandListArgument(value, varArgsExpanded);
- }
- this->SetIncludeDirectories(varArgsExpanded);
- return;
- }
if ( propname == "LINK_DIRECTORIES" )
{
@@ -3368,17 +3395,6 @@ void cmMakefile::AppendProperty(const char* prop, const char* value,
// handle special props
std::string propname = prop;
- if ( propname == "INCLUDE_DIRECTORIES" )
- {
- std::vector<std::string> varArgsExpanded;
- cmSystemTools::ExpandListArgument(value, varArgsExpanded);
- for(std::vector<std::string>::const_iterator vi = varArgsExpanded.begin();
- vi != varArgsExpanded.end(); ++vi)
- {
- this->AddIncludeDirectory(vi->c_str());
- }
- return;
- }
if ( propname == "LINK_DIRECTORIES" )
{
@@ -3474,23 +3490,6 @@ const char *cmMakefile::GetProperty(const char* prop,
output += this->DefineFlagsOrig;
return output.c_str();
}
- else if (!strcmp("INCLUDE_DIRECTORIES",prop) )
- {
- cmOStringStream str;
- for (std::vector<std::string>::const_iterator
- it = this->GetIncludeDirectories().begin();
- it != this->GetIncludeDirectories().end();
- ++ it )
- {
- if ( it != this->GetIncludeDirectories().begin())
- {
- str << ";";
- }
- str << it->c_str();
- }
- output = str.str();
- return output.c_str();
- }
else if (!strcmp("LINK_DIRECTORIES",prop))
{
cmOStringStream str;
@@ -3861,9 +3860,22 @@ void cmMakefile::DefineProperties(cmake *cm)
cm->DefineProperty
("INCLUDE_DIRECTORIES", cmProperty::DIRECTORY,
"List of preprocessor include file search directories.",
- "This read-only property specifies the list of directories given "
- "so far to the include_directories command. "
- "It is intended for debugging purposes.", false);
+ "This property specifies the list of directories given "
+ "so far to the include_directories command. "
+ "This property exists on directories and targets. "
+ "In addition to accepting values from the include_directories "
+ "command, values may be set directly on any directory or any "
+ "target using the set_property command. "
+ "A target gets its initial value for this property from the value "
+ "of the directory property. "
+ "A directory gets its initial value from its parent directory if "
+ "it has one. "
+ "Both directory and target property values are adjusted by calls "
+ "to the include_directories command."
+ "\n"
+ "The target property values are used by the generators to set "
+ "the include paths for the compiler. "
+ "See also the include_directories command.");
cm->DefineProperty
("LINK_DIRECTORIES", cmProperty::DIRECTORY,