summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmGetFilenameComponentCommand.cxx24
-rw-r--r--Source/cmGetFilenameComponentCommand.h8
2 files changed, 28 insertions, 4 deletions
diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx
index 390cef8..cfefdb9 100644
--- a/Source/cmGetFilenameComponentCommand.cxx
+++ b/Source/cmGetFilenameComponentCommand.cxx
@@ -50,6 +50,17 @@ bool cmGetFilenameComponentCommand::InitialPass(std::vector<std::string> const&
return false;
}
+ // Check and see if the value has been stored in the cache
+ // already, if so use that value
+ if(args.size() == 4 && args[3] == "CACHE")
+ {
+ const char* cacheValue = m_Makefile->GetDefinition(args[0].c_str());
+ if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
+ {
+ return true;
+ }
+ }
+
std::string result;
std::string filename = args[1];
m_Makefile->ExpandVariablesInString(filename);
@@ -77,7 +88,18 @@ bool cmGetFilenameComponentCommand::InitialPass(std::vector<std::string> const&
return false;
}
- m_Makefile->AddDefinition(args[0].c_str(), result.c_str());
+ if(args.size() == 4 && args[3] == "CACHE")
+ {
+ m_Makefile->AddCacheDefinition(args[0].c_str(),
+ result.c_str(),
+ "",
+ args[2] == "PATH" ? cmCacheManager::FILEPATH
+ : cmCacheManager::STRING);
+ }
+ else
+ {
+ m_Makefile->AddDefinition(args[0].c_str(), result.c_str());
+ }
return true;
}
diff --git a/Source/cmGetFilenameComponentCommand.h b/Source/cmGetFilenameComponentCommand.h
index 19b8873..807659d 100644
--- a/Source/cmGetFilenameComponentCommand.h
+++ b/Source/cmGetFilenameComponentCommand.h
@@ -48,7 +48,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* cmGetFilenameComponentCommand is a utility command used to get the path,
* name, extension or name without extension of a full filename.
- * Warning: as a utility command, the resulting value is not put in the cache.
*/
class cmGetFilenameComponentCommand : public cmCommand
{
@@ -92,11 +91,14 @@ public:
virtual const char* GetFullDocumentation()
{
return
- "GET_FILENAME_COMPONENT(VarName FileName PATH|NAME|EXT|NAME_WE)\n"
+ "GET_FILENAME_COMPONENT(VarName FileName PATH|NAME|EXT|NAME_WE [CACHE])\n"
"Set VarName to be the path (PATH), file name (NAME), file "
"extension (EXT) or file name without extension (NAME_WE) of FileName.\n"
"Note that the path is converted to Unix slashes format and has no "
- "trailing slashes. The longest file extension is always considered.";
+ "trailing slashes. The longest file extension is always considered.\n"
+ "Warning: as a utility command, the resulting value is not put in the "
+ "cache but in the definition list, unless you add the optional CACHE "
+ "parameter.";
}
cmTypeMacro(cmGetFilenameComponentCommand, cmCommand);