summaryrefslogtreecommitdiffstats
path: root/Source
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
parentc04cbcac70535788ca79ce7cf621f3baaf2abcbb (diff)
downloadCMake-82bb6fae0d127b2ffcaae5eaa8a5365093cfac5c.zip
CMake-82bb6fae0d127b2ffcaae5eaa8a5365093cfac5c.tar.gz
CMake-82bb6fae0d127b2ffcaae5eaa8a5365093cfac5c.tar.bz2
ENH: add framework support to FIND_FILE
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFindFileCommand.cxx75
-rw-r--r--Source/cmFindFileCommand.h2
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx40
-rw-r--r--Source/cmLocalGenerator.cxx14
4 files changed, 127 insertions, 4 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
+}
diff --git a/Source/cmFindFileCommand.h b/Source/cmFindFileCommand.h
index 12d1f75..1e44be5 100644
--- a/Source/cmFindFileCommand.h
+++ b/Source/cmFindFileCommand.h
@@ -79,7 +79,7 @@ public:
"different extensions on different platforms, FIND_PROGRAM "
"should be used instead of FIND_FILE when looking for them.";
}
-
+ cmStdString FindHeaderInFrameworks(const char* var, const char* file);
cmTypeMacro(cmFindFileCommand, cmCommand);
};
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 43c47f8..fc37952 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1173,11 +1173,45 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
std::vector<std::string>& includes =
m_CurrentMakefile->GetIncludeDirectories();
std::vector<std::string>::iterator i = includes.begin();
+ std::string fdirs;
+ std::set<cmStdString> emitted;
for(;i != includes.end(); ++i)
{
- std::string incpath =
- this->XCodeEscapePath(i->c_str());
- dirs += incpath + " ";
+ if(cmSystemTools::IsPathToFramework(i->c_str()))
+ {
+ std::string frameworkDir = *i;
+ frameworkDir += "/../";
+ frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
+ if(emitted.insert(frameworkDir).second)
+ {
+ fdirs += this->XCodeEscapePath(frameworkDir.c_str());
+ fdirs += " ";
+ }
+ }
+ else
+ {
+ std::string incpath =
+ this->XCodeEscapePath(i->c_str());
+ dirs += incpath + " ";
+ }
+ }
+ std::vector<std::string>& frameworks = target.GetFrameworks();
+ if(frameworks.size())
+ {
+ for(std::vector<std::string>::iterator i = frameworks.begin();
+ i != frameworks.end(); ++i)
+ {
+ if(emitted.insert(*i).second)
+ {
+ fdirs += this->XCodeEscapePath(i->c_str());
+ fdirs += " ";
+ }
+ }
+ }
+ if(fdirs.size())
+ {
+ buildSettings->AddAttribute("FRAMEWORK_SEARCH_PATHS",
+ this->CreateString(fdirs.c_str()));
}
if(dirs.size())
{
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index b0066b0..214ab6b 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1055,8 +1055,22 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang)
repeatFlag = false;
}
bool flagUsed = false;
+ std::set<cmStdString> emitted;
for(i = includes.begin(); i != includes.end(); ++i)
{
+#ifdef __APPLE__
+ if(cmSystemTools::IsPathToFramework(i->c_str()))
+ {
+ std::string frameworkDir = *i;
+ frameworkDir += "/../";
+ frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
+ if(emitted.insert(frameworkDir).second)
+ {
+ includeFlags << "-F" << this->ConvertToOutputForExisting(frameworkDir.c_str()) << " ";
+ }
+ continue;
+ }
+#endif
std::string include = *i;
if(!flagUsed || repeatFlag)
{