summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmElseCommand.cxx2
-rw-r--r--Source/cmFindFileCommand.cxx5
-rw-r--r--Source/cmFindLibraryCommand.cxx5
-rw-r--r--Source/cmFindPathCommand.cxx5
-rw-r--r--Source/cmIfCommand.cxx2
-rw-r--r--Source/cmSystemTools.cxx17
-rw-r--r--Source/cmSystemTools.h14
7 files changed, 35 insertions, 15 deletions
diff --git a/Source/cmElseCommand.cxx b/Source/cmElseCommand.cxx
index bebee88..b905945 100644
--- a/Source/cmElseCommand.cxx
+++ b/Source/cmElseCommand.cxx
@@ -51,7 +51,7 @@ bool cmElseCommand::Invoke(std::vector<std::string>& args)
// check to see if the argument is defined first
const char *def = m_Makefile->GetDefinition(args[0].c_str());
- if(cmSystemTools::IsOn(def))
+ if(!cmSystemTools::IsOff(def))
{
// add block
cmIfFunctionBlocker *f = new cmIfFunctionBlocker();
diff --git a/Source/cmFindFileCommand.cxx b/Source/cmFindFileCommand.cxx
index 2128356..009f291 100644
--- a/Source/cmFindFileCommand.cxx
+++ b/Source/cmFindFileCommand.cxx
@@ -63,17 +63,14 @@ bool cmFindFileCommand::Invoke(std::vector<std::string>& args)
helpString += args[1] + " file be found";
const char* cacheValue
= cmCacheManager::GetInstance()->GetCacheValue(define);
- if(cacheValue)
+ if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
{
- if(strcmp(cacheValue, "NOTFOUND") != 0)
- {
m_Makefile->AddDefinition(define, cacheValue);
// update help string if changed
cmCacheManager::GetInstance()->AddCacheEntry(define,
cacheValue,
helpString.c_str(),
cmCacheManager::FILEPATH);
- }
return true;
}
// if it is not in the cache, then search the system path
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index 0794101..6d2df8f 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -55,16 +55,13 @@ bool cmFindLibraryCommand::Invoke(std::vector<std::string>& args)
helpString += args[1] + " library be found";
const char* cacheValue
= cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
- if(cacheValue)
+ if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
{
- if(strcmp(cacheValue, "NOTFOUND") != 0)
- {
m_Makefile->AddDefinition(args[0].c_str(), cacheValue);
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
cacheValue,
helpString.c_str(),
cmCacheManager::PATH);
- }
return true;
}
diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx
index 482123b..01221bc 100644
--- a/Source/cmFindPathCommand.cxx
+++ b/Source/cmFindPathCommand.cxx
@@ -56,16 +56,13 @@ bool cmFindPathCommand::Invoke(std::vector<std::string>& args)
helpString += args[1] + " can be found";
const char* cacheValue
= cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
- if(cacheValue)
+ if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
{
- if(strcmp(cacheValue, "NOTFOUND") != 0)
- {
m_Makefile->AddDefinition(args[0].c_str(), cacheValue);
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
cacheValue,
helpString.c_str(),
cmCacheManager::PATH);
- }
return true;
}
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index 462d649..86803de 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -73,7 +73,7 @@ bool cmIfCommand::Invoke(std::vector<std::string>& args)
// check to see if the argument is defined first
const char *def = m_Makefile->GetDefinition(args[0].c_str());
- if(cmSystemTools::IsOn(def))
+ if(!cmSystemTools::IsOff(def))
{
// do nothing
}
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 2da8439..9211d8b 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -544,3 +544,20 @@ bool cmSystemTools::IsOn(const char* val)
}
return (v == "ON" || v == "1" || v == "YES" || v == "TRUE" || v == "Y");
}
+
+bool cmSystemTools::IsOff(const char* val)
+{
+ if (!val)
+ {
+ return true;
+ }
+ std::basic_string<char> v = val;
+
+ for(std::basic_string<char>::iterator c = v.begin();
+ c != v.end(); c++)
+ {
+ *c = toupper(*c);
+ }
+ return (v == "OFF" || v == "0" || v == "NO" || v == "FALSE" ||
+ v == "N" || v == "NOTFOUND");
+}
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index e542947..2cc9c8e 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -151,9 +151,21 @@ public:
///! Remove a file.
static void RemoveFile(const char* source);
- ///! does a string indicate a true or on value ?
+ /**
+ * does a string indicate a true or on value ? This is not the same
+ * as ifdef.
+ */
static bool IsOn(const char* val);
+ /**
+ * does a string indicate a false or off value ? Note that this is
+ * not the same as !IsOn(...) because there are a number of
+ * ambiguous values such as "/usr/local/bin" a path will result in
+ * IsON and IsOff both returning false. Note that the special path
+ * NOTFOUND will cause IsOff to return true.
+ */
+ static bool IsOff(const char* val);
+
static long int ModifiedTime(const char* filename);
private: