From f58d7df66a4cbfd171ae27eb0beaf12cf5355c08 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 31 Jan 2003 13:50:42 -0500 Subject: ENH: add checking for NOTFOUND --- Source/cmFindFileCommand.cxx | 5 +-- Source/cmFindFileCommand.h | 7 ++-- Source/cmFindLibraryCommand.cxx | 3 +- Source/cmFindPackageCommand.cxx | 2 +- Source/cmFindPathCommand.cxx | 4 +-- Source/cmFindProgramCommand.cxx | 4 +-- Source/cmFindProgramCommand.h | 5 +-- Source/cmGetFilenameComponentCommand.cxx | 2 +- Source/cmGlobalGenerator.cxx | 56 +++++++++++++++++++++++++++++++- Source/cmITKWrapTclCommand.cxx | 4 +-- Source/cmIncludeDirectoryCommand.cxx | 5 --- Source/cmLinkLibrariesCommand.cxx | 5 --- Source/cmMakefile.cxx | 1 + Source/cmSourceFile.cxx | 4 +-- Source/cmSystemTools.cxx | 13 +++++++- Source/cmSystemTools.h | 5 ++- Source/cmTargetLinkLibrariesCommand.cxx | 6 ---- 17 files changed, 95 insertions(+), 36 deletions(-) diff --git a/Source/cmFindFileCommand.cxx b/Source/cmFindFileCommand.cxx index 54f4d27..71712d8 100644 --- a/Source/cmFindFileCommand.cxx +++ b/Source/cmFindFileCommand.cxx @@ -56,7 +56,7 @@ bool cmFindFileCommand::InitialPass(std::vector 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 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; diff --git a/Source/cmFindFileCommand.h b/Source/cmFindFileCommand.h index 18abfa2..ebf7144 100644 --- a/Source/cmFindFileCommand.h +++ b/Source/cmFindFileCommand.h @@ -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."; diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 70c97a4..c1ebe87 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -135,8 +135,9 @@ bool cmFindLibraryCommand::InitialPass(std::vector 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; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 4f0681f..5dd2eb3 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -234,7 +234,7 @@ std::string cmFindPackageCommand::SearchForConfig() const } } - return "NOTFOUND"; + return this->Variable + "-NOTFOUND"; } //---------------------------------------------------------------------------- diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 6261187..3385582 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -50,7 +50,7 @@ bool cmFindPathCommand::InitialPass(std::vector 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 const& argsIn) } m_Makefile->AddCacheDefinition(args[0].c_str(), - "NOTFOUND", + (args[0] + "-NOTFOUND").c_str(), helpString.c_str(), cmCacheManager::PATH); return true; diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index 84f7dab..6b94d71 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -55,7 +55,7 @@ bool cmFindProgramCommand::InitialPass(std::vector 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 const& argsIn) } } m_Makefile->AddCacheDefinition(args[0].c_str(), - "NOTFOUND", + (args[0] + "-NOTFOUND").c_str(), doc.c_str(), cmCacheManager::FILEPATH); return true; diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h index 7deff44..3c39cb8 100644 --- a/Source/cmFindProgramCommand.h +++ b/Source/cmFindProgramCommand.h @@ -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"; } diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index 2fded7e..55f24a3 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -31,7 +31,7 @@ bool cmGetFilenameComponentCommand::InitialPass(std::vector 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; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index e5991e4..c758438 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -284,12 +284,66 @@ void cmGlobalGenerator::Configure() // now do it this->RecursiveConfigure(lg,0.0f,0.9f); + std::set 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& incs = + m_LocalGenerators[i]->GetMakefile()->GetIncludeDirectories(); + + for( std::vector::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::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); } diff --git a/Source/cmITKWrapTclCommand.cxx b/Source/cmITKWrapTclCommand.cxx index c7a2cc8..86791a9 100644 --- a/Source/cmITKWrapTclCommand.cxx +++ b/Source/cmITKWrapTclCommand.cxx @@ -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"; } diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index 0e43736..48bede4 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -35,11 +35,6 @@ bool cmIncludeDirectoryCommand::InitialPass(std::vector 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; diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx index c2eade7..d45f246 100644 --- a/Source/cmLinkLibrariesCommand.cxx +++ b/Source/cmLinkLibrariesCommand.cxx @@ -28,11 +28,6 @@ bool cmLinkLibrariesCommand::InitialPass(std::vector const& args) for(std::vector::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; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index a567f83..ec994f5 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -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++) { diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index fa220e7..abc623d 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -163,8 +163,8 @@ void cmSourceFile::SetProperty(const char* prop, const char* value) } if (!value) { - value = "NOTFOUND"; - } + value = "NOTFOUND"; + } m_Properties[prop] = value; } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 4b71bf4..95f4d59 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -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"); } diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 9c3d2ae..c977ced 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -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& path= std::vector()); diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index ab3663a..70ba944 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -36,12 +36,6 @@ bool cmTargetLinkLibrariesCommand::InitialPass(std::vector 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; -- cgit v0.12