diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-04-27 22:10:51 +0200 |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-04-27 22:10:51 +0200 |
commit | 8d9f39f4c324db01d5a60c5a783e1c44180c5c4c (patch) | |
tree | 22345f8edb9060ec8bcaa999874c07ef3b92abbd /Source/cmIncludeCommand.cxx | |
parent | dd062b2b50495b5cb9669efe13538fb032586722 (diff) | |
download | cmake-8d9f39f4c324db01d5a60c5a783e1c44180c5c4c.tar.gz |
include: Ask for permission, rather than forgiveness.
Check that a non-optional file exists before attempting to include
it. This makes more sense than relying on an error case deeper
within cmListFileCache.
Diffstat (limited to 'Source/cmIncludeCommand.cxx')
-rw-r--r-- | Source/cmIncludeCommand.cxx | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index 132b650572..71dabaff4e 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -130,8 +130,20 @@ bool cmIncludeCommand gg->GenerateImportFile(fname_abs); } + std::string listFile = + cmSystemTools::CollapseFullPath(fname.c_str(), + this->Makefile->GetCurrentSourceDirectory()); + if(optional && !cmSystemTools::FileExists(listFile.c_str())) + { + if (!resultVarName.empty()) + { + this->Makefile->AddDefinition(resultVarName, "NOTFOUND"); + } + return true; + } + bool readit = - this->Makefile->ReadDependentFile(fname.c_str(), noPolicyScope); + this->Makefile->ReadDependentFile(listFile.c_str(), noPolicyScope); // add the location of the included file if a result variable was given if (!resultVarName.empty()) |