From 067717a56a55d5a35c223170e5bad0427d0d63f3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 14 Apr 2008 17:53:11 -0400 Subject: BUG: Fix compatibility with CMake 2.4 for installation of MACOSX_BUNDLE targets - Add policy CMP0006 to decide whether to use compatibility - OLD behavior is to fall back to RUNTIME rules - NEW behavior is to produce an error --- Source/cmInstallCommand.cxx | 48 ++++++++++++++++++++++++++++++++++++++++++++- Source/cmInstallCommand.h | 1 + Source/cmPolicies.cxx | 18 +++++++++++++++++ Source/cmPolicies.h | 1 + 4 files changed, 67 insertions(+), 1 deletion(-) diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 80dcdfc..03bd159 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -536,7 +536,22 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) bundleGenerator = CreateInstallTargetGenerator(target, bundleArgs, false); } - else + if(!runtimeArgs.GetDestination().empty()) + { + bool failure = false; + if(this->CheckCMP0006(failure)) + { + // For CMake 2.4 compatibility fallback to the RUNTIME + // properties. + bundleGenerator = + CreateInstallTargetGenerator(target, runtimeArgs, false); + } + else if(failure) + { + return false; + } + } + if(!bundleGenerator) { cmOStringStream e; e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE " @@ -1284,3 +1299,34 @@ bool cmInstallCommand::MakeFilesFullPath(const char* modeName, } return true; } + +//---------------------------------------------------------------------------- +bool cmInstallCommand::CheckCMP0006(bool& failure) +{ + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0006)) + { + case cmPolicies::WARN: + { + this->Makefile->IssueMessage( + cmake::AUTHOR_WARNING, + this->Makefile->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0006) + ); + } + case cmPolicies::OLD: + // OLD behavior is to allow compatibility + return true; + case cmPolicies::NEW: + // NEW behavior is to disallow compatibility + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + failure = true; + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + this->Makefile->GetPolicies() + ->GetRequiredPolicyError(cmPolicies::CMP0006) + ); + break; + } + return false; +} diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 4978059..0b7c95f 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -346,6 +346,7 @@ private: bool MakeFilesFullPath(const char* modeName, const std::vector& relFiles, std::vector& absFiles); + bool CheckCMP0006(bool& failure); }; diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index b69a719..4e1b857 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -251,6 +251,24 @@ cmPolicies::cmPolicies() "See documentation of the COMPILE_DEFINITIONS target property for " "limitations of the escaping implementation.", 2,6,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0006, "CMP0006", + "Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.", + "This policy determines whether the install(TARGETS) command must be " + "given a BUNDLE DESTINATION when asked to install a target with the " + "MACOSX_BUNDLE property set. " + "CMake 2.4 and below did not distinguish application bundles from " + "normal executables when installing targets. " + "CMake 2.6 provides a BUNDLE option to the install(TARGETS) command " + "that specifies rules specific to application bundles on the Mac. " + "Projects should use this option when installing a target with the " + "MACOSX_BUNDLE property set.\n" + "The OLD behavior for this policy is to fall back to the RUNTIME " + "DESTINATION if a BUNDLE DESTINATION is not given. " + "The NEW behavior for this policy is to produce an error if a bundle " + "target is installed without a BUNDLE DESTINATION.", + 2,6,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 5adfbfa..fed9d31 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -46,6 +46,7 @@ public: CMP0003, // Linking does not include extra -L paths CMP0004, // Libraries linked may not have leading or trailing whitespace CMP0005, // Definition value escaping + CMP0006, // BUNDLE install rules needed for MACOSX_BUNDLE targets // Always the last entry. Useful mostly to avoid adding a comma // the last policy when adding a new one. -- cgit v0.12