mirror of
https://github.com/reactos/CMake.git
synced 2025-02-08 04:48:46 +00:00
set: warn if CACHE type is not recognized
This commit is contained in:
parent
d75fec5a88
commit
198650ae73
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "cmAlgorithms.h"
|
#include "cmAlgorithms.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
|
#include "cmMessageType.h"
|
||||||
#include "cmState.h"
|
#include "cmState.h"
|
||||||
#include "cmStateTypes.h"
|
#include "cmStateTypes.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
@ -112,7 +113,15 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
|
|
||||||
if (cache) {
|
if (cache) {
|
||||||
std::string::size_type cacheStart = args.size() - 3 - (force ? 1 : 0);
|
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();
|
docstring = args[cacheStart + 2].c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,15 +74,24 @@ const char* cmState::CacheEntryTypeToString(cmStateEnums::CacheEntryType type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmStateEnums::CacheEntryType cmState::StringToCacheEntryType(const char* s)
|
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;
|
int i = 0;
|
||||||
while (cmCacheEntryTypes[i]) {
|
while (cmCacheEntryTypes[i]) {
|
||||||
if (strcmp(s, cmCacheEntryTypes[i]) == 0) {
|
if (strcmp(s, cmCacheEntryTypes[i]) == 0) {
|
||||||
return static_cast<cmStateEnums::CacheEntryType>(i);
|
type = static_cast<cmStateEnums::CacheEntryType>(i);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
return cmStateEnums::STRING;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmState::IsCacheEntryType(std::string const& key)
|
bool cmState::IsCacheEntryType(std::string const& key)
|
||||||
|
@ -65,6 +65,8 @@ public:
|
|||||||
cmStateSnapshot Pop(cmStateSnapshot const& originSnapshot);
|
cmStateSnapshot Pop(cmStateSnapshot const& originSnapshot);
|
||||||
|
|
||||||
static cmStateEnums::CacheEntryType StringToCacheEntryType(const char*);
|
static cmStateEnums::CacheEntryType StringToCacheEntryType(const char*);
|
||||||
|
static bool StringToCacheEntryType(const char*,
|
||||||
|
cmStateEnums::CacheEntryType& type);
|
||||||
static const char* CacheEntryTypeToString(cmStateEnums::CacheEntryType);
|
static const char* CacheEntryTypeToString(cmStateEnums::CacheEntryType);
|
||||||
static bool IsCacheEntryType(std::string const& key);
|
static bool IsCacheEntryType(std::string const& key);
|
||||||
|
|
||||||
|
@ -3,3 +3,4 @@ include(RunCMake)
|
|||||||
run_cmake(ParentScope)
|
run_cmake(ParentScope)
|
||||||
run_cmake(ParentPulling)
|
run_cmake(ParentPulling)
|
||||||
run_cmake(ParentPullingRecursive)
|
run_cmake(ParentPullingRecursive)
|
||||||
|
run_cmake(UnknownCacheType)
|
||||||
|
5
Tests/RunCMake/set/UnknownCacheType-stderr.txt
Normal file
5
Tests/RunCMake/set/UnknownCacheType-stderr.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
CMake Warning \(dev\) at UnknownCacheType.cmake:1 \(set\):
|
||||||
|
implicitly converting 'unknown_type_sample' to 'STRING' type.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
||||||
|
This warning is for project developers. Use -Wno-dev to suppress it.
|
1
Tests/RunCMake/set/UnknownCacheType.cmake
Normal file
1
Tests/RunCMake/set/UnknownCacheType.cmake
Normal file
@ -0,0 +1 @@
|
|||||||
|
set (sample_key sample_value CACHE unknown_type_sample "sample doc")
|
Loading…
x
Reference in New Issue
Block a user