diff options
-rw-r--r-- | Modules/CMakeGenericSystem.cmake | 8 | ||||
-rw-r--r-- | Modules/ExternalProject.cmake | 8 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.h | 11 | ||||
-rw-r--r-- | Source/CPack/cmCPackDocumentVariables.cxx | 31 | ||||
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 65 | ||||
-rw-r--r-- | Source/CPack/cmCPackGenerator.h | 42 | ||||
-rw-r--r-- | Source/CPack/cmCPackGeneratorFactory.cxx | 106 | ||||
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.cxx | 14 | ||||
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.h | 2 | ||||
-rw-r--r-- | Source/CPack/cmCPackRPMGenerator.h | 11 | ||||
-rw-r--r-- | Source/cmDocumentVariables.cxx | 40 | ||||
-rw-r--r-- | Source/cmInstallCommand.cxx | 77 | ||||
-rw-r--r-- | Source/cmInstallCommand.h | 4 | ||||
-rw-r--r-- | Source/cmInstallCommandArguments.cxx | 19 | ||||
-rw-r--r-- | Source/cmInstallCommandArguments.h | 11 | ||||
-rw-r--r-- | Source/cmInstallFilesCommand.cxx | 32 | ||||
-rw-r--r-- | Source/cmInstallGenerator.cxx | 12 | ||||
-rw-r--r-- | Source/cmInstallProgramsCommand.cxx | 26 | ||||
-rw-r--r-- | Source/cmInstallTargetsCommand.cxx | 3 | ||||
-rw-r--r-- | Tests/CMakeLists.txt | 48 |
21 files changed, 446 insertions, 126 deletions
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index 127588f..c733969 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -12,7 +12,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") # -pic +SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") # -pic SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") # -rpath @@ -42,7 +42,7 @@ SET (CMAKE_SKIP_RPATH "NO" CACHE BOOL SET (CMAKE_SKIP_INSTALL_RPATH "NO" CACHE BOOL "If set, runtime paths are not added when installing shared libraries, but are added when building.") -SET(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.") +SET(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.") IF(CMAKE_GENERATOR MATCHES "Makefiles") SET(CMAKE_COLOR_MAKEFILE ON CACHE BOOL @@ -170,6 +170,10 @@ ELSE(CMAKE_HOST_UNIX) SET(CMAKE_GENERIC_PROGRAM_FILES) ENDIF(CMAKE_HOST_UNIX) +# Set a variable which will be used as component name in install() commands +# where no COMPONENT has been given: +SET(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "Unspecified") + MARK_AS_ADVANCED( CMAKE_SKIP_RPATH CMAKE_SKIP_INSTALL_RPATH diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 0353e45..a0a9aea 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -712,8 +712,12 @@ function(_ep_get_build_command name step cmd_var) endif() else() # if(cfg_cmd_id STREQUAL "configure") # Non-CMake project. Guess "make" and "make install" and "make test". - # But use "$(MAKE)" to get recursive parallel make. - set(cmd "$(MAKE)") + if("${CMAKE_GENERATOR}" MATCHES "Makefiles") + # Try to get the parallel arguments + set(cmd "$(MAKE)") + else() + set(cmd "make") + endif() if(step STREQUAL "INSTALL") set(args install) endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c2c577e..b02b3a8 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 8) SET(CMake_VERSION_PATCH 8) -SET(CMake_VERSION_TWEAK 20120522) +SET(CMake_VERSION_TWEAK 20120524) #SET(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackDebGenerator.h b/Source/CPack/cmCPackDebGenerator.h index f536c47..7f2352f 100644 --- a/Source/CPack/cmCPackDebGenerator.h +++ b/Source/CPack/cmCPackDebGenerator.h @@ -31,6 +31,17 @@ public: cmCPackDebGenerator(); virtual ~cmCPackDebGenerator(); + static bool CanGenerate() + { +#ifdef __APPLE__ + // on MacOS enable CPackDeb iff dpkg is found + return cmSystemTools::FindProgram("dpkg") != "" ? true : false; +#else + // legacy behavior on other systems + return true; +#endif + } + protected: virtual int InitializeInternal(); /** 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..6748512 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -63,6 +63,16 @@ public: cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE; } /** + * Returns true if the generator may work on this system. + * Rational: + * Some CPack generator may run on some host and may not on others + * (with the same system) because some tools are missing. If the tool + * is missing then CPack won't activate (in the CPackGeneratorFactory) + * this particular generator. + */ + static bool CanGenerate() { return true; } + + /** * Do the actual whole package processing. * Subclass may redefine it but its usually enough * to redefine @ref PackageFiles, because in fact @@ -190,6 +200,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/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index a04b403..37ff460 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -31,7 +31,7 @@ # include "cmCPackCygwinSourceGenerator.h" #endif -#if !defined(_WIN32) && !defined(__APPLE__) \ +#if !defined(_WIN32) \ && !defined(__QNXNTO__) && !defined(__BEOS__) # include "cmCPackDebGenerator.h" # include "cmCPackRPMGenerator.h" @@ -40,44 +40,90 @@ #include "cmCPackLog.h" +#if defined(__BORLANDC__) +# pragma warn -8008 /* condition is always true */ +#endif + //---------------------------------------------------------------------- cmCPackGeneratorFactory::cmCPackGeneratorFactory() { - this->RegisterGenerator("TGZ", "Tar GZip compression", - cmCPackTGZGenerator::CreateGenerator); - this->RegisterGenerator("STGZ", "Self extracting Tar GZip compression", - cmCPackSTGZGenerator::CreateGenerator); - this->RegisterGenerator("NSIS", "Null Soft Installer", - cmCPackNSISGenerator::CreateGenerator); + if (cmCPackTGZGenerator::CanGenerate()) + { + this->RegisterGenerator("TGZ", "Tar GZip compression", + cmCPackTGZGenerator::CreateGenerator); + } + if (cmCPackSTGZGenerator::CanGenerate()) + { + this->RegisterGenerator("STGZ", "Self extracting Tar GZip compression", + cmCPackSTGZGenerator::CreateGenerator); + } + if (cmCPackNSISGenerator::CanGenerate()) + { + this->RegisterGenerator("NSIS", "Null Soft Installer", + cmCPackNSISGenerator::CreateGenerator); + } #ifdef __CYGWIN__ - this->RegisterGenerator("CygwinBinary", "Cygwin Binary Installer", - cmCPackCygwinBinaryGenerator::CreateGenerator); - this->RegisterGenerator("CygwinSource", "Cygwin Source Installer", - cmCPackCygwinSourceGenerator::CreateGenerator); + if (cmCPackCygwinBinaryGenerator::CanGenerate()) + { + this->RegisterGenerator("CygwinBinary", "Cygwin Binary Installer", + cmCPackCygwinBinaryGenerator::CreateGenerator); + } + if (cmCPackCygwinSourceGenerator::CanGenerate()) + { + this->RegisterGenerator("CygwinSource", "Cygwin Source Installer", + cmCPackCygwinSourceGenerator::CreateGenerator); + } #endif - this->RegisterGenerator("ZIP", "ZIP file format", - cmCPackZIPGenerator::CreateGenerator); - this->RegisterGenerator("TBZ2", "Tar BZip2 compression", - cmCPackTarBZip2Generator::CreateGenerator); - this->RegisterGenerator("TZ", "Tar Compress compression", - cmCPackTarCompressGenerator::CreateGenerator); + if (cmCPackZIPGenerator::CanGenerate()) + { + this->RegisterGenerator("ZIP", "ZIP file format", + cmCPackZIPGenerator::CreateGenerator); + } + if (cmCPackTarBZip2Generator::CanGenerate()) + { + this->RegisterGenerator("TBZ2", "Tar BZip2 compression", + cmCPackTarBZip2Generator::CreateGenerator); + } + if (cmCPackTarCompressGenerator::CanGenerate()) + { + this->RegisterGenerator("TZ", "Tar Compress compression", + cmCPackTarCompressGenerator::CreateGenerator); + } #ifdef __APPLE__ - this->RegisterGenerator("DragNDrop", "Mac OSX Drag And Drop", - cmCPackDragNDropGenerator::CreateGenerator); - this->RegisterGenerator("Bundle", "Mac OSX bundle", - cmCPackBundleGenerator::CreateGenerator); - this->RegisterGenerator("PackageMaker", "Mac OSX Package Maker installer", - cmCPackPackageMakerGenerator::CreateGenerator); - this->RegisterGenerator("OSXX11", "Mac OSX X11 bundle", - cmCPackOSXX11Generator::CreateGenerator); + if (cmCPackDragNDropGenerator::CanGenerate()) + { + this->RegisterGenerator("DragNDrop", "Mac OSX Drag And Drop", + cmCPackDragNDropGenerator::CreateGenerator); + } + if (cmCPackBundleGenerator::CanGenerate()) + { + this->RegisterGenerator("Bundle", "Mac OSX bundle", + cmCPackBundleGenerator::CreateGenerator); + } + if (cmCPackPackageMakerGenerator::CanGenerate()) + { + this->RegisterGenerator("PackageMaker", "Mac OSX Package Maker installer", + cmCPackPackageMakerGenerator::CreateGenerator); + } + if (cmCPackOSXX11Generator::CanGenerate()) + { + this->RegisterGenerator("OSXX11", "Mac OSX X11 bundle", + cmCPackOSXX11Generator::CreateGenerator); + } #endif -#if !defined(_WIN32) && !defined(__APPLE__) \ +#if !defined(_WIN32) \ && !defined(__QNXNTO__) && !defined(__BEOS__) - this->RegisterGenerator("DEB", "Debian packages", - cmCPackDebGenerator::CreateGenerator); - this->RegisterGenerator("RPM", "RPM packages", - cmCPackRPMGenerator::CreateGenerator); + if (cmCPackDebGenerator::CanGenerate()) + { + this->RegisterGenerator("DEB", "Debian packages", + cmCPackDebGenerator::CreateGenerator); + } + if (cmCPackRPMGenerator::CanGenerate()) + { + this->RegisterGenerator("RPM", "RPM packages", + cmCPackRPMGenerator::CreateGenerator); + } #endif } 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 diff --git a/Source/CPack/cmCPackRPMGenerator.h b/Source/CPack/cmCPackRPMGenerator.h index 4883a0d..eec8204 100644 --- a/Source/CPack/cmCPackRPMGenerator.h +++ b/Source/CPack/cmCPackRPMGenerator.h @@ -35,6 +35,17 @@ public: cmCPackRPMGenerator(); virtual ~cmCPackRPMGenerator(); + static bool CanGenerate() + { +#ifdef __APPLE__ + // on MacOS enable CPackRPM iff rpmbuild is found + return cmSystemTools::FindProgram("rpmbuild") != "" ? true : false; +#else + // legacy behavior on other systems + return true; +#endif + } + protected: virtual int InitializeInternal(); virtual int PackageFiles(); diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 897e516..9e33d75 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -523,6 +523,16 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables That Change Behavior"); cm->DefineProperty + ("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME", cmProperty::VARIABLE, + "Default component used in install() commands.", + "If an install() command is used without the COMPONENT argument, " + "these files will be grouped into a default component. The name of this " + "default install component will be taken from this variable. " + "It defaults to \"Unspecified\". ", + false, + "Variables That Change Behavior"); + + cm->DefineProperty ("CMAKE_FIND_LIBRARY_PREFIXES", cmProperty::VARIABLE, "Prefixes to prepend when looking for libraries.", "This specifies what prefixes to add to library names when " @@ -833,6 +843,36 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Default is ON.",false, "Variables That Change Behavior"); + cm->DefineProperty + ("CMAKE_ABSOLUTE_DESTINATION_FILES", cmProperty::VARIABLE, + "List of files which have been installed using " + " an ABSOLUTE DESTINATION path.", + "This variable is defined by CMake-generated cmake_install.cmake " + "scripts." + " It can be used (read-only) by program or script that source those" + " install scripts. This is used by some CPack generators (e.g. RPM).", + false, + "Variables That Change Behavior"); + + cm->DefineProperty + ("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", cmProperty::VARIABLE, + "Ask cmake_install.cmake script to warn each time a file with " + "absolute INSTALL DESTINATION is encountered.", + "This variable is used by CMake-generated cmake_install.cmake" + " scripts. If ones set this variable to ON while running the" + " script, it may get warning messages from the script.", false, + "Variables That Change Behavior"); + + cm->DefineProperty + ("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", cmProperty::VARIABLE, + "Ask cmake_install.cmake script 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." + " This variable is used by CMake-generated cmake_install.cmake" + " scripts. If ones set this variable to ON while running the" + " script, it may get fatal error messages from the script.",false, + "Variables That Change Behavior"); // Variables defined by CMake that describe the system diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index c656487..4016734 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -23,25 +23,25 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target, const cmInstallCommandArguments& args, bool impLib, bool forceOpt = false) { - return new cmInstallTargetGenerator(target, args.GetDestination().c_str(), - impLib, args.GetPermissions().c_str(), + return new cmInstallTargetGenerator(target, args.GetDestination().c_str(), + impLib, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), args.GetOptional() || forceOpt); } static cmInstallFilesGenerator* CreateInstallFilesGenerator( - const std::vector<std::string>& absFiles, + const std::vector<std::string>& absFiles, const cmInstallCommandArguments& args, bool programs) { - return new cmInstallFilesGenerator(absFiles, args.GetDestination().c_str(), - programs, args.GetPermissions().c_str(), + return new cmInstallFilesGenerator(absFiles, args.GetDestination().c_str(), + programs, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), args.GetRename().c_str(), args.GetOptional()); } // cmInstallCommand -bool cmInstallCommand::InitialPass(std::vector<std::string> const& args, +bool cmInstallCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { // Allow calling with no arguments so that arguments may be built up @@ -55,6 +55,13 @@ bool cmInstallCommand::InitialPass(std::vector<std::string> const& args, this->Makefile->GetLocalGenerator() ->GetGlobalGenerator()->EnableInstallTarget(); + this->DefaultComponentName = this->Makefile->GetSafeDefinition( + "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); + if (this->DefaultComponentName.empty()) + { + this->DefaultComponentName = "Unspecified"; + } + // Switch among the command modes. if(args[0] == "SCRIPT") { @@ -95,7 +102,7 @@ bool cmInstallCommand::InitialPass(std::vector<std::string> const& args, //---------------------------------------------------------------------------- bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) { - std::string component("Unspecified"); + std::string component = this->DefaultComponentName; int componentCount = 0; bool doing_script = false; bool doing_code = false; @@ -190,7 +197,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) /*struct InstallPart { - InstallPart(cmCommandArgumentsHelper* helper, const char* key, + InstallPart(cmCommandArgumentsHelper* helper, const char* key, cmCommandArgumentGroup* group); cmCAStringVector argVector; cmInstallCommandArguments args; @@ -222,7 +229,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // ARCHIVE, RUNTIME etc. (see above) // These generic args also contain the targets and the export stuff std::vector<std::string> unknownArgs; - cmInstallCommandArguments genericArgs; + cmInstallCommandArguments genericArgs(this->DefaultComponentName); cmCAStringVector targetList(&genericArgs.Parser, "TARGETS"); cmCAString exports(&genericArgs.Parser,"EXPORT", &genericArgs.ArgumentGroup); targetList.Follows(0); @@ -230,16 +237,16 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) genericArgs.Parse(&genericArgVector.GetVector(), &unknownArgs); bool success = genericArgs.Finalize(); - cmInstallCommandArguments archiveArgs; - cmInstallCommandArguments libraryArgs; - cmInstallCommandArguments runtimeArgs; - cmInstallCommandArguments frameworkArgs; - cmInstallCommandArguments bundleArgs; - cmInstallCommandArguments privateHeaderArgs; - cmInstallCommandArguments publicHeaderArgs; - cmInstallCommandArguments resourceArgs; + cmInstallCommandArguments archiveArgs(this->DefaultComponentName); + cmInstallCommandArguments libraryArgs(this->DefaultComponentName); + cmInstallCommandArguments runtimeArgs(this->DefaultComponentName); + cmInstallCommandArguments frameworkArgs(this->DefaultComponentName); + cmInstallCommandArguments bundleArgs(this->DefaultComponentName); + cmInstallCommandArguments privateHeaderArgs(this->DefaultComponentName); + cmInstallCommandArguments publicHeaderArgs(this->DefaultComponentName); + cmInstallCommandArguments resourceArgs(this->DefaultComponentName); - // now parse the args for specific parts of the target (e.g. LIBRARY, + // now parse the args for specific parts of the target (e.g. LIBRARY, // RUNTIME, ARCHIVE etc. archiveArgs.Parse (&archiveArgVector.GetVector(), &unknownArgs); libraryArgs.Parse (&libraryArgVector.GetVector(), &unknownArgs); @@ -345,7 +352,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")); - for(std::vector<std::string>::const_iterator + for(std::vector<std::string>::const_iterator targetIt=targetList.GetVector().begin(); targetIt!=targetList.GetVector().end(); ++targetIt) @@ -422,7 +429,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) case cmTarget::SHARED_LIBRARY: { // Shared libraries are handled differently on DLL and non-DLL - // platforms. All windows platforms are DLL platforms including + // platforms. All windows platforms are DLL platforms including // cygwin. Currently no other platform is a DLL platform. if(dll_platform) { @@ -436,13 +443,13 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) if(!archiveArgs.GetDestination().empty()) { // The import library uses the ARCHIVE properties. - archiveGenerator = CreateInstallTargetGenerator(target, + archiveGenerator = CreateInstallTargetGenerator(target, archiveArgs, true); } if(!runtimeArgs.GetDestination().empty()) { // The DLL uses the RUNTIME properties. - runtimeGenerator = CreateInstallTargetGenerator(target, + runtimeGenerator = CreateInstallTargetGenerator(target, runtimeArgs, false); } if ((archiveGenerator==0) && (runtimeGenerator==0)) @@ -467,7 +474,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // Use the FRAMEWORK properties. if (!frameworkArgs.GetDestination().empty()) { - frameworkGenerator = CreateInstallTargetGenerator(target, + frameworkGenerator = CreateInstallTargetGenerator(target, frameworkArgs, false); } else @@ -484,7 +491,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // The shared library uses the LIBRARY properties. if (!libraryArgs.GetDestination().empty()) { - libraryGenerator = CreateInstallTargetGenerator(target, + libraryGenerator = CreateInstallTargetGenerator(target, libraryArgs, false); libraryGenerator->SetNamelinkMode(namelinkMode); namelinkOnly = @@ -507,7 +514,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // Static libraries use ARCHIVE properties. if (!archiveArgs.GetDestination().empty()) { - archiveGenerator = CreateInstallTargetGenerator(target, archiveArgs, + archiveGenerator = CreateInstallTargetGenerator(target, archiveArgs, false); } else @@ -525,7 +532,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // Modules use LIBRARY properties. if (!libraryArgs.GetDestination().empty()) { - libraryGenerator = CreateInstallTargetGenerator(target, libraryArgs, + libraryGenerator = CreateInstallTargetGenerator(target, libraryArgs, false); libraryGenerator->SetNamelinkMode(namelinkMode); namelinkOnly = @@ -548,7 +555,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // Application bundles use the BUNDLE properties. if (!bundleArgs.GetDestination().empty()) { - bundleGenerator = CreateInstallTargetGenerator(target, bundleArgs, + bundleGenerator = CreateInstallTargetGenerator(target, bundleArgs, false); } else if(!runtimeArgs.GetDestination().empty()) @@ -580,7 +587,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // Executables use the RUNTIME properties. if (!runtimeArgs.GetDestination().empty()) { - runtimeGenerator = CreateInstallTargetGenerator(target, + runtimeGenerator = CreateInstallTargetGenerator(target, runtimeArgs, false); } else @@ -600,7 +607,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) target.IsExecutableWithExports()) { // The import library uses the ARCHIVE properties. - archiveGenerator = CreateInstallTargetGenerator(target, + archiveGenerator = CreateInstallTargetGenerator(target, archiveArgs, true, true); } } @@ -710,7 +717,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) installsRuntime = installsRuntime || runtimeGenerator != 0; installsFramework = installsFramework || frameworkGenerator != 0; installsBundle = installsBundle || bundleGenerator != 0; - installsPrivateHeader = installsPrivateHeader + installsPrivateHeader = installsPrivateHeader || privateHeaderGenerator != 0; installsPublicHeader = installsPublicHeader || publicHeaderGenerator != 0; installsResource = installsResource || resourceGenerator; @@ -729,7 +736,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) if(!exports.GetString().empty() && !namelinkOnly) { this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddTargetToExports(exports.GetCString(), &target, + ->AddTargetToExports(exports.GetCString(), &target, archiveGenerator, runtimeGenerator, libraryGenerator, frameworkGenerator, bundleGenerator, publicHeaderGenerator); @@ -788,7 +795,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) { // This is the FILES mode. bool programs = (args[0] == "PROGRAMS"); - cmInstallCommandArguments ica; + cmInstallCommandArguments ica(this->DefaultComponentName); cmCAStringVector files(&ica.Parser, programs ? "PROGRAMS" : "FILES"); files.Follows(0); ica.ArgumentGroup.Follows(&files); @@ -803,7 +810,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) this->SetError(e.str().c_str()); return false; } - + // Check if there is something to do. if(files.GetVector().empty()) { @@ -865,7 +872,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) std::string permissions_file; std::string permissions_dir; std::vector<std::string> configurations; - std::string component = "Unspecified"; + std::string component = this->DefaultComponentName; std::string literal_args; for(unsigned int i=1; i < args.size(); ++i) { @@ -1179,7 +1186,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) { // This is the EXPORT mode. - cmInstallCommandArguments ica; + cmInstallCommandArguments ica(this->DefaultComponentName); cmCAString exp(&ica.Parser, "EXPORT"); cmCAString name_space(&ica.Parser, "NAMESPACE", &ica.ArgumentGroup); cmCAString filename(&ica.Parser, "FILE", &ica.ArgumentGroup); diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 3403c38..bf9fd9e 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -337,10 +337,12 @@ private: bool HandleFilesMode(std::vector<std::string> const& args); bool HandleDirectoryMode(std::vector<std::string> const& args); bool HandleExportMode(std::vector<std::string> const& args); - bool MakeFilesFullPath(const char* modeName, + bool MakeFilesFullPath(const char* modeName, const std::vector<std::string>& relFiles, std::vector<std::string>& absFiles); bool CheckCMP0006(bool& failure); + + std::string DefaultComponentName; }; diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 13ef8ed..0ba21c7 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -23,7 +23,8 @@ const char* cmInstallCommandArguments::PermissionsTable[] = const std::string cmInstallCommandArguments::EmptyString; -cmInstallCommandArguments::cmInstallCommandArguments() +cmInstallCommandArguments::cmInstallCommandArguments( + const std::string& defaultComponent) :Parser() ,ArgumentGroup() ,Destination (&Parser, "DESTINATION" , &ArgumentGroup) @@ -35,7 +36,9 @@ cmInstallCommandArguments::cmInstallCommandArguments() ,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup) ,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup) ,GenericArguments(0) -{} +{ + this->Component.SetDefaultString(defaultComponent.c_str()); +} const std::string& cmInstallCommandArguments::GetDestination() const { @@ -130,7 +133,7 @@ bool cmInstallCommandArguments::GetNamelinkSkip() const return false; } -const std::vector<std::string>& +const std::vector<std::string>& cmInstallCommandArguments::GetConfigurations() const { if (!this->Configurations.GetVector().empty()) @@ -156,7 +159,7 @@ bool cmInstallCommandArguments::Finalize() return true; } -void cmInstallCommandArguments::Parse(const std::vector<std::string>* args, +void cmInstallCommandArguments::Parse(const std::vector<std::string>* args, std::vector<std::string>* unconsumedArgs) { this->Parser.Parse(args, unconsumedArgs); @@ -166,9 +169,9 @@ void cmInstallCommandArguments::Parse(const std::vector<std::string>* args, bool cmInstallCommandArguments::CheckPermissions() { this->PermissionsString = ""; - for(std::vector<std::string>::const_iterator - permIt = this->Permissions.GetVector().begin(); - permIt != this->Permissions.GetVector().end(); + for(std::vector<std::string>::const_iterator + permIt = this->Permissions.GetVector().begin(); + permIt != this->Permissions.GetVector().end(); ++permIt) { if (!this->CheckPermissions(*permIt, this->PermissionsString)) @@ -183,7 +186,7 @@ bool cmInstallCommandArguments::CheckPermissions( const std::string& onePermission, std::string& permissions) { // Check the permission against the table. - for(const char** valid = cmInstallCommandArguments::PermissionsTable; + for(const char** valid = cmInstallCommandArguments::PermissionsTable; *valid; ++valid) { if(onePermission == *valid) diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h index 16033ce..321454a 100644 --- a/Source/cmInstallCommandArguments.h +++ b/Source/cmInstallCommandArguments.h @@ -19,10 +19,10 @@ class cmInstallCommandArguments { public: - cmInstallCommandArguments(); - void SetGenericArguments(cmInstallCommandArguments* args) + cmInstallCommandArguments(const std::string& defaultComponent); + void SetGenericArguments(cmInstallCommandArguments* args) {this->GenericArguments = args;} - void Parse(const std::vector<std::string>* args, + void Parse(const std::vector<std::string>* args, std::vector<std::string>* unconsumedArgs); // Compute destination path.and check permissions @@ -37,14 +37,15 @@ class cmInstallCommandArguments bool GetNamelinkOnly() const; bool GetNamelinkSkip() const; - // once HandleDirectoryMode() is also switched to using + // once HandleDirectoryMode() is also switched to using // cmInstallCommandArguments then these two functions can become non-static // private member functions without arguments - static bool CheckPermissions(const std::string& onePerm, + static bool CheckPermissions(const std::string& onePerm, std::string& perm); cmCommandArgumentsHelper Parser; cmCommandArgumentGroup ArgumentGroup; private: + cmInstallCommandArguments(); // disabled cmCAString Destination; cmCAString Component; cmCAString Rename; diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 0ec3030..cc62c4b 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -34,7 +34,7 @@ bool cmInstallFilesCommand if((args.size() > 1) && (args[1] == "FILES")) { - this->IsFilesForm = true; + this->IsFilesForm = true; for(std::vector<std::string>::const_iterator s = args.begin()+2; s != args.end(); ++s) { @@ -53,45 +53,46 @@ bool cmInstallFilesCommand this->FinalArgs.push_back(*s); } } - + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent("Unspecified"); + ->AddInstallComponent(this->Makefile->GetSafeDefinition( + "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); return true; } -void cmInstallFilesCommand::FinalPass() +void cmInstallFilesCommand::FinalPass() { // No final pass for "FILES" form of arguments. if(this->IsFilesForm) { return; } - + std::string testf; std::string ext = this->FinalArgs[0]; - + // two different options if (this->FinalArgs.size() > 1) { // now put the files into the list std::vector<std::string>::iterator s = this->FinalArgs.begin(); ++s; - // for each argument, get the files + // for each argument, get the files for (;s != this->FinalArgs.end(); ++s) { // replace any variables std::string temps = *s; if (cmSystemTools::GetFilenamePath(temps).size() > 0) { - testf = cmSystemTools::GetFilenamePath(temps) + "/" + + testf = cmSystemTools::GetFilenamePath(temps) + "/" + cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext; } else { testf = cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext; } - + // add to the result this->Files.push_back(this->FindInstallSource(testf.c_str())); } @@ -102,9 +103,9 @@ void cmInstallFilesCommand::FinalPass() std::string regex = this->FinalArgs[0].c_str(); cmSystemTools::Glob(this->Makefile->GetCurrentDirectory(), regex.c_str(), files); - + std::vector<std::string>::iterator s = files.begin(); - // for each argument, get the files + // for each argument, get the files for (;s != files.end(); ++s) { this->Files.push_back(this->FindInstallSource(s->c_str())); @@ -128,13 +129,14 @@ void cmInstallFilesCommand::CreateInstallGenerator() const // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; - const char* no_component = "Unspecified"; + std::string no_component = this->Makefile->GetSafeDefinition( + "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector<std::string> no_configurations; this->Makefile->AddInstallGenerator( new cmInstallFilesGenerator(this->Files, destination.c_str(), false, no_permissions, no_configurations, - no_component, no_rename)); + no_component.c_str(), no_rename)); } @@ -151,7 +153,7 @@ std::string cmInstallFilesCommand::FindInstallSource(const char* name) const // This is a full path. return name; } - + // This is a relative path. std::string tb = this->Makefile->GetCurrentOutputDirectory(); tb += "/"; @@ -159,7 +161,7 @@ std::string cmInstallFilesCommand::FindInstallSource(const char* name) const std::string ts = this->Makefile->GetCurrentDirectory(); ts += "/"; ts += name; - + if(cmSystemTools::FileExists(tb.c_str())) { // The file exists in the binary tree. Use it. diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 807168e..3be2c2b 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -60,7 +60,7 @@ void cmInstallGenerator std::string dest = this->GetInstallDestination(); if (cmSystemTools::FileIsFullPath(dest.c_str())) { - os << "list(APPEND CPACK_ABSOLUTE_DESTINATION_FILES\n"; + os << "list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES\n"; os << indent << " \""; for(std::vector<std::string>::const_iterator fi = files.begin(); fi != files.end(); ++fi) @@ -80,6 +80,16 @@ void cmInstallGenerator } } os << "\")\n"; + os << indent << "IF (CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)\n"; + os << indent << indent << "message(WARNING \"ABSOLUTE path INSTALL " + << "DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n"; + os << indent << "ENDIF (CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)\n"; + + os << indent << "IF (CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)\n"; + os << indent << indent << "message(FATAL_ERROR \"ABSOLUTE path INSTALL " + << "DESTINATION forbidden (by caller): " + << "${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n"; + os << indent << "ENDIF (CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)\n"; } os << "FILE(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str(); if(optional) diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 7e6c9ce..3a0a322 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -31,26 +31,27 @@ bool cmInstallProgramsCommand for (++s;s != args.end(); ++s) { this->FinalArgs.push_back(*s); - } - + } + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent("Unspecified"); + ->AddInstallComponent(this->Makefile->GetSafeDefinition( + "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); return true; } -void cmInstallProgramsCommand::FinalPass() +void cmInstallProgramsCommand::FinalPass() { bool files_mode = false; if(!this->FinalArgs.empty() && this->FinalArgs[0] == "FILES") { files_mode = true; } - + // two different options if (this->FinalArgs.size() > 1 || files_mode) { - // for each argument, get the programs + // for each argument, get the programs std::vector<std::string>::iterator s = this->FinalArgs.begin(); if(files_mode) { @@ -68,9 +69,9 @@ void cmInstallProgramsCommand::FinalPass() std::vector<std::string> programs; cmSystemTools::Glob(this->Makefile->GetCurrentDirectory(), this->FinalArgs[0].c_str(), programs); - + std::vector<std::string>::iterator s = programs.begin(); - // for each argument, get the programs + // for each argument, get the programs for (;s != programs.end(); ++s) { this->Files.push_back(this->FindInstallSource(s->c_str())); @@ -89,13 +90,14 @@ void cmInstallProgramsCommand::FinalPass() // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; - const char* no_component = "Unspecified"; + std::string no_component = this->Makefile->GetSafeDefinition( + "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector<std::string> no_configurations; this->Makefile->AddInstallGenerator( new cmInstallFilesGenerator(this->Files, destination.c_str(), true, no_permissions, no_configurations, - no_component, no_rename)); + no_component.c_str(), no_rename)); } /** @@ -112,7 +114,7 @@ std::string cmInstallProgramsCommand // This is a full path. return name; } - + // This is a relative path. std::string tb = this->Makefile->GetCurrentOutputDirectory(); tb += "/"; @@ -120,7 +122,7 @@ std::string cmInstallProgramsCommand std::string ts = this->Makefile->GetCurrentDirectory(); ts += "/"; ts += name; - + if(cmSystemTools::FileExists(tb.c_str())) { // The file exists in the binary tree. Use it. diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index 27fc175..277ccea 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -58,7 +58,8 @@ bool cmInstallTargetsCommand } this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent("Unspecified"); + ->AddInstallComponent(this->Makefile->GetSafeDefinition( + "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); return true; } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 3f5dd2c..5972c19 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -699,6 +699,31 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ENDIF(CTEST_RUN_CPackComponents) IF(CTEST_RUN_CPackComponentsForAll) + # Analyze 'cpack --help' output for list of available generators: + execute_process(COMMAND ${CMAKE_CPACK_COMMAND} --help + RESULT_VARIABLE result + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr) + + string(REPLACE ";" "\\;" stdout "${stdout}") + string(REPLACE "\n" "E;" stdout "${stdout}") + + set(collecting 0) + set(ACTIVE_CPACK_GENERATORS) + foreach(eline ${stdout}) + string(REGEX REPLACE "^(.*)E$" "\\1" line "${eline}") + if(collecting AND NOT line STREQUAL "") + string(REGEX REPLACE "^ ([^ ]+) += (.*)$" "\\1" gen "${line}") + string(REGEX REPLACE "^ ([^ ]+) += (.*)$" "\\2" doc "${line}") + list(APPEND ACTIVE_CPACK_GENERATORS ${gen}) + endif() + if(line STREQUAL "Generators") + set(collecting 1) + endif() + endforeach() + # ACTIVE_CPACK_GENERATORS variable + # now contains the list of 'active generators' + set(CPackComponentsForAll_EXTRA_OPTIONS) set(CPackRun_CPackCommand "-DCPackCommand=${CMAKE_CPACK_COMMAND}") # set up list of CPack generators @@ -706,18 +731,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ if(APPLE) list(APPEND GENLST "DragNDrop") endif(APPLE) - if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*") - find_program(RPMBUILD NAMES rpmbuild) - endif(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*") - if (RPMBUILD) - list(APPEND GENLST "RPM") - endif(RPMBUILD) - if (CMAKE_SYSTEM_NAME MATCHES "Linux") - find_program(DPKG NAMES dpkg) - if (DPKG) - list(APPEND GENLST "DEB") - endif(DPKG) - endif(CMAKE_SYSTEM_NAME MATCHES "Linux") + if (NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*") + list(FIND ACTIVE_CPACK_GENERATORS "RPM" RPM_ACTIVE) + if (NOT ${RPM_ACTIVE} EQUAL -1) + list(APPEND GENLST "RPM") + endif(NOT ${RPM_ACTIVE} EQUAL -1) + endif(NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*") + list(FIND ACTIVE_CPACK_GENERATORS "DEB" DEB_ACTIVE) + if (NOT ${DEB_ACTIVE} EQUAL -1) + list(APPEND GENLST "DEB") + endif(NOT ${DEB_ACTIVE} EQUAL -1) + # set up list of component packaging ways list(APPEND CWAYLST "default") list(APPEND CWAYLST "OnePackPerGroup") |