summaryrefslogtreecommitdiffstats
path: root/Source/CPack/cmCPackGenerator.cxx
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-05-24 17:38:03 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-05-24 17:38:03 (GMT)
commitdb1857e14250f1bbafd69f6bfb78f248101e164d (patch)
treef1cb30205683f5da3eb5a554cf5367dfcffd6eb7 /Source/CPack/cmCPackGenerator.cxx
parent59bdb879e8355537a30aa5a39b72ad54146d2c9b (diff)
parent4986d525afcddcad6f8610c85cc7d2cf46701ad5 (diff)
downloadCMake-db1857e14250f1bbafd69f6bfb78f248101e164d.zip
CMake-db1857e14250f1bbafd69f6bfb78f248101e164d.tar.gz
CMake-db1857e14250f1bbafd69f6bfb78f248101e164d.tar.bz2
Merge topic 'CPackNSIS-warnDESTDIRandABSOLUTE'
4986d52 Use CPACK_xxx and CMAKE_xxx in a consistent way. f90223c Fix KWStyle warning 47f0dbd CPack add necessary check to detect/warns/error on ABSOLUTE DESTINATION 6ba055b CPack add easy possibility to warn about CPACK_SET_DESTDIR
Diffstat (limited to 'Source/CPack/cmCPackGenerator.cxx')
-rw-r--r--Source/CPack/cmCPackGenerator.cxx65
1 files changed, 64 insertions, 1 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index de8f1e0..0177653 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -62,10 +62,31 @@ void cmCPackGenerator::DisplayVerboseOutput(const char* msg,
//----------------------------------------------------------------------
int cmCPackGenerator::PrepareNames()
-{
+{
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Create temp directory." << std::endl);
+ // checks CPACK_SET_DESTDIR support
+ if (IsOn("CPACK_SET_DESTDIR"))
+ {
+ if (SETDESTDIR_UNSUPPORTED==SupportsSetDestdir())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_SET_DESTDIR is set to ON but the '"
+ << Name << "' generator does NOT support it."
+ << std::endl);
+ return 0;
+ }
+ else if (SETDESTDIR_SHOULD_NOT_BE_USED==SupportsSetDestdir())
+ {
+ cmCPackLogger(cmCPackLog::LOG_WARNING,
+ "CPACK_SET_DESTDIR is set to ON but it is "
+ << "usually a bad idea to do that with '"
+ << Name << "' generator. Use at your own risk."
+ << std::endl);
+ }
+ }
+
std::string tempDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
tempDirectory += "/_CPack_Packages/";
const char* toplevelTag = this->GetOption("CPACK_TOPLEVEL_TAG");
@@ -831,8 +852,35 @@ 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("CMAKE_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("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION",
+ "1");
+ }
// do installation
int res = mf->ReadListFile(0, installFile.c_str());
+ // forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES
+ // to CPack (may be used by generators like CPack RPM or DEB)
+ // in order to transparently handle ABSOLUTE PATH
+ if (mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"))
+ {
+ mf->AddDefinition("CPACK_ABSOLUTE_DESTINATION_FILES",
+ mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"));
+ }
+
// Now rebuild the list of files after installation
// of the current component (if we are in component install)
if (componentInstall)
@@ -956,6 +1004,8 @@ int cmCPackGenerator::DoPackage()
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"Create package using " << this->Name.c_str() << std::endl);
+ // Prepare CPack internal name and check
+ // values for many CPACK_xxx vars
if ( !this->PrepareNames() )
{
return 0;
@@ -1434,6 +1484,19 @@ std::string cmCPackGenerator::GetComponentPackageFileName(
}
//----------------------------------------------------------------------
+enum cmCPackGenerator::CPackSetDestdirSupport
+cmCPackGenerator::SupportsSetDestdir() const
+{
+ return cmCPackGenerator::SETDESTDIR_SUPPORTED;
+}
+
+//----------------------------------------------------------------------
+bool cmCPackGenerator::SupportsAbsoluteDestination() const
+{
+ return true;
+}
+
+//----------------------------------------------------------------------
bool cmCPackGenerator::SupportsComponentInstallation() const
{
return false;