From 3901e0408c77c3a072ebd7f3276e2ebdf47bf5eb Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 1 May 2010 14:29:13 +0200 Subject: -improve crosscompiling from Linux to iphone (#10526) Patch by Karol Krizka Alex --- Source/cmFindCommon.cxx | 14 ++++++++++++++ Source/cmFindCommon.h | 2 ++ Source/cmLocalGenerator.cxx | 16 +++++++++------- Source/cmLocalGenerator.h | 2 -- Source/cmMakefileExecutableTargetGenerator.cxx | 2 -- Source/cmMakefileLibraryTargetGenerator.cxx | 2 -- Source/cmMakefileTargetGenerator.cxx | 14 ++++++++------ 7 files changed, 33 insertions(+), 19 deletions(-) diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index f4c0064..f352172 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -423,3 +423,17 @@ void cmFindCommon::AddTrailingSlashes(std::vector& paths) } } } + +//---------------------------------------------------------------------------- +void cmFindCommon::SetMakefile(cmMakefile* makefile) +{ + cmCommand::SetMakefile(makefile); + + // If we are building for Apple (OSX or also iphone), make sure + // that frameworks and bundles are searched first. + if(this->Makefile->IsOn("APPLE")) + { + this->SearchFrameworkFirst = true; + this->SearchAppBundleFirst = true; + } +} diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index 08d2158..2ffbd00 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -61,6 +61,8 @@ protected: PathType pathType); void AddPathInternal(std::string const& in_path, PathType pathType); + void SetMakefile(cmMakefile* makefile); + bool NoDefaultPath; bool NoCMakePath; bool NoCMakeEnvironmentPath; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 851e34f..fd3508e 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -712,9 +712,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) std::string langFlags; this->AddLanguageFlags(langFlags, llang, 0); -#ifdef __APPLE__ this->AddArchitectureFlags(langFlags, &target, llang, 0); -#endif /* __APPLE__ */ vars.LanguageCompileFlags = langFlags.c_str(); cmCustomCommandLines commandLines; @@ -1272,8 +1270,8 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang) #endif for(i = includes.begin(); i != includes.end(); ++i) { -#ifdef __APPLE__ - if(cmSystemTools::IsPathToFramework(i->c_str())) + if(this->Makefile->IsOn("APPLE") + && cmSystemTools::IsPathToFramework(i->c_str())) { std::string frameworkDir = *i; frameworkDir += "/../"; @@ -1288,7 +1286,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang) } continue; } -#endif + std::string include = *i; if(!flagUsed || repeatFlag) { @@ -1766,12 +1764,17 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, //---------------------------------------------------------------------------- -#ifdef __APPLE__ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, cmTarget* target, const char *lang, const char* config) { + // Only add Mac OS X specific flags on Darwin platforms (OSX and iphone): + if(!this->Makefile->IsOn("APPLE")) + { + return; + } + if(this->EmitUniversalBinaryFlags) { std::vector archs; @@ -1828,7 +1831,6 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, } } } -#endif /* __APPLE__ */ //---------------------------------------------------------------------------- diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index becdfff..4c2fc22 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -133,10 +133,8 @@ public: std::vector& GetChildren() { return this->Children; }; -#ifdef __APPLE__ void AddArchitectureFlags(std::string& flags, cmTarget* target, const char *lang, const char* config); -#endif /* __APPLE__ */ void AddLanguageFlags(std::string& flags, const char* lang, const char* config); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index e7c4a7d..93c981a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -229,10 +229,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Add language feature flags. this->AddFeatureFlags(flags, linkLanguage); -#ifdef __APPLE__ this->LocalGenerator->AddArchitectureFlags(flags, this->Target, linkLanguage, this->ConfigName); -#endif /* __APPLE__ */ // Add target-specific linker flags. this->LocalGenerator->AppendFlags diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index f351174..d3e6e11 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -682,10 +682,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string langFlags; this->AddFeatureFlags(langFlags, linkLanguage); -#ifdef __APPLE__ this->LocalGenerator->AddArchitectureFlags(langFlags, this->Target, linkLanguage, this->ConfigName); -#endif /* __APPLE__ */ // remove any language flags that might not work with the // particular os diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index dd45950..124d2bd 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -294,10 +294,8 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() // Add language feature flags. this->AddFeatureFlags(flags, lang); -#ifdef __APPLE__ this->LocalGenerator->AddArchitectureFlags(flags, this->Target, lang, this->ConfigName); -#endif /* __APPLE__ */ // Fortran-specific flags computed for this target. if(*l == "Fortran") @@ -1439,11 +1437,15 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output, //---------------------------------------------------------------------------- std::string cmMakefileTargetGenerator::GetFrameworkFlags() { -#ifndef __APPLE__ - return std::string(); -#else - std::set emitted; + if(!this->Makefile->IsOn("APPLE")) + { + return std::string(); + } + + std::set emitted; +#ifdef __APPLE__ /* don't insert this when crosscompiling e.g. to iphone */ emitted.insert("/System/Library/Frameworks"); +#else std::vector includes; this->LocalGenerator->GetIncludeDirectories(includes); std::vector::iterator i; -- cgit v0.12