diff options
author | Taylor Holberton <taylorcholberton@gmail.com> | 2019-01-29 02:06:38 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-01-30 15:47:24 (GMT) |
commit | 198650ae7399cc086c49e58b0a9e03e9efb86235 (patch) | |
tree | a0e27ca7fe9bd39fac7545a299f16141016c4d80 /Source | |
parent | d75fec5a88f81a8c16cdeab46766e92a14d1d3cf (diff) | |
download | CMake-198650ae7399cc086c49e58b0a9e03e9efb86235.zip CMake-198650ae7399cc086c49e58b0a9e03e9efb86235.tar.gz CMake-198650ae7399cc086c49e58b0a9e03e9efb86235.tar.bz2 |
set: warn if CACHE type is not recognized
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmSetCommand.cxx | 11 | ||||
-rw-r--r-- | Source/cmState.cxx | 13 | ||||
-rw-r--r-- | Source/cmState.h | 2 |
3 files changed, 23 insertions, 3 deletions
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 1a2d1c6..b09e3ca 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -4,6 +4,7 @@ #include "cmAlgorithms.h" #include "cmMakefile.h" +#include "cmMessageType.h" #include "cmState.h" #include "cmStateTypes.h" #include "cmSystemTools.h" @@ -112,7 +113,15 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, if (cache) { std::string::size_type cacheStart = args.size() - 3 - (force ? 1 : 0); - type = cmState::StringToCacheEntryType(args[cacheStart + 1].c_str()); + if (!cmState::StringToCacheEntryType(args[cacheStart + 1].c_str(), type)) { + std::string m = "implicitly converting '" + args[cacheStart + 1] + + "' to 'STRING' type."; + this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, m); + // Setting this may not be required, since it's + // initialized as a string. Keeping this here to + // ensure that the type is actually converting to a string. + type = cmStateEnums::STRING; + } docstring = args[cacheStart + 2].c_str(); } diff --git a/Source/cmState.cxx b/Source/cmState.cxx index fdd7b3d..a08e9b8 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -75,14 +75,23 @@ const char* cmState::CacheEntryTypeToString(cmStateEnums::CacheEntryType type) cmStateEnums::CacheEntryType cmState::StringToCacheEntryType(const char* s) { + cmStateEnums::CacheEntryType type = cmStateEnums::STRING; + StringToCacheEntryType(s, type); + return type; +} + +bool cmState::StringToCacheEntryType(const char* s, + cmStateEnums::CacheEntryType& type) +{ int i = 0; while (cmCacheEntryTypes[i]) { if (strcmp(s, cmCacheEntryTypes[i]) == 0) { - return static_cast<cmStateEnums::CacheEntryType>(i); + type = static_cast<cmStateEnums::CacheEntryType>(i); + return true; } ++i; } - return cmStateEnums::STRING; + return false; } bool cmState::IsCacheEntryType(std::string const& key) diff --git a/Source/cmState.h b/Source/cmState.h index e447485..f755f83 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -65,6 +65,8 @@ public: cmStateSnapshot Pop(cmStateSnapshot const& originSnapshot); static cmStateEnums::CacheEntryType StringToCacheEntryType(const char*); + static bool StringToCacheEntryType(const char*, + cmStateEnums::CacheEntryType& type); static const char* CacheEntryTypeToString(cmStateEnums::CacheEntryType); static bool IsCacheEntryType(std::string const& key); |