summaryrefslogtreecommitdiffstats
path: root/Source/cmFindFileCommand.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2005-12-27 19:56:56 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2005-12-27 19:56:56 (GMT)
commit82bb6fae0d127b2ffcaae5eaa8a5365093cfac5c (patch)
tree6ed31cc2a14443808e4b04510bea76e22c204a13 /Source/cmFindFileCommand.cxx
parentc04cbcac70535788ca79ce7cf621f3baaf2abcbb (diff)
downloadCMake-82bb6fae0d127b2ffcaae5eaa8a5365093cfac5c.zip
CMake-82bb6fae0d127b2ffcaae5eaa8a5365093cfac5c.tar.gz
CMake-82bb6fae0d127b2ffcaae5eaa8a5365093cfac5c.tar.bz2
ENH: add framework support to FIND_FILE
Diffstat (limited to 'Source/cmFindFileCommand.cxx')
-rw-r--r--Source/cmFindFileCommand.cxx75
1 files changed, 75 insertions, 0 deletions
diff --git a/Source/cmFindFileCommand.cxx b/Source/cmFindFileCommand.cxx
index d4f7221..82c0ff4 100644
--- a/Source/cmFindFileCommand.cxx
+++ b/Source/cmFindFileCommand.cxx
@@ -16,6 +16,7 @@
=========================================================================*/
#include "cmFindFileCommand.h"
#include "cmCacheManager.h"
+#include "cmGlob.h"
#include <stdlib.h>
@@ -86,6 +87,17 @@ bool cmFindFileCommand::InitialPass(std::vector<std::string> const& argsIn)
return true;
}
}
+#if defined (__APPLE__)
+ cmStdString fpath = this->FindHeaderInFrameworks(args[0].c_str(), args[1].c_str());
+ if(fpath.size())
+ {
+ m_Makefile->AddCacheDefinition(args[0].c_str(),
+ fpath.c_str(),
+ helpString.c_str(),
+ cmCacheManager::FILEPATH);
+ return true;
+ }
+#endif
std::string s = args[0] + "-NOTFOUND";
m_Makefile->AddCacheDefinition(args[0].c_str(),
s.c_str(),
@@ -94,3 +106,66 @@ bool cmFindFileCommand::InitialPass(std::vector<std::string> const& argsIn)
return true;
}
+cmStdString cmFindFileCommand::FindHeaderInFrameworks(const char* defineVar,
+ const char* file)
+{
+#ifndef __APPLE__
+ return cmStdString("");
+#else
+ cmStdString fileName = file;
+ cmStdString frameWorkName;
+ cmStdString::size_type pos = fileName.find("/");
+ std::cerr << "ff " << fileName << " " << pos << "\n";
+ if(pos != fileName.npos)
+ {
+ // remove the name from the slash;
+ fileName = fileName.substr(pos+1);
+ frameWorkName = file;
+ frameWorkName = frameWorkName.substr(0, frameWorkName.size()-fileName.size()-1);
+ // if the framework has a path in it then just use the filename
+ std::cerr << fileName << " " << frameWorkName << "\n";
+ if(frameWorkName.find("/") != frameWorkName.npos)
+ {
+ fileName = file;
+ frameWorkName = "";
+ }
+ }
+ std::vector<cmStdString> path;
+ path.push_back("~/Library/Frameworks");
+ path.push_back("/Library/Frameworks");
+ path.push_back("/System/Library/Frameworks");
+ path.push_back("/Network/Library/Frameworks");
+ for( std::vector<cmStdString>::iterator i = path.begin();
+ i != path.end(); ++i)
+ {
+ if(frameWorkName.size())
+ {
+ std::string fpath = *i;
+ fpath += "/";
+ fpath += frameWorkName;
+ fpath += ".framework";
+ std::string path = fpath;
+ path += "/Headers/";
+ path += fileName;
+ std::cerr << "try " << path << "\n";
+ if(cmSystemTools::FileExists(path.c_str()))
+ {
+ return fpath;
+ }
+ }
+ cmStdString glob = *i;
+ glob += "/*/Headers/";
+ glob += file;
+ cmGlob globIt;
+ globIt.FindFiles(glob);
+ std::vector<std::string> files = globIt.GetFiles();
+ if(files.size())
+ {
+ cmStdString fheader = cmSystemTools::CollapseFullPath(files[0].c_str());
+ fheader = cmSystemTools::GetFilenamePath(fheader);
+ return fheader;
+ }
+ }
+ return cmStdString("");
+#endif
+}