From 552842d11f845ad53e4f34be549aa4007737564b Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 27 Dec 2005 15:33:47 -0500 Subject: ENH: make sure -F is not duplicated --- Source/cmFindFileCommand.cxx | 13 ++++++++----- Source/cmFindFileCommand.h | 3 ++- Source/cmLocalUnixMakefileGenerator3.cxx | 28 ++++++++++++++++++++++++---- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/Source/cmFindFileCommand.cxx b/Source/cmFindFileCommand.cxx index 82c0ff4..b1972f2 100644 --- a/Source/cmFindFileCommand.cxx +++ b/Source/cmFindFileCommand.cxx @@ -70,6 +70,8 @@ bool cmFindFileCommand::InitialPass(std::vector const& argsIn) cmSystemTools::GlobDirs(args[j].c_str(), path); } + cmSystemTools::GetPath(path, "CMAKE_LIBRARY_PATH"); + // add the standard path cmSystemTools::GetPath(path); for(unsigned int k=0; k < path.size(); k++) @@ -88,7 +90,7 @@ bool cmFindFileCommand::InitialPass(std::vector const& argsIn) } } #if defined (__APPLE__) - cmStdString fpath = this->FindHeaderInFrameworks(args[0].c_str(), args[1].c_str()); + cmStdString fpath = this->FindHeaderInFrameworks(path, args[0].c_str(), args[1].c_str()); if(fpath.size()) { m_Makefile->AddCacheDefinition(args[0].c_str(), @@ -106,8 +108,10 @@ bool cmFindFileCommand::InitialPass(std::vector const& argsIn) return true; } -cmStdString cmFindFileCommand::FindHeaderInFrameworks(const char* defineVar, - const char* file) +cmStdString cmFindFileCommand::FindHeaderInFrameworks( + std::vector path, + const char* defineVar, + const char* file) { #ifndef __APPLE__ return cmStdString(""); @@ -130,12 +134,11 @@ cmStdString cmFindFileCommand::FindHeaderInFrameworks(const char* defineVar, frameWorkName = ""; } } - std::vector 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::iterator i = path.begin(); + for( std::vector::iterator i = path.begin(); i != path.end(); ++i) { if(frameWorkName.size()) diff --git a/Source/cmFindFileCommand.h b/Source/cmFindFileCommand.h index 1e44be5..e5fb661 100644 --- a/Source/cmFindFileCommand.h +++ b/Source/cmFindFileCommand.h @@ -79,7 +79,8 @@ 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); + cmStdString FindHeaderInFrameworks( std::vector path, + const char* var, const char* file); cmTypeMacro(cmFindFileCommand, cmCommand); }; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 1c24934..922c94c 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -513,14 +513,34 @@ cmLocalUnixMakefileGenerator3 #ifndef __APPLE__ return std::string(); #else + std::set emitted; + std::vector includes; + this->GetIncludeDirectories(includes); + std::vector::iterator i; + // check all include directories for frameworks as this + // will already have added a -F for the framework + for(i = includes.begin(); i != includes.end(); ++i) + { + if(cmSystemTools::IsPathToFramework(i->c_str())) + { + std::string frameworkDir = *i; + frameworkDir += "/../"; + frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str()); + emitted.insert(frameworkDir); + } + } + std::string flags; std::vector& frameworks = target.GetFrameworks(); - for(std::vector::iterator i = frameworks.begin(); + for(i = frameworks.begin(); i != frameworks.end(); ++i) { - flags += "-F"; - flags += this->ConvertToOutputForExisting(i->c_str()); - flags += " "; + if(emitted.insert(*i).second) + { + flags += "-F"; + flags += this->ConvertToOutputForExisting(i->c_str()); + flags += " "; + } } return flags; #endif -- cgit v0.12