ENH: add checking for NOTFOUND
This commit is contained in:
parent
5e661c6639
commit
f58d7df66a
|
@ -56,7 +56,7 @@ bool cmFindFileCommand::InitialPass(std::vector<std::string> const& argsIn)
|
|||
// already, if so use that value and don't look for the program
|
||||
const char* cacheValue
|
||||
= m_Makefile->GetDefinition(define);
|
||||
if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
|
||||
if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -87,8 +87,9 @@ bool cmFindFileCommand::InitialPass(std::vector<std::string> const& argsIn)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
std::string s = args[0] + "-NOTFOUND";
|
||||
m_Makefile->AddCacheDefinition(args[0].c_str(),
|
||||
"NOTFOUND",
|
||||
s.c_str(),
|
||||
helpString.c_str(),
|
||||
cmCacheManager::FILEPATH);
|
||||
return true;
|
||||
|
|
|
@ -72,8 +72,11 @@ public:
|
|||
return
|
||||
"FIND_FILE(NAME file extrapath extrapath ... [DOC docstring])"
|
||||
"Find a file in the system PATH or in any extra paths specified in the command."
|
||||
"A cache entry called NAME is created to store the result. NOTFOUND is the value"
|
||||
" used if the file was not found. If DOC is specified the next argument is the "
|
||||
"A cache entry called NAME is created to store the result. "
|
||||
" NAME-NOTFOUND is the value used if the file was not found. "
|
||||
"As long as NOTFOUND is the value each time cmake will continue to "
|
||||
"try and find the file each time it is run. "
|
||||
" If DOC is specified the next argument is the "
|
||||
"documentation string for the cache entry NAME. Since Executables, "
|
||||
"can have different extensions on different platforms, FIND_PROGRAM,"
|
||||
" should be used instead of FIND_FILE when looking for and executable.";
|
||||
|
|
|
@ -135,8 +135,9 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
std::string s = args[0] + "-NOTFOUND";
|
||||
m_Makefile->AddCacheDefinition(args[0].c_str(),
|
||||
"NOTFOUND",
|
||||
s.c_str(),
|
||||
helpString.c_str(),
|
||||
cmCacheManager::FILEPATH);
|
||||
return true;
|
||||
|
|
|
@ -234,7 +234,7 @@ std::string cmFindPackageCommand::SearchForConfig() const
|
|||
}
|
||||
}
|
||||
|
||||
return "NOTFOUND";
|
||||
return this->Variable + "-NOTFOUND";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -50,7 +50,7 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn)
|
|||
|
||||
const char* cacheValue
|
||||
= m_Makefile->GetDefinition(args[0].c_str());
|
||||
if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
|
||||
if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn)
|
|||
}
|
||||
|
||||
m_Makefile->AddCacheDefinition(args[0].c_str(),
|
||||
"NOTFOUND",
|
||||
(args[0] + "-NOTFOUND").c_str(),
|
||||
helpString.c_str(),
|
||||
cmCacheManager::PATH);
|
||||
return true;
|
||||
|
|
|
@ -55,7 +55,7 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn)
|
|||
// already, if so use that value and don't look for the program
|
||||
const char* cacheValue
|
||||
= m_Makefile->GetDefinition(define);
|
||||
if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
|
||||
if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn)
|
|||
}
|
||||
}
|
||||
m_Makefile->AddCacheDefinition(args[0].c_str(),
|
||||
"NOTFOUND",
|
||||
(args[0] + "-NOTFOUND").c_str(),
|
||||
doc.c_str(),
|
||||
cmCacheManager::FILEPATH);
|
||||
return true;
|
||||
|
|
|
@ -72,8 +72,9 @@ public:
|
|||
return
|
||||
"FIND_PROGRAM(DEFINE_NAME executableName [NAMES name1 name2 name3...] [PATHS path1 path2 path3...] [NO_SYSTEM_PATH] [DOC helpstring]) "
|
||||
"Find the executable in the system PATH or in any extra paths specified in the command."
|
||||
"A cache entry called DEFILE_NAME is created to store the result. NOTFOUND is the value"
|
||||
" used if the program was not found. If DOC is specified the next argument is the "
|
||||
"A cache entry called DEFILE_NAME is created to store the result. DEFILE_NAME-NOTFOUND is the value"
|
||||
" used if the program was not found. CMake will continue to look as long as the value "
|
||||
"is NOTFOUND If DOC is specified the next argument is the "
|
||||
"documentation string for the cache entry NAME."
|
||||
"If NO_SYSTEM_PATH is specified the contents of system PATH is not used";
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ bool cmGetFilenameComponentCommand::InitialPass(std::vector<std::string> const&
|
|||
if(args.size() == 4 && args[3] == "CACHE")
|
||||
{
|
||||
const char* cacheValue = m_Makefile->GetDefinition(args[0].c_str());
|
||||
if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
|
||||
if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -284,12 +284,66 @@ void cmGlobalGenerator::Configure()
|
|||
// now do it
|
||||
this->RecursiveConfigure(lg,0.0f,0.9f);
|
||||
|
||||
std::set<std::string> notFoundMap;
|
||||
// after it is all done do a ConfigureFinalPass
|
||||
cmCacheManager* manager = 0;
|
||||
for (i = 0; i < m_LocalGenerators.size(); ++i)
|
||||
{
|
||||
manager = m_LocalGenerators[i]->GetMakefile()->GetCacheManager();
|
||||
m_LocalGenerators[i]->ConfigureFinalPass();
|
||||
m_CMakeInstance->UpdateProgress("Configuring",
|
||||
cmTargets const& targets = m_LocalGenerators[i]->GetMakefile()->GetTargets();
|
||||
for (cmTargets::const_iterator l = targets.begin();
|
||||
l != targets.end(); l++)
|
||||
{
|
||||
cmTarget::LinkLibraries libs = l->second.GetLinkLibraries();
|
||||
for(cmTarget::LinkLibraries::iterator lib = libs.begin();
|
||||
lib != libs.end(); ++lib)
|
||||
{
|
||||
if(cmSystemTools::IsNOTFOUND(lib->first.c_str()))
|
||||
{
|
||||
std::string not = lib->first.substr(0, lib->first.size()-9);
|
||||
notFoundMap.insert(not);
|
||||
}
|
||||
}
|
||||
std::vector<std::string>& incs =
|
||||
m_LocalGenerators[i]->GetMakefile()->GetIncludeDirectories();
|
||||
|
||||
for( std::vector<std::string>::iterator lib = incs.begin();
|
||||
lib != incs.end(); ++lib)
|
||||
{
|
||||
if(cmSystemTools::IsNOTFOUND(lib->c_str()))
|
||||
{
|
||||
std::string not = lib->substr(0, lib->size()-9);
|
||||
notFoundMap.insert(not);
|
||||
}
|
||||
}
|
||||
m_CMakeInstance->UpdateProgress("Configuring",
|
||||
0.9f+0.1f*(i+1.0f)/m_LocalGenerators.size());
|
||||
}
|
||||
}
|
||||
|
||||
if(notFoundMap.size())
|
||||
{
|
||||
std::string notFoundVars;
|
||||
for(std::set<std::string>::iterator i = notFoundMap.begin();
|
||||
i != notFoundMap.end(); ++i)
|
||||
{
|
||||
notFoundVars += *i;
|
||||
if(manager)
|
||||
{
|
||||
cmCacheManager::CacheIterator it =
|
||||
manager->GetCacheIterator(i->c_str());
|
||||
if(it.GetPropertyAsBool("ADVANCED"))
|
||||
{
|
||||
notFoundVars += " (ADVANCED)";
|
||||
}
|
||||
}
|
||||
notFoundVars += "\n";
|
||||
}
|
||||
cmSystemTools::Error("This project requires some variables to be set,\n"
|
||||
"and cmake can not find them.\n"
|
||||
"Please set the following variables:\n",
|
||||
notFoundVars.c_str());
|
||||
}
|
||||
m_CMakeInstance->UpdateProgress("Configuring done", -1);
|
||||
}
|
||||
|
|
|
@ -222,8 +222,8 @@ std::string cmITKWrapTclCommand::GetCableFromCache() const
|
|||
{ return cable; }
|
||||
|
||||
m_Makefile->AddCacheDefinition("CABLE",
|
||||
"NOTFOUND",
|
||||
"CABLE-NOTFOUND",
|
||||
"Path to CABLE executable.",
|
||||
cmCacheManager::FILEPATH);
|
||||
return "NOTFOUND";
|
||||
return "CABLE-NOTFOUND";
|
||||
}
|
||||
|
|
|
@ -35,11 +35,6 @@ bool cmIncludeDirectoryCommand::InitialPass(std::vector<std::string> const& args
|
|||
|
||||
for(; i != args.end(); ++i)
|
||||
{
|
||||
if ( *i == "NOTFOUND" )
|
||||
{
|
||||
this->SetError("CMake attempted to put directory that was not found to the list of include directories.");
|
||||
return false;
|
||||
}
|
||||
m_Makefile->AddIncludeDirectory((*i).c_str(), before);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -28,11 +28,6 @@ bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& args)
|
|||
for(std::vector<std::string>::const_iterator i = args.begin();
|
||||
i != args.end(); ++i)
|
||||
{
|
||||
if ( *i == "NOTFOUND" )
|
||||
{
|
||||
this->SetError("CMake attempted to put directory that was not found to the list of include directories.");
|
||||
return false;
|
||||
}
|
||||
if (*i == "debug")
|
||||
{
|
||||
++i;
|
||||
|
|
|
@ -385,6 +385,7 @@ void cmMakefile::ConfigureFinalPass()
|
|||
bool oldVersion = (!versionValue || atof(versionValue) < 1.4);
|
||||
// merge libraries
|
||||
|
||||
std::string notFoundVars;
|
||||
for (cmTargets::iterator l = m_Targets.begin();
|
||||
l != m_Targets.end(); l++)
|
||||
{
|
||||
|
|
|
@ -163,8 +163,8 @@ void cmSourceFile::SetProperty(const char* prop, const char* value)
|
|||
}
|
||||
if (!value)
|
||||
{
|
||||
value = "NOTFOUND";
|
||||
}
|
||||
value = "NOTFOUND";
|
||||
}
|
||||
m_Properties[prop] = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -1188,6 +1188,17 @@ bool cmSystemTools::IsOn(const char* val)
|
|||
return (v == "ON" || v == "1" || v == "YES" || v == "TRUE" || v == "Y");
|
||||
}
|
||||
|
||||
bool cmSystemTools::IsNOTFOUND(const char* val)
|
||||
{
|
||||
cmRegularExpression reg("-NOTFOUND$");
|
||||
if(reg.find(val))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return std::string("NOTFOUND") == val;
|
||||
}
|
||||
|
||||
|
||||
bool cmSystemTools::IsOff(const char* val)
|
||||
{
|
||||
if (!val || strlen(val) == 0)
|
||||
|
@ -1202,7 +1213,7 @@ bool cmSystemTools::IsOff(const char* val)
|
|||
*c = toupper(*c);
|
||||
}
|
||||
return (v == "OFF" || v == "0" || v == "NO" || v == "FALSE" ||
|
||||
v == "N" || v == "NOTFOUND" || v == "IGNORE");
|
||||
v == "N" || cmSystemTools::IsNOTFOUND(v.c_str()) || v == "IGNORE");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -213,10 +213,13 @@ public:
|
|||
* 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 or IGNORE will cause IsOff to return true.
|
||||
* NOTFOUND, *-NOTFOUND or IGNORE will cause IsOff to return true.
|
||||
*/
|
||||
static bool IsOff(const char* val);
|
||||
|
||||
///! Return true if value is NOTFOUND or ends in -NOTFOUND.
|
||||
static bool IsNOTFOUND(const char* value);
|
||||
|
||||
///! Find a file in the system PATH, with optional extra paths.
|
||||
static std::string FindFile(const char* name,
|
||||
const std::vector<std::string>& path= std::vector<std::string>());
|
||||
|
|
|
@ -36,12 +36,6 @@ bool cmTargetLinkLibrariesCommand::InitialPass(std::vector<std::string> const& a
|
|||
|
||||
for(++i; i != args.end(); ++i)
|
||||
{
|
||||
if ( *i == "NOTFOUND" )
|
||||
{
|
||||
this->SetError("CMake attempted to put library that was not found to the list of libraries.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*i == "debug")
|
||||
{
|
||||
++i;
|
||||
|
|
Loading…
Reference in New Issue