summaryrefslogtreecommitdiffstats
path: root/Source/cmFindLibraryCommand.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2001-05-09 18:53:32 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2001-05-09 18:53:32 (GMT)
commitf07ee5b8177e9e08f290e3acdff6c31d6b694bf6 (patch)
tree7d08c74e73010dfe3bd735b592fd64f09de5ab9c /Source/cmFindLibraryCommand.cxx
parent1dc7ae38ead50498b9e813d7c6e96f9d850b45ea (diff)
downloadCMake-f07ee5b8177e9e08f290e3acdff6c31d6b694bf6.zip
CMake-f07ee5b8177e9e08f290e3acdff6c31d6b694bf6.tar.gz
CMake-f07ee5b8177e9e08f290e3acdff6c31d6b694bf6.tar.bz2
ENH: change find library and find program to look for more than one name
Diffstat (limited to 'Source/cmFindLibraryCommand.cxx')
-rw-r--r--Source/cmFindLibraryCommand.cxx113
1 files changed, 57 insertions, 56 deletions
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index 6d2df8f..e60d4ed 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -57,78 +57,79 @@ bool cmFindLibraryCommand::Invoke(std::vector<std::string>& args)
= cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
{
- m_Makefile->AddDefinition(args[0].c_str(), cacheValue);
- cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
- cacheValue,
- helpString.c_str(),
- cmCacheManager::PATH);
+ m_Makefile->AddDefinition(args[0].c_str(), cacheValue);
+ cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
+ cacheValue,
+ helpString.c_str(),
+ cmCacheManager::FILEPATH);
return true;
}
-
std::vector<std::string> path;
- // add any user specified paths
- for (unsigned int j = 2; j < args.size(); j++)
- {
- // expand variables
- std::string exp = args[j];
- m_Makefile->ExpandVariablesInString(exp);
- path.push_back(exp);
- }
-
- // add the standard path
- cmSystemTools::GetPath(path);
- unsigned int k;
- for(k=0; k < path.size(); k++)
+ std::vector<std::string> names;
+ bool namePathStyle = false;
+ bool foundName = false;
+ bool foundPath = false;
+ bool doingNames = true;
+ for (unsigned int j = 1; j < args.size(); ++j)
{
- std::string tryPath = path[k];
- tryPath += "/";
- std::string testF;
- testF = tryPath + args[1] + ".lib";
- if(cmSystemTools::FileExists(testF.c_str()))
+ if(args[j] == "NAMES")
{
- m_Makefile->AddDefinition(args[0].c_str(), path[k].c_str());
- cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
- path[k].c_str(),
- helpString.c_str(),
- cmCacheManager::PATH);
- return true;
+ doingNames = true;
+ foundName = true;
}
- testF = tryPath + "lib" + args[1] + ".so";
- if(cmSystemTools::FileExists(testF.c_str()))
+ else if (args[j] == "PATHS")
{
- m_Makefile->AddDefinition(args[0].c_str(), path[k].c_str());
- cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
- path[k].c_str(),
- helpString.c_str(),
- cmCacheManager::PATH);
- return true;
+ doingNames = false;
+ foundPath = true;
+ }
+ else
+ {
+ m_Makefile->ExpandVariablesInString(args[j]);
+ if(doingNames)
+ {
+ names.push_back(args[j]);
+ }
+ else
+ {
+ path.push_back(args[j]);
+ }
}
- testF = tryPath + "lib" + args[1] + ".a";
- if(cmSystemTools::FileExists(testF.c_str()))
+ }
+ // old style name path1 path2 path3
+ if(!foundPath && !foundName)
+ {
+ names.clear();
+ path.clear();
+ names.push_back(args[1]);
+ // add any user specified paths
+ for (unsigned int j = 2; j < args.size(); j++)
{
- m_Makefile->AddDefinition(args[0].c_str(), path[k].c_str());
+ // expand variables
+ std::string exp = args[j];
+ m_Makefile->ExpandVariablesInString(exp);
+ path.push_back(exp);
+ }
+ }
+ std::string library;
+ for(std::vector<std::string>::iterator i = names.begin();
+ i != names.end() ; ++i)
+ {
+ library = cmSystemTools::FindLibrary(i->c_str(),
+ path);
+ if(library != "")
+ {
+ m_Makefile->AddDefinition(args[0].c_str(), library.c_str());
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
- path[k].c_str(),
+ library.c_str(),
helpString.c_str(),
- cmCacheManager::PATH);
+ cmCacheManager::FILEPATH);
return true;
- }
- testF = tryPath + "lib" + args[1] + ".sl";
- if(cmSystemTools::FileExists(testF.c_str()))
- {
- m_Makefile->AddDefinition(args[0].c_str(), path[k].c_str());
- cmCacheManager::GetInstance()->
- AddCacheEntry(args[0].c_str(),
- path[k].c_str(),
- helpString.c_str(),
- cmCacheManager::PATH);
- return true;
- }
+ }
}
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
"NOTFOUND",
helpString.c_str(),
- cmCacheManager::PATH);
+ cmCacheManager::FILEPATH);
return true;
}