summaryrefslogtreecommitdiffstats
path: root/Source/CPack/cmCPackGenerator.cxx
diff options
context:
space:
mode:
authorEric NOULARD <eric.noulard@gmail.com>2012-05-14 21:29:42 (GMT)
committerEric NOULARD <eric.noulard@gmail.com>2012-05-14 21:29:42 (GMT)
commit47f0dbd70b83ccb5e314abee5feded2ed50a23fb (patch)
treeb3821ced0886a295429aa3e014e4f7abf087a5aa /Source/CPack/cmCPackGenerator.cxx
parent6ba055bacdce1cdf7a74008b980440027f275d94 (diff)
downloadCMake-47f0dbd70b83ccb5e314abee5feded2ed50a23fb.zip
CMake-47f0dbd70b83ccb5e314abee5feded2ed50a23fb.tar.gz
CMake-47f0dbd70b83ccb5e314abee5feded2ed50a23fb.tar.bz2
CPack add necessary check to detect/warns/error on ABSOLUTE DESTINATION
The [usually] wrong usage of absolute DESTINATION in INSTALL rules keeps popping-up on the ML. We shall have some way to: 1) easily detect it. 2) forbids this for some CPack generator like NSIS In fact it should certainly be forbidden for *any* generators when used on Windows but we may implements that on top of the current patch. The patch ask the task to the generated cmake_install.cmake scripts. Those scripts are a little bit more complicated with that but iff there are absolute DESTINATION. This cost nothing if relative DESTINATION are used. Two new vars are introduced (and documented to handle that): CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION and CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
Diffstat (limited to 'Source/CPack/cmCPackGenerator.cxx')
-rw-r--r--Source/CPack/cmCPackGenerator.cxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index bf65271..ca790c0 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -849,8 +849,27 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
filesBefore = glB.GetFiles();
std::sort(filesBefore.begin(),filesBefore.end());
}
+
+ // If CPack was asked to warn on ABSOLUTE INSTALL DESTINATION
+ // then forward request to cmake_install.cmake script
+ if (this->GetOption("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION"))
+ {
+ mf->AddDefinition("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION",
+ "1");
+ }
+ // If current CPack generator does support
+ // ABSOLUTE INSTALL DESTINATION or CPack has been asked for
+ // then ask cmake_install.cmake script to error out
+ // as soon as it occurs (before installing file)
+ if (!SupportsAbsoluteDestination() ||
+ this->GetOption("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION"))
+ {
+ mf->AddDefinition("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION",
+ "1");
+ }
// do installation
int res = mf->ReadListFile(0, installFile.c_str());
+
// Now rebuild the list of files after installation
// of the current component (if we are in component install)
if (componentInstall)
@@ -1461,6 +1480,12 @@ cmCPackGenerator::SupportsSetDestdir() const
}
//----------------------------------------------------------------------
+bool cmCPackGenerator::SupportsAbsoluteDestination() const
+{
+ return true;
+}
+
+//----------------------------------------------------------------------
bool cmCPackGenerator::SupportsComponentInstallation() const
{
return false;