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
This commit is contained in:
Brad King 2008-04-14 17:53:11 -04:00
parent 3052d2c854
commit 067717a56a
4 changed files with 67 additions and 1 deletions

View File

@ -536,7 +536,22 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> 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;
}

View File

@ -346,6 +346,7 @@ private:
bool MakeFilesFullPath(const char* modeName,
const std::vector<std::string>& relFiles,
std::vector<std::string>& absFiles);
bool CheckCMP0006(bool& failure);
};

View File

@ -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()

View File

@ -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.