diff options
author | David Cole <david.cole@kitware.com> | 2012-05-24 17:38:03 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-05-24 17:38:03 (GMT) |
commit | db1857e14250f1bbafd69f6bfb78f248101e164d (patch) | |
tree | f1cb30205683f5da3eb5a554cf5367dfcffd6eb7 /Source/CPack | |
parent | 59bdb879e8355537a30aa5a39b72ad54146d2c9b (diff) | |
parent | 4986d525afcddcad6f8610c85cc7d2cf46701ad5 (diff) | |
download | CMake-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')
-rw-r--r-- | Source/CPack/cmCPackDocumentVariables.cxx | 31 | ||||
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 65 | ||||
-rw-r--r-- | Source/CPack/cmCPackGenerator.h | 32 | ||||
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.cxx | 14 | ||||
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.h | 2 |
5 files changed, 143 insertions, 1 deletions
diff --git a/Source/CPack/cmCPackDocumentVariables.cxx b/Source/CPack/cmCPackDocumentVariables.cxx index d2e3802..edbef45 100644 --- a/Source/CPack/cmCPackDocumentVariables.cxx +++ b/Source/CPack/cmCPackDocumentVariables.cxx @@ -77,4 +77,35 @@ void cmCPackDocumentVariables::DefineVariables(cmake* cm) "which is done right before packaging the files." " The script is not called by e.g.: make install.", false, "Variables common to all CPack generators"); + + cm->DefineProperty + ("CPACK_ABSOLUTE_DESTINATION_FILES", cmProperty::VARIABLE, + "List of files which have been installed using " + " an ABSOLUTE DESTINATION path.", + "This variable is a Read-Only variable which is set internally" + " by CPack during installation and before packaging using" + " CMAKE_ABSOLUTE_DESTINATION_FILES defined in cmake_install.cmake " + "scripts. The value can be used within CPack project configuration" + " file and/or CPack<GEN>.cmake file of <GEN> generator.", false, + "Variables common to all CPack generators"); + + cm->DefineProperty + ("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", cmProperty::VARIABLE, + "Ask CPack to warn each time a file with absolute INSTALL" + " DESTINATION is encountered.", + "This variable triggers the definition of " + "CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION when CPack runs" + " cmake_install.cmake scripts.", false, + "Variables common to all CPack generators"); + + cm->DefineProperty + ("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", cmProperty::VARIABLE, + "Ask CPack to error out as soon as a file with absolute INSTALL" + " DESTINATION is encountered.", + "The fatal error is emitted before the installation of " + "the offending file takes place. Some CPack generators, like NSIS," + "enforce this internally. " + "This variable triggers the definition of" + "CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION when CPack runs" + "Variables common to all CPack generators"); } 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; diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 55afb44..ddde8b5 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -190,6 +190,38 @@ protected: bool setDestDir, const char* tempInstallDirectory); /** + * The various level of support of + * CPACK_SET_DESTDIR used by the generator. + */ + enum CPackSetDestdirSupport { + /* the generator works with or without it */ + SETDESTDIR_SUPPORTED, + /* the generator works best if automatically handled */ + SETDESTDIR_INTERNALLY_SUPPORTED, + /* no official support, use at your own risk */ + SETDESTDIR_SHOULD_NOT_BE_USED, + /* officially NOT supported */ + SETDESTDIR_UNSUPPORTED + }; + + /** + * Does the CPack generator support CPACK_SET_DESTDIR? + * The default legacy value is 'SETDESTDIR_SUPPORTED' generator + * have to override it in order change this. + * @return CPackSetDestdirSupport + */ + virtual enum CPackSetDestdirSupport SupportsSetDestdir() const; + + /** + * Does the CPack generator support absolute path + * in INSTALL DESTINATION? + * The default legacy value is 'true' generator + * have to override it in order change this. + * @return true if supported false otherwise + */ + virtual bool SupportsAbsoluteDestination() const; + + /** * Does the CPack generator support component installation?. * Some Generators requires the user to set * CPACK_<GENNAME>_COMPONENT_INSTALL in order to make this diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 0787ef9..481fd2b 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -64,6 +64,7 @@ int cmCPackNSISGenerator::PackageFiles() << std::endl); return false; } + std::string nsisFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); std::string tmpFile = nsisFileName; tmpFile += "/NSISOutput.log"; @@ -631,6 +632,19 @@ bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir, } //---------------------------------------------------------------------- +enum cmCPackGenerator::CPackSetDestdirSupport +cmCPackNSISGenerator::SupportsSetDestdir() const +{ + return cmCPackGenerator::SETDESTDIR_SHOULD_NOT_BE_USED; +} + +//---------------------------------------------------------------------- +bool cmCPackNSISGenerator::SupportsAbsoluteDestination() const +{ + return false; +} + +//---------------------------------------------------------------------- bool cmCPackNSISGenerator::SupportsComponentInstallation() const { return true; diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index 7bccb89..8224854 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -44,6 +44,8 @@ protected: bool GetListOfSubdirectories(const char* dir, std::vector<std::string>& dirs); + enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir() const; + virtual bool SupportsAbsoluteDestination() const; virtual bool SupportsComponentInstallation() const; /// Produce a string that contains the NSIS code to describe a |