diff options
author | Brad King <brad.king@kitware.com> | 2014-01-02 19:23:09 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-01-02 19:23:09 (GMT) |
commit | 0d63bdd2d9690cfdb43671af7465704675a68733 (patch) | |
tree | 17370b9ce679a48de0ed5f3baf7cddd27ed08e01 /Source | |
parent | c0ea0604a0dcd1d580e9b6a976aae0069cab2986 (diff) | |
parent | d25ad482e978cbf5e4fcfa8b1dcc342ba93dcda0 (diff) | |
download | CMake-0d63bdd2d9690cfdb43671af7465704675a68733.zip CMake-0d63bdd2d9690cfdb43671af7465704675a68733.tar.gz CMake-0d63bdd2d9690cfdb43671af7465704675a68733.tar.bz2 |
Merge topic 'rpath-default'
d25ad48 OS X: Add CMP0042 to enable MACOSX_RPATH by default
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 28 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 5 | ||||
-rw-r--r-- | Source/cmLocalXCodeGenerator.cxx | 29 | ||||
-rw-r--r-- | Source/cmLocalXCodeGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmPolicies.cxx | 5 | ||||
-rw-r--r-- | Source/cmPolicies.h | 1 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 53 | ||||
-rw-r--r-- | Source/cmTarget.h | 8 |
9 files changed, 125 insertions, 8 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index f3bdddd..6986965 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1752,7 +1752,7 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, // @loader_path or full paths. if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { - if(!target->HasMacOSXRpath(this->Config)) + if(!target->HasMacOSXRpathInstallNameDir(this->Config)) { return; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 227a948..3b858af 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1045,6 +1045,12 @@ cmGlobalGenerator::GetExportedTargetsFile(const std::string &filename) const return it == this->BuildExportSets.end() ? 0 : it->second; } +//---------------------------------------------------------------------------- +void cmGlobalGenerator::AddCMP0042WarnTarget(const std::string& target) +{ + this->CMP0042WarnTargets.insert(target); +} + bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() { // If the property is not enabled then okay. @@ -1072,6 +1078,9 @@ void cmGlobalGenerator::Generate() // Start with an empty vector: this->FilesReplacedDuringGenerate.clear(); + // clear targets to issue warning CMP0042 for + this->CMP0042WarnTargets.clear(); + // Check whether this generator is allowed to run. if(!this->CheckALLOW_DUPLICATE_CUSTOM_TARGETS()) { @@ -1203,6 +1212,25 @@ void cmGlobalGenerator::Generate() this->ExtraGenerator->Generate(); } + if(!this->CMP0042WarnTargets.empty()) + { + cmOStringStream w; + w << + (this->GetCMakeInstance()->GetPolicies()-> + GetPolicyWarning(cmPolicies::CMP0042)) << "\n"; + w << "MACOSX_RPATH is not specified for" + " the following targets:\n"; + for(std::set<std::string>::iterator + iter = this->CMP0042WarnTargets.begin(); + iter != this->CMP0042WarnTargets.end(); + ++iter) + { + w << " " << *iter << "\n"; + } + this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str(), + cmListFileBacktrace()); + } + this->CMakeInstance->UpdateProgress("Generating done", -1); } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index f60d24d..049b0e6 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -315,6 +315,8 @@ public: bool GenerateImportFile(const std::string &file); cmExportBuildFileGenerator* GetExportedTargetsFile(const std::string &filename) const; + void AddCMP0042WarnTarget(const std::string& target); + protected: typedef std::vector<cmLocalGenerator*> GeneratorVector; // for a project collect all its targets by following depend @@ -449,6 +451,9 @@ private: // Set of binary directories on disk. std::set<cmStdString> BinaryDirectories; + + // track targets to issue CMP0042 warning for. + std::set<std::string> CMP0042WarnTargets; }; #endif diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index 7c5f69d..a9a27b9 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -12,6 +12,7 @@ #include "cmLocalXCodeGenerator.h" #include "cmGlobalXCodeGenerator.h" #include "cmSourceFile.h" +#include "cmMakefile.h" //---------------------------------------------------------------------------- cmLocalXCodeGenerator::cmLocalXCodeGenerator() @@ -42,3 +43,31 @@ void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags, static_cast<cmGlobalXCodeGenerator*>(this->GlobalGenerator); gg->AppendFlag(flags, rawFlag); } + +//---------------------------------------------------------------------------- +void cmLocalXCodeGenerator::Generate() +{ + cmLocalGenerator::Generate(); + + cmTargets& targets = this->Makefile->GetTargets(); + for(cmTargets::iterator iter = targets.begin(); + iter != targets.end(); ++iter) + { + cmTarget* t = &iter->second; + t->HasMacOSXRpathInstallNameDir(NULL); + } +} + +//---------------------------------------------------------------------------- +void cmLocalXCodeGenerator::GenerateInstallRules() +{ + cmLocalGenerator::GenerateInstallRules(); + + cmTargets& targets = this->Makefile->GetTargets(); + for(cmTargets::iterator iter = targets.begin(); + iter != targets.end(); ++iter) + { + cmTarget* t = &iter->second; + t->HasMacOSXRpathInstallNameDir(NULL); + } +} diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index d97a41c..edd2f5b 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -29,6 +29,8 @@ public: virtual ~cmLocalXCodeGenerator(); virtual std::string GetTargetDirectory(cmTarget const& target) const; virtual void AppendFlagEscape(std::string& flags, const char* rawFlag); + virtual void Generate(); + virtual void GenerateInstallRules(); private: }; diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 0b3018e..987c663 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -311,6 +311,11 @@ cmPolicies::cmPolicies() CMP0041, "CMP0041", "Error on relative include with generator expression.", 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0042, "CMP0042", + "MACOSX_RPATH is enabled by default.", + 3,0,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 245ec4b..66eaf87 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -95,6 +95,7 @@ public: CMP0040, ///< The target in the TARGET signature of /// add_custom_command() must exist. CMP0041, ///< Error on relative include with generator expression + CMP0042, ///< Enable MACOSX_RPATH by default /** \brief Always the last entry. * diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a0177fb..9faf0d9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3186,13 +3186,17 @@ std::string cmTarget::GetSOName(const char* config) const } //---------------------------------------------------------------------------- -bool cmTarget::HasMacOSXRpath(const char* config) const +bool cmTarget::HasMacOSXRpathInstallNameDir(const char* config) const { bool install_name_is_rpath = false; - bool macosx_rpath = this->GetPropertyAsBool("MACOSX_RPATH"); + bool macosx_rpath = false; if(!this->IsImportedTarget) { + if(this->GetType() != cmTarget::SHARED_LIBRARY) + { + return false; + } const char* install_name = this->GetProperty("INSTALL_NAME_DIR"); bool use_install_name = this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"); @@ -3205,6 +3209,10 @@ bool cmTarget::HasMacOSXRpath(const char* config) const { return false; } + if(!install_name_is_rpath) + { + macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); + } } else { @@ -3259,6 +3267,37 @@ bool cmTarget::HasMacOSXRpath(const char* config) const } //---------------------------------------------------------------------------- +bool cmTarget::MacOSXRpathInstallNameDirDefault() const +{ + // we can't do rpaths when unsupported + if(!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG")) + { + return false; + } + + const char* macosx_rpath_str = this->GetProperty("MACOSX_RPATH"); + if(macosx_rpath_str) + { + return this->GetPropertyAsBool("MACOSX_RPATH"); + } + + cmPolicies::PolicyStatus cmp0042 = this->GetPolicyStatusCMP0042(); + + if(cmp0042 == cmPolicies::WARN) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> + AddCMP0042WarnTarget(this->GetName()); + } + + if(cmp0042 == cmPolicies::NEW) + { + return true; + } + + return false; +} + +//---------------------------------------------------------------------------- bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) const { if(this->IsImported() && this->GetType() == cmTarget::SHARED_LIBRARY) @@ -3847,7 +3886,8 @@ std::string cmTarget::GetInstallNameDirForBuildTree(const char* config) const !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) { std::string dir; - if(this->GetPropertyAsBool("MACOSX_RPATH")) + bool macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); + if(macosx_rpath) { dir = "@rpath"; } @@ -3881,9 +3921,12 @@ std::string cmTarget::GetInstallNameDirForInstallTree() const dir += "/"; } } - if(!install_name_dir && this->GetPropertyAsBool("MACOSX_RPATH")) + if(!install_name_dir) { - dir = "@rpath/"; + if(this->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath/"; + } } return dir; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index bf4a8ef..e026c59 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -26,7 +26,8 @@ F(CMP0020) \ F(CMP0021) \ F(CMP0022) \ - F(CMP0041) + F(CMP0041) \ + F(CMP0042) class cmake; class cmMakefile; @@ -382,7 +383,10 @@ public: std::string GetSOName(const char* config) const; /** Whether this library has \@rpath and platform supports it. */ - bool HasMacOSXRpath(const char* config) const; + bool HasMacOSXRpathInstallNameDir(const char* config) const; + + /** Whether this library defaults to \@rpath. */ + bool MacOSXRpathInstallNameDirDefault() const; /** Test for special case of a third-party shared library that has no soname at all. */ |