summaryrefslogtreecommitdiffstats
path: root/Source/cmListFileCache.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2002-12-02 20:30:59 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2002-12-02 20:30:59 (GMT)
commit27110975c2fb8e579ab85cc2313d0e243fb81d37 (patch)
tree06b8d0c0fa1d0105c57188a4cca5b6142abc9925 /Source/cmListFileCache.cxx
parent5d2f83dad56a5e393374630522259ea4ecb42c96 (diff)
downloadCMake-27110975c2fb8e579ab85cc2313d0e243fb81d37.zip
CMake-27110975c2fb8e579ab85cc2313d0e243fb81d37.tar.gz
CMake-27110975c2fb8e579ab85cc2313d0e243fb81d37.tar.bz2
ENH: add PROJECT command if there is not one
Diffstat (limited to 'Source/cmListFileCache.cxx')
-rw-r--r--Source/cmListFileCache.cxx33
1 files changed, 29 insertions, 4 deletions
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 876ee9f..00c6b1f 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -39,14 +39,15 @@ void cmListFileCache::ClearCache()
-cmListFile* cmListFileCache::GetFileCache(const char* path)
+cmListFile* cmListFileCache::GetFileCache(const char* path,
+ bool requireProjectCommand)
{
ListFileMap::iterator sl = m_ListFileCache.find(path);
if (sl == m_ListFileCache.end())
{
// if not already in the map, then parse and store the
// file
- if(!this->CacheFile(path))
+ if(!this->CacheFile(path, requireProjectCommand))
{
return 0;
}
@@ -61,7 +62,7 @@ cmListFile* cmListFileCache::GetFileCache(const char* path)
cmListFile& ret = sl->second;
if(cmSystemTools::ModifiedTime(path) > ret.m_ModifiedTime )
{
- if(!this->CacheFile(path))
+ if(!this->CacheFile(path, requireProjectCommand))
{
return 0;
}
@@ -75,7 +76,7 @@ cmListFile* cmListFileCache::GetFileCache(const char* path)
}
-bool cmListFileCache::CacheFile(const char* path)
+bool cmListFileCache::CacheFile(const char* path, bool requireProjectCommand)
{
if(!cmSystemTools::FileExists(path))
{
@@ -106,6 +107,30 @@ bool cmListFileCache::CacheFile(const char* path)
inFile.m_ModifiedTime = 0;
}
}
+ if(requireProjectCommand)
+ {
+ bool hasProject = false;
+ // search for a project command
+ for(std::vector<cmListFileFunction>::iterator i
+ = inFile.m_Functions.begin();
+ i != inFile.m_Functions.end(); ++i)
+ {
+ if(i->m_Name == "PROJECT")
+ {
+ hasProject = true;
+ break;
+ }
+ }
+ // if no project command is found, add one
+ if(!hasProject)
+ {
+ cmListFileFunction project;
+ project.m_Name = "PROJECT";
+ project.m_Arguments.push_back("Project");
+ inFile.m_Functions.push_back(project);
+ std::cerr << "adding project command to file " << path << "\n";
+ }
+ }
m_ListFileCache[path] = inFile;
return true;
}