View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0014921 | CMake | CMake | public | 2014-05-19 04:47 | 2016-06-10 14:21 | ||||
Reporter | Nick Lewis | ||||||||
Assigned To | |||||||||
Priority | normal | Severity | feature | Reproducibility | always | ||||
Status | closed | Resolution | fixed | ||||||
Platform | All | OS | All | OS Version | All | ||||
Product Version | CMake 2.8.12.2 | ||||||||
Target Version | CMake 3.6 | Fixed in Version | CMake 3.6 | ||||||
Summary | 0014921: No way to exclude a component install() from a full installation | ||||||||
Description | There is currently no way to exclude a component install() from a full installation. Current workarounds using OPTIONAL do not work reliably because they depend on previous builds and on the order execution of the build and install commands for the components and the default target | ||||||||
Steps To Reproduce | make make tests make install DESTDIR=/testpkgs make install-tests This results in test components in the default installation as well as the testpkg Judging by questions on the mail list, users typically try to overcome this problem by adding the unsupported EXCLUDE_FROM_ALL keyword to the install command | ||||||||
Additional Information | patch attached that adds support for EXCLUDE_FROM_ALL to the install() command. | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | cmake_install_exclude.patch [^] (24,130 bytes) 2014-05-19 04:47 [Show Content] [Hide Content]diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 3c76bd6..23943c3 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -28,7 +28,8 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target, return new cmInstallTargetGenerator(target, args.GetDestination().c_str(), impLib, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), - args.GetOptional() || forceOpt); + args.GetExcludeFromAll(), + args.GetOptional() || forceOpt); } static cmInstallFilesGenerator* CreateInstallFilesGenerator( @@ -38,7 +39,8 @@ static cmInstallFilesGenerator* CreateInstallFilesGenerator( 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()); + args.GetExcludeFromAll(), args.GetRename().c_str(), + args.GetOptional()); } @@ -108,6 +110,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) int componentCount = 0; bool doing_script = false; bool doing_code = false; + bool exclude_from_all = false; // Scan the args once for COMPONENT. Only allow one. // @@ -119,6 +122,10 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) ++i; component = args[i]; } + if(args[i] == "EXCLUDE_FROM_ALL") + { + exclude_from_all = true; + } } if(componentCount>1) @@ -166,7 +173,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) } this->Makefile->AddInstallGenerator( new cmInstallScriptGenerator(script.c_str(), false, - component.c_str())); + component.c_str(), exclude_from_all)); } else if(doing_code) { @@ -174,7 +181,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) std::string code = args[i]; this->Makefile->AddInstallGenerator( new cmInstallScriptGenerator(code.c_str(), true, - component.c_str())); + component.c_str(), exclude_from_all)); } } @@ -900,6 +907,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) Doing doing = DoingDirs; bool in_match_mode = false; bool optional = false; + bool exclude_from_all = false; std::vector<std::string> dirs; const char* destination = 0; std::string permissions_file; @@ -1065,6 +1073,19 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) // Switch to setting the component property. doing = DoingComponent; } + else if(args[i] == "EXCLUDE_FROM_ALL") + { + if(in_match_mode) + { + cmOStringStream e; + e << args[0] << " does not allow \"" + << args[i] << "\" after PATTERN or REGEX."; + this->SetError(e.str().c_str()); + return false; + } + exclude_from_all = true; + doing = DoingNone; + } else if(doing == DoingDirs) { // Convert this directory to a full path. @@ -1204,6 +1225,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) permissions_dir.c_str(), configurations, component.c_str(), + exclude_from_all, literal_args.c_str(), optional)); @@ -1328,7 +1350,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), ica.GetConfigurations(), - ica.GetComponent().c_str(), fname.c_str(), + ica.GetComponent().c_str(), ica.GetExcludeFromAll(), fname.c_str(), name_space.GetCString(), exportOld.IsEnabled(), this->Makefile); this->Makefile->AddInstallGenerator(exportGenerator); diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 6509501..a127cdb 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -87,7 +87,8 @@ public: "with which the install rule is associated, such as \"runtime\" or " "\"development\". During component-specific installation only " "install rules associated with the given component name will be " - "executed. During a full installation all components are installed." + "executed. During a full installation all components are installed " + "unless marked with EXCLUDE_FROM_ALL." " If COMPONENT is not provided a default component \"Unspecified\" is" " created. The default component name may be controlled with the " "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME variable.\n" @@ -106,7 +107,8 @@ public: " [PERMISSIONS permissions...]\n" " [CONFIGURATIONS [Debug|Release|...]]\n" " [COMPONENT <component>]\n" - " [OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP]\n" + " [OPTIONAL] [EXCLUDE_FROM_ALL]\n" + " [NAMELINK_ONLY|NAMELINK_SKIP]\n" " ] [...])\n" "The TARGETS form specifies rules for installing targets from a " "project. There are five kinds of target files that may be " @@ -187,14 +189,14 @@ public: "See documentation of the install(EXPORT ...) signature below for " "details." "\n" - "Installing a target with EXCLUDE_FROM_ALL set to true has " - "undefined behavior." + "Installing a target that has EXCLUDE_FROM_ALL set to true in" + "add_executable or add_library has undefined behavior." "\n" "The FILES signature:\n" " install(FILES files... DESTINATION <dir>\n" " [PERMISSIONS permissions...]\n" " [CONFIGURATIONS [Debug|Release|...]]\n" - " [COMPONENT <component>]\n" + " [COMPONENT <component>] [EXCLUDE_FROM_ALL]\n" " [RENAME <name>] [OPTIONAL])\n" "The FILES form specifies rules for installing files for a " "project. File names given as relative paths are interpreted with " @@ -206,7 +208,7 @@ public: " install(PROGRAMS files... DESTINATION <dir>\n" " [PERMISSIONS permissions...]\n" " [CONFIGURATIONS [Debug|Release|...]]\n" - " [COMPONENT <component>]\n" + " [COMPONENT <component>] [EXCLUDE_FROM_ALL]\n" " [RENAME <name>] [OPTIONAL])\n" "The PROGRAMS form is identical to the FILES form except that the " "default permissions for the installed file also include " @@ -221,7 +223,8 @@ public: " [DIRECTORY_PERMISSIONS permissions...]\n" " [USE_SOURCE_PERMISSIONS] [OPTIONAL]\n" " [CONFIGURATIONS [Debug|Release|...]]\n" - " [COMPONENT <component>] [FILES_MATCHING]\n" + " [COMPONENT <component>] [EXCLUDE_FROM_ALL]\n" + " [FILES_MATCHING]\n" " [[PATTERN <pattern> | REGEX <regex>]\n" " [EXCLUDE] [PERMISSIONS permissions...]] [...])\n" "The DIRECTORY form installs contents of one or more directories " @@ -297,7 +300,7 @@ public: " [PERMISSIONS permissions...]\n" " [CONFIGURATIONS [Debug|Release|...]]\n" " [EXPORT_LINK_INTERFACE_LIBRARIES]\n" - " [COMPONENT <component>])\n" + " [COMPONENT <component>] [EXCLUDE_FROM_ALL])\n" "The EXPORT form generates and installs a CMake file containing code " "to import targets from the installation tree into another project. " "Target installations are associated with the export <export-name> " diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 91ea861..c681416 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -27,14 +27,15 @@ cmInstallCommandArguments::cmInstallCommandArguments( const std::string& defaultComponent) :Parser() ,ArgumentGroup() -,Destination (&Parser, "DESTINATION" , &ArgumentGroup) -,Component (&Parser, "COMPONENT" , &ArgumentGroup) -,Rename (&Parser, "RENAME" , &ArgumentGroup) -,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup) -,Configurations(&Parser, "CONFIGURATIONS", &ArgumentGroup) -,Optional (&Parser, "OPTIONAL" , &ArgumentGroup) -,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup) -,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup) +,Destination (&Parser, "DESTINATION" , &ArgumentGroup) +,Component (&Parser, "COMPONENT" , &ArgumentGroup) +,ExcludeFromAll(&Parser, "EXCLUDE_FROM_ALL", &ArgumentGroup) +,Rename (&Parser, "RENAME" , &ArgumentGroup) +,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup) +,Configurations(&Parser, "CONFIGURATIONS" , &ArgumentGroup) +,Optional (&Parser, "OPTIONAL" , &ArgumentGroup) +,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup) +,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup) ,GenericArguments(0) ,DefaultComponentName(defaultComponent) { @@ -110,6 +111,19 @@ bool cmInstallCommandArguments::GetOptional() const return false; } +bool cmInstallCommandArguments::GetExcludeFromAll() const +{ + if (this->ExcludeFromAll.IsEnabled()) + { + return true; + } + if (this->GenericArguments!=0) + { + return this->GenericArguments->GetExcludeFromAll(); + } + return false; +} + bool cmInstallCommandArguments::GetNamelinkOnly() const { if (this->NamelinkOnly.IsEnabled()) diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h index 90347e6..694f1ed 100644 --- a/Source/cmInstallCommandArguments.h +++ b/Source/cmInstallCommandArguments.h @@ -30,6 +30,7 @@ class cmInstallCommandArguments const std::string& GetDestination() const; const std::string& GetComponent() const; + bool GetExcludeFromAll() const; const std::string& GetRename() const; const std::string& GetPermissions() const; const std::vector<std::string>& GetConfigurations() const; @@ -48,6 +49,7 @@ class cmInstallCommandArguments cmInstallCommandArguments(); // disabled cmCAString Destination; cmCAString Component; + cmCAEnabler ExcludeFromAll; cmCAString Rename; cmCAStringVector Permissions; cmCAStringVector Configurations; diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index ddf7d08..1041788 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -21,11 +21,13 @@ cmInstallDirectoryGenerator const char* dir_permissions, std::vector<std::string> const& configurations, const char* component, + bool exclude_from_all, const char* literal_args, bool optional): - cmInstallGenerator(dest, configurations, component), Directories(dirs), - FilePermissions(file_permissions), DirPermissions(dir_permissions), - LiteralArguments(literal_args), Optional(optional) + cmInstallGenerator(dest, configurations, component, exclude_from_all), + Directories(dirs), FilePermissions(file_permissions), + DirPermissions(dir_permissions), LiteralArguments(literal_args), + Optional(optional) { } diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h index d76ef3c..b391e9e 100644 --- a/Source/cmInstallDirectoryGenerator.h +++ b/Source/cmInstallDirectoryGenerator.h @@ -26,6 +26,7 @@ public: const char* dir_permissions, std::vector<std::string> const& configurations, const char* component, + bool exclude_from_all, const char* literal_args, bool optional = false); virtual ~cmInstallDirectoryGenerator(); diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 3e9e6ac..481c3c7 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -32,10 +32,11 @@ cmInstallExportGenerator::cmInstallExportGenerator( const char* file_permissions, std::vector<std::string> const& configurations, const char* component, + bool exclude_from_all, const char* filename, const char* name_space, bool exportOld, cmMakefile* mf) - :cmInstallGenerator(destination, configurations, component) + :cmInstallGenerator(destination, configurations, component, exclude_from_all) ,ExportSet(exportSet) ,FilePermissions(file_permissions) ,FileName(filename) diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index 37b5593..f0ced17 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -30,6 +30,7 @@ public: const char* dest, const char* file_permissions, const std::vector<std::string>& configurations, const char* component, + bool exclude_from_all, const char* filename, const char* name_space, bool exportOld, cmMakefile* mf); ~cmInstallExportGenerator(); diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index cc62c4b..21d3c2a 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -129,6 +129,7 @@ void cmInstallFilesCommand::CreateInstallGenerator() const // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; + bool no_exclude_from_all = false; std::string no_component = this->Makefile->GetSafeDefinition( "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector<std::string> no_configurations; @@ -136,7 +137,8 @@ void cmInstallFilesCommand::CreateInstallGenerator() const new cmInstallFilesGenerator(this->Files, destination.c_str(), false, no_permissions, no_configurations, - no_component.c_str(), no_rename)); + no_component.c_str(), no_exclude_from_all, + no_rename)); } diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index ec02bc7..74ac462 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -18,9 +18,10 @@ cmInstallFilesGenerator const char* file_permissions, std::vector<std::string> const& configurations, const char* component, + bool exclude_from_all, const char* rename, bool optional): - cmInstallGenerator(dest, configurations, component), + cmInstallGenerator(dest, configurations, component, exclude_from_all), Files(files), Programs(programs), FilePermissions(file_permissions), Rename(rename), Optional(optional) diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index 871335c..5e2f201 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -25,6 +25,7 @@ public: const char* file_permissions, std::vector<std::string> const& configurations, const char* component, + bool exclude_from_all, const char* rename, bool optional = false); virtual ~cmInstallFilesGenerator(); diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 3be2c2b..4147de6 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -17,10 +17,12 @@ cmInstallGenerator ::cmInstallGenerator(const char* destination, std::vector<std::string> const& configurations, - const char* component): + const char* component, + bool exclude_from_all): cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations), Destination(destination? destination:""), - Component(component? component:"") + Component(component? component:""), + ExcludeFromAll(exclude_from_all) { } @@ -135,12 +137,15 @@ void cmInstallGenerator //---------------------------------------------------------------------------- std::string -cmInstallGenerator::CreateComponentTest(const char* component) +cmInstallGenerator::CreateComponentTest(const char* component, bool exclude_from_all) { - std::string result = "NOT CMAKE_INSTALL_COMPONENT OR " - "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \""; + std::string result = "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \""; result += component; result += "\""; + if(!exclude_from_all) + { + result += " OR NOT CMAKE_INSTALL_COMPONENT"; + } return result; } @@ -152,7 +157,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os) // Begin this block of installation. std::string component_test = - this->CreateComponentTest(this->Component.c_str()); + this->CreateComponentTest(this->Component.c_str(),this->ExcludeFromAll); os << indent << "IF(" << component_test << ")\n"; // Generate the script possibly with per-configuration code. diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index c89ab8a..5073282 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -26,7 +26,7 @@ class cmInstallGenerator: public cmScriptGenerator public: cmInstallGenerator(const char* destination, std::vector<std::string> const& configurations, - const char* component); + const char* component, bool exclude_from_all); virtual ~cmInstallGenerator(); void AddInstallRule( @@ -53,11 +53,12 @@ public: protected: virtual void GenerateScript(std::ostream& os); - std::string CreateComponentTest(const char* component); + std::string CreateComponentTest(const char* component, bool exclude_from_all); // Information shared by most generator types. std::string Destination; std::string Component; + bool ExcludeFromAll; }; #endif diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 3a0a322..4dc1f3a 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -90,6 +90,7 @@ void cmInstallProgramsCommand::FinalPass() // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; + bool no_exclude_from_all = false; std::string no_component = this->Makefile->GetSafeDefinition( "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector<std::string> no_configurations; @@ -97,7 +98,8 @@ void cmInstallProgramsCommand::FinalPass() new cmInstallFilesGenerator(this->Files, destination.c_str(), true, no_permissions, no_configurations, - no_component.c_str(), no_rename)); + no_component.c_str(), no_exclude_from_all, + no_rename)); } /** diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index bcfbe63..72e4b61 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -14,8 +14,9 @@ //---------------------------------------------------------------------------- cmInstallScriptGenerator ::cmInstallScriptGenerator(const char* script, bool code, - const char* component) : - cmInstallGenerator(0, std::vector<std::string>(), component), + const char* component, bool exclude_from_all) : + cmInstallGenerator(0, std::vector<std::string>(), component, + exclude_from_all), Script(script), Code(code) { } @@ -31,7 +32,7 @@ void cmInstallScriptGenerator::GenerateScript(std::ostream& os) { Indent indent; std::string component_test = - this->CreateComponentTest(this->Component.c_str()); + this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll); os << indent << "IF(" << component_test << ")\n"; if(this->Code) diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h index 54a7b21..7e7c0c8 100644 --- a/Source/cmInstallScriptGenerator.h +++ b/Source/cmInstallScriptGenerator.h @@ -21,7 +21,7 @@ class cmInstallScriptGenerator: public cmInstallGenerator { public: cmInstallScriptGenerator(const char* script, bool code, - const char* component); + const char* component, bool exclude_from_all); virtual ~cmInstallScriptGenerator(); protected: diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c9624c8..4fba1a0 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -24,9 +24,11 @@ cmInstallTargetGenerator ::cmInstallTargetGenerator(cmTarget& t, const char* dest, bool implib, const char* file_permissions, std::vector<std::string> const& configurations, - const char* component, bool optional): - cmInstallGenerator(dest, configurations, component), Target(&t), - ImportLibrary(implib), FilePermissions(file_permissions), Optional(optional) + const char* component, bool exclude_from_all, + bool optional): + cmInstallGenerator(dest, configurations, component, exclude_from_all), + Target(&t), ImportLibrary(implib), + FilePermissions(file_permissions), Optional(optional) { this->ActionsPerConfig = true; this->NamelinkMode = NamelinkModeNone; diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 8cf72f9..de16601 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -28,6 +28,7 @@ public: std::vector<std::string> const& configurations = std::vector<std::string>(), const char* component = "Unspecified", + bool exclude_from_all = false, bool optional = false ); virtual ~cmInstallTargetGenerator(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 9c04109..9c60424 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2758,7 +2758,7 @@ cmLocalGenerator // Include the user-specified pre-install script for this target. if(const char* preinstall = l->second.GetProperty("PRE_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(preinstall, false, 0); + cmInstallScriptGenerator g(preinstall, false, 0, false); g.Generate(os, config, configurationTypes); } @@ -2815,7 +2815,7 @@ cmLocalGenerator // Include the user-specified post-install script for this target. if(const char* postinstall = l->second.GetProperty("POST_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(postinstall, false, 0); + cmInstallScriptGenerator g(postinstall, false, 0, false); g.Generate(os, config, configurationTypes); } } cmake_3_2_2_install_exclude.patch [^] (23,369 bytes) 2015-07-16 12:20 [Show Content] [Hide Content] diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 3c76bd6..23943c3 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -31,7 +31,8 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target, impLib, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), message, - args.GetOptional() || forceOpt); + args.GetExcludeFromAll(), + args.GetOptional() || forceOpt); } static cmInstallFilesGenerator* CreateInstallFilesGenerator( @@ -46,7 +47,8 @@ static cmInstallFilesGenerator* CreateInstallFilesGenerator( programs, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), message, - args.GetRename().c_str(), args.GetOptional()); + args.GetExcludeFromAll(), args.GetRename().c_str(), + args.GetOptional()); } @@ -116,6 +118,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) int componentCount = 0; bool doing_script = false; bool doing_code = false; + bool exclude_from_all = false; // Scan the args once for COMPONENT. Only allow one. // @@ -127,6 +130,10 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) ++i; component = args[i]; } + if(args[i] == "EXCLUDE_FROM_ALL") + { + exclude_from_all = true; + } } if(componentCount>1) @@ -174,7 +181,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) } this->Makefile->AddInstallGenerator( new cmInstallScriptGenerator(script.c_str(), false, - component.c_str())); + component.c_str(), exclude_from_all)); } else if(doing_code) { @@ -182,7 +199,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) std::string code = args[i]; this->Makefile->AddInstallGenerator( new cmInstallScriptGenerator(code.c_str(), true, - component.c_str())); + component.c_str(), exclude_from_all)); } } @@ -906,6 +913,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) Doing doing = DoingDirs; bool in_match_mode = false; bool optional = false; + bool exclude_from_all = false; bool message_never = false; std::vector<std::string> dirs; const char* destination = 0; @@ -1087,6 +1095,19 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) // Switch to setting the component property. doing = DoingComponent; } + else if(args[i] == "EXCLUDE_FROM_ALL") + { + if(in_match_mode) + { + std::ostringstream e; + e << args[0] << " does not allow \"" + << args[i] << "\" after PATTERN or REGEX."; + this->SetError(e.str().c_str()); + return false; + } + exclude_from_all = true; + doing = DoingNone; + } else if(doing == DoingDirs) { // Convert this directory to a full path. @@ -1230,6 +1251,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) configurations, component.c_str(), message, + exclude_from_all, literal_args.c_str(), optional)); @@ -1357,7 +1379,8 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), ica.GetConfigurations(), - ica.GetComponent().c_str(), message, fname.c_str(), + ica.GetComponent().c_str(), message, + ica.GetExcludeFromAll(), fname.c_str(), name_space.GetCString(), exportOld.IsEnabled(), this->Makefile); this->Makefile->AddInstallGenerator(exportGenerator); diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 6509501..a127cdb 100644 --- a/Help/command/install.rst +++ b/Help/command/install.rst @@ -45,9 +45,9 @@ is associated, such as "runtime" or "development". During component-specific installation only install rules associated with the given component name will be executed. During a full installation - all components are installed. If ``COMPONENT`` is not provided a - default component "Unspecified" is created. The default component - name may be controlled with the + all components are installed unless marked with EXCLUDE_FROM_ALL. + If ``COMPONENT`` is not provided a default component "Unspecified" is + created. The default component name may be controlled with the :variable:`CMAKE_INSTALL_DEFAULT_COMPONENT_NAME` variable. ``RENAME`` @@ -76,7 +76,8 @@ [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] [COMPONENT <component>] - [OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP] + [OPTIONAL] [EXCLUDE_FROM_ALL] + [NAMELINK_ONLY|NAMELINK_SKIP] ] [...]) The ``TARGETS`` form specifies rules for installing targets from a project. There are five kinds of target files that may be @@ -187,7 +188,7 @@ file itself, call ``install(EXPORT)``, documented below. Installing a target with the :prop_tgt:`EXCLUDE_FROM_ALL` target property -set to ``TRUE`` has undefined behavior. +set to ``TRUE`` in add_executable or add_library has undefined behavior. Installing Files ^^^^^^^^^^^^^^^^ @@ -187,7 +188,7 @@ install(<FILES|PROGRAMS> files... DESTINATION <dir> [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] - [COMPONENT <component>] + [COMPONENT <component>] [EXCLUDE_FROM_ALL] [RENAME <name>] [OPTIONAL]) The ``FILES`` form specifies rules for installing files for a project. @@ -221,7 +223,8 @@ [DIRECTORY_PERMISSIONS permissions...] [USE_SOURCE_PERMISSIONS] [OPTIONAL] [CONFIGURATIONS [Debug|Release|...]] - [COMPONENT <component>] [FILES_MATCHING] + [COMPONENT <component>] [EXCLUDE_FROM_ALL] + [FILES_MATCHING] [[PATTERN <pattern> | REGEX <regex>] [EXCLUDE] [PERMISSIONS permissions...]] [...]) @@ -297,7 +300,7 @@ public: [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] [EXPORT_LINK_INTERFACE_LIBRARIES] - [COMPONENT <component>]) + [COMPONENT <component>] [EXCLUDE_FROM_ALL]) The EXPORT form generates and installs a CMake file containing code to import targets from the installation tree into another project. diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 91ea861..c681416 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -27,14 +27,15 @@ cmInstallCommandArguments::cmInstallCommandArguments( const std::string& defaultComponent) :Parser() ,ArgumentGroup() -,Destination (&Parser, "DESTINATION" , &ArgumentGroup) -,Component (&Parser, "COMPONENT" , &ArgumentGroup) -,Rename (&Parser, "RENAME" , &ArgumentGroup) -,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup) -,Configurations(&Parser, "CONFIGURATIONS", &ArgumentGroup) -,Optional (&Parser, "OPTIONAL" , &ArgumentGroup) -,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup) -,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup) +,Destination (&Parser, "DESTINATION" , &ArgumentGroup) +,Component (&Parser, "COMPONENT" , &ArgumentGroup) +,ExcludeFromAll(&Parser, "EXCLUDE_FROM_ALL", &ArgumentGroup) +,Rename (&Parser, "RENAME" , &ArgumentGroup) +,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup) +,Configurations(&Parser, "CONFIGURATIONS" , &ArgumentGroup) +,Optional (&Parser, "OPTIONAL" , &ArgumentGroup) +,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup) +,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup) ,GenericArguments(0) ,DefaultComponentName(defaultComponent) { @@ -110,6 +111,19 @@ bool cmInstallCommandArguments::GetOptional() const return false; } +bool cmInstallCommandArguments::GetExcludeFromAll() const +{ + if (this->ExcludeFromAll.IsEnabled()) + { + return true; + } + if (this->GenericArguments!=0) + { + return this->GenericArguments->GetExcludeFromAll(); + } + return false; +} + bool cmInstallCommandArguments::GetNamelinkOnly() const { if (this->NamelinkOnly.IsEnabled()) diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h index 90347e6..694f1ed 100644 --- a/Source/cmInstallCommandArguments.h +++ b/Source/cmInstallCommandArguments.h @@ -30,6 +30,7 @@ class cmInstallCommandArguments const std::string& GetDestination() const; const std::string& GetComponent() const; + bool GetExcludeFromAll() const; const std::string& GetRename() const; const std::string& GetPermissions() const; const std::vector<std::string>& GetConfigurations() const; @@ -48,6 +49,7 @@ class cmInstallCommandArguments cmInstallCommandArguments(); // disabled cmCAString Destination; cmCAString Component; + cmCAEnabler ExcludeFromAll; cmCAString Rename; cmCAStringVector Permissions; cmCAStringVector Configurations; diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index ddf7d08..1041788 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -22,9 +22,11 @@ cmInstallDirectoryGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* literal_args, bool optional): - cmInstallGenerator(dest, configurations, component, message), + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), Directories(dirs), FilePermissions(file_permissions), DirPermissions(dir_permissions), LiteralArguments(literal_args), Optional(optional) diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h index d76ef3c..b391e9e 100644 --- a/Source/cmInstallDirectoryGenerator.h +++ b/Source/cmInstallDirectoryGenerator.h @@ -27,6 +27,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* literal_args, bool optional = false); virtual ~cmInstallDirectoryGenerator(); diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 3e9e6ac..481c3c7 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -33,10 +33,12 @@ cmInstallExportGenerator::cmInstallExportGenerator( std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* filename, const char* name_space, bool exportOld, cmMakefile* mf) - :cmInstallGenerator(destination, configurations, component, message) + :cmInstallGenerator(destination, configurations, component, message, + exclude_from_all) ,ExportSet(exportSet) ,FilePermissions(file_permissions) ,FileName(filename) diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index 37b5593..f0ced17 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -31,6 +31,7 @@ public: const std::vector<std::string>& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* filename, const char* name_space, bool exportOld, cmMakefile* mf); ~cmInstallExportGenerator(); diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index cc62c4b..21d3c2a 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -126,6 +126,7 @@ void cmInstallFilesCommand::CreateInstallGenerator() const // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; + bool no_exclude_from_all = false; std::string no_component = this->Makefile->GetSafeDefinition( "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector<std::string> no_configurations; @@ -135,7 +136,8 @@ void cmInstallFilesCommand::CreateInstallGenerator() const new cmInstallFilesGenerator(this->Makefile, this->Files, destination.c_str(), false, no_permissions, no_configurations, - no_component.c_str(), message, no_rename)); + no_component.c_str(), message, + no_exclude_from_all, no_rename)); } diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index ec02bc7..74ac462 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -24,9 +24,11 @@ cmInstallFilesGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* rename, bool optional): - cmInstallGenerator(dest, configurations, component, message), + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), Makefile(mf), Files(files), Programs(programs), FilePermissions(file_permissions), diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index 871335c..5e2f201 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -29,6 +29,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* rename, bool optional = false); virtual ~cmInstallFilesGenerator(); diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 3be2c2b..4147de6 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -19,11 +19,13 @@ ::cmInstallGenerator(const char* destination, std::vector<std::string> const& configurations, const char* component, - MessageLevel message): + MessageLevel message, + bool exclude_from_all): cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations), Destination(destination? destination:""), Component(component? component:""), - Message(message) + Message(message), + ExcludeFromAll(exclude_from_all) { } @@ -145,12 +147,15 @@ void cmInstallGenerator //---------------------------------------------------------------------------- std::string -cmInstallGenerator::CreateComponentTest(const char* component) +cmInstallGenerator::CreateComponentTest(const char* component, bool exclude_from_all) { - std::string result = "NOT CMAKE_INSTALL_COMPONENT OR " - "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \""; + std::string result = "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \""; result += component; result += "\""; + if(!exclude_from_all) + { + result += " OR NOT CMAKE_INSTALL_COMPONENT"; + } return result; } @@ -162,7 +167,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os) // Begin this block of installation. std::string component_test = - this->CreateComponentTest(this->Component.c_str()); + this->CreateComponentTest(this->Component.c_str(),this->ExcludeFromAll); os << indent << "if(" << component_test << ")\n"; // Generate the script possibly with per-configuration code. diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index c89ab8a..5073282 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -36,7 +36,8 @@ class cmInstallGenerator: public cmScriptGenerator cmInstallGenerator(const char* destination, std::vector<std::string> const& configurations, const char* component, - MessageLevel message); + MessageLevel message, + bool exclude_from_all); virtual ~cmInstallGenerator(); void AddInstallRule( @@ -66,12 +67,14 @@ public: protected: virtual void GenerateScript(std::ostream& os); - std::string CreateComponentTest(const char* component); + std::string CreateComponentTest(const char* component, + bool exclude_from_all); // Information shared by most generator types. std::string Destination; std::string Component; MessageLevel Message; + bool ExcludeFromAll; }; #endif diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 3a0a322..4dc1f3a 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -86,6 +86,7 @@ void cmInstallProgramsCommand::FinalPass() // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; + bool no_exclude_from_all = false; std::string no_component = this->Makefile->GetSafeDefinition( "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector<std::string> no_configurations; @@ -95,7 +96,8 @@ void cmInstallProgramsCommand::FinalPass() new cmInstallFilesGenerator(this->Makefile, this->Files, destination.c_str(), true, no_permissions, no_configurations, - no_component.c_str(), message, no_rename)); + no_component.c_str(), message, + no_exclude_from_all, no_rename)); } /** diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index bcfbe63..72e4b61 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -14,8 +14,9 @@ //---------------------------------------------------------------------------- cmInstallScriptGenerator ::cmInstallScriptGenerator(const char* script, bool code, - const char* component) : - cmInstallGenerator(0, std::vector<std::string>(), component, MessageDefault), + const char* component, bool exclude_from_all) : + cmInstallGenerator(0, std::vector<std::string>(), component, MessageDefault, + exclude_from_all), Script(script), Code(code) { } @@ -31,7 +32,7 @@ void cmInstallScriptGenerator::GenerateScript(std::ostream& os) { Indent indent; std::string component_test = - this->CreateComponentTest(this->Component.c_str()); + this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll); os << indent << "if(" << component_test << ")\n"; if(this->Code) diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h index 54a7b21..7e7c0c8 100644 --- a/Source/cmInstallScriptGenerator.h +++ b/Source/cmInstallScriptGenerator.h @@ -21,7 +21,7 @@ class cmInstallScriptGenerator: public cmInstallGenerator { public: cmInstallScriptGenerator(const char* script, bool code, - const char* component); + const char* component, bool exclude_from_all); virtual ~cmInstallScriptGenerator(); protected: diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c9624c8..4fba1a0 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -26,9 +26,12 @@ cmInstallTargetGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, - bool optional): - cmInstallGenerator(dest, configurations, component, message), Target(&t), - ImportLibrary(implib), FilePermissions(file_permissions), Optional(optional) + bool exclude_from_all, + bool optional): + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), + Target(&t), ImportLibrary(implib), + FilePermissions(file_permissions), Optional(optional) { this->ActionsPerConfig = true; this->NamelinkMode = NamelinkModeNone; diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 8cf72f9..de16601 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -28,6 +28,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, bool optional ); virtual ~cmInstallTargetGenerator(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 9c04109..9c60424 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3034,7 +3034,7 @@ cmInstallTargetGenerator( t, dest, implib, "", std::vector<std::string>(), "Unspecified", cmInstallGenerator::SelectMessageLevel(t.GetMakefile()), - false) {} + false, false) {} }; //---------------------------------------------------------------------------- @@ -3057,7 +3057,7 @@ cmLocalGenerator // Include the user-specified pre-install script for this target. if(const char* preinstall = l->second.GetProperty("PRE_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(preinstall, false, 0); + cmInstallScriptGenerator g(preinstall, false, 0, false); g.Generate(os, config, configurationTypes); } @@ -3118,7 +3118,7 @@ cmLocalGenerator // Include the user-specified post-install script for this target. if(const char* postinstall = l->second.GetProperty("POST_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(postinstall, false, 0); + cmInstallScriptGenerator g(postinstall, false, 0, false); g.Generate(os, config, configurationTypes); } } cmake_3_4_2_install_exclude.patch [^] (23,369 bytes) 2016-01-29 03:29 [Show Content] [Hide Content] diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 3c76bd6..23943c3 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -31,7 +31,8 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target, impLib, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), message, - args.GetOptional() || forceOpt); + args.GetExcludeFromAll(), + args.GetOptional() || forceOpt); } static cmInstallFilesGenerator* CreateInstallFilesGenerator( @@ -46,7 +47,8 @@ static cmInstallFilesGenerator* CreateInstallFilesGenerator( programs, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), message, - args.GetRename().c_str(), args.GetOptional()); + args.GetExcludeFromAll(), args.GetRename().c_str(), + args.GetOptional()); } @@ -116,6 +118,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) int componentCount = 0; bool doing_script = false; bool doing_code = false; + bool exclude_from_all = false; // Scan the args once for COMPONENT. Only allow one. // @@ -127,6 +130,10 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) ++i; component = args[i]; } + if(args[i] == "EXCLUDE_FROM_ALL") + { + exclude_from_all = true; + } } if(componentCount>1) @@ -174,7 +181,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) } this->Makefile->AddInstallGenerator( new cmInstallScriptGenerator(script.c_str(), false, - component.c_str())); + component.c_str(), exclude_from_all)); } else if(doing_code) { @@ -182,7 +199,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) std::string code = args[i]; this->Makefile->AddInstallGenerator( new cmInstallScriptGenerator(code.c_str(), true, - component.c_str())); + component.c_str(), exclude_from_all)); } } @@ -906,6 +913,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) Doing doing = DoingDirs; bool in_match_mode = false; bool optional = false; + bool exclude_from_all = false; bool message_never = false; std::vector<std::string> dirs; const char* destination = 0; @@ -1087,6 +1095,19 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) // Switch to setting the component property. doing = DoingComponent; } + else if(args[i] == "EXCLUDE_FROM_ALL") + { + if(in_match_mode) + { + std::ostringstream e; + e << args[0] << " does not allow \"" + << args[i] << "\" after PATTERN or REGEX."; + this->SetError(e.str().c_str()); + return false; + } + exclude_from_all = true; + doing = DoingNone; + } else if(doing == DoingDirs) { // Convert this directory to a full path. @@ -1230,6 +1251,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) configurations, component.c_str(), message, + exclude_from_all, literal_args.c_str(), optional)); @@ -1357,7 +1379,8 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), ica.GetConfigurations(), - ica.GetComponent().c_str(), message, fname.c_str(), + ica.GetComponent().c_str(), message, + ica.GetExcludeFromAll(), fname.c_str(), name_space.GetCString(), exportOld.IsEnabled(), this->Makefile); this->Makefile->AddInstallGenerator(exportGenerator); diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 6509501..a127cdb 100644 --- a/Help/command/install.rst +++ b/Help/command/install.rst @@ -45,9 +45,9 @@ is associated, such as "runtime" or "development". During component-specific installation only install rules associated with the given component name will be executed. During a full installation - all components are installed. If ``COMPONENT`` is not provided a - default component "Unspecified" is created. The default component - name may be controlled with the + all components are installed unless marked with EXCLUDE_FROM_ALL. + If ``COMPONENT`` is not provided a default component "Unspecified" is + created. The default component name may be controlled with the :variable:`CMAKE_INSTALL_DEFAULT_COMPONENT_NAME` variable. ``RENAME`` @@ -76,7 +76,8 @@ [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] [COMPONENT <component>] - [OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP] + [OPTIONAL] [EXCLUDE_FROM_ALL] + [NAMELINK_ONLY|NAMELINK_SKIP] ] [...]) The ``TARGETS`` form specifies rules for installing targets from a project. There are five kinds of target files that may be @@ -187,7 +188,7 @@ file itself, call ``install(EXPORT)``, documented below. Installing a target with the :prop_tgt:`EXCLUDE_FROM_ALL` target property -set to ``TRUE`` has undefined behavior. +set to ``TRUE`` in add_executable or add_library has undefined behavior. Installing Files ^^^^^^^^^^^^^^^^ @@ -187,7 +188,7 @@ install(<FILES|PROGRAMS> files... DESTINATION <dir> [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] - [COMPONENT <component>] + [COMPONENT <component>] [EXCLUDE_FROM_ALL] [RENAME <name>] [OPTIONAL]) The ``FILES`` form specifies rules for installing files for a project. @@ -221,7 +223,8 @@ [DIRECTORY_PERMISSIONS permissions...] [USE_SOURCE_PERMISSIONS] [OPTIONAL] [CONFIGURATIONS [Debug|Release|...]] - [COMPONENT <component>] [FILES_MATCHING] + [COMPONENT <component>] [EXCLUDE_FROM_ALL] + [FILES_MATCHING] [[PATTERN <pattern> | REGEX <regex>] [EXCLUDE] [PERMISSIONS permissions...]] [...]) @@ -297,7 +300,7 @@ public: [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] [EXPORT_LINK_INTERFACE_LIBRARIES] - [COMPONENT <component>]) + [COMPONENT <component>] [EXCLUDE_FROM_ALL]) The EXPORT form generates and installs a CMake file containing code to import targets from the installation tree into another project. diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 91ea861..c681416 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -27,14 +27,15 @@ cmInstallCommandArguments::cmInstallCommandArguments( const std::string& defaultComponent) :Parser() ,ArgumentGroup() -,Destination (&Parser, "DESTINATION" , &ArgumentGroup) -,Component (&Parser, "COMPONENT" , &ArgumentGroup) -,Rename (&Parser, "RENAME" , &ArgumentGroup) -,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup) -,Configurations(&Parser, "CONFIGURATIONS", &ArgumentGroup) -,Optional (&Parser, "OPTIONAL" , &ArgumentGroup) -,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup) -,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup) +,Destination (&Parser, "DESTINATION" , &ArgumentGroup) +,Component (&Parser, "COMPONENT" , &ArgumentGroup) +,ExcludeFromAll(&Parser, "EXCLUDE_FROM_ALL", &ArgumentGroup) +,Rename (&Parser, "RENAME" , &ArgumentGroup) +,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup) +,Configurations(&Parser, "CONFIGURATIONS" , &ArgumentGroup) +,Optional (&Parser, "OPTIONAL" , &ArgumentGroup) +,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup) +,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup) ,GenericArguments(0) ,DefaultComponentName(defaultComponent) { @@ -110,6 +111,19 @@ bool cmInstallCommandArguments::GetOptional() const return false; } +bool cmInstallCommandArguments::GetExcludeFromAll() const +{ + if (this->ExcludeFromAll.IsEnabled()) + { + return true; + } + if (this->GenericArguments!=0) + { + return this->GenericArguments->GetExcludeFromAll(); + } + return false; +} + bool cmInstallCommandArguments::GetNamelinkOnly() const { if (this->NamelinkOnly.IsEnabled()) diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h index 90347e6..694f1ed 100644 --- a/Source/cmInstallCommandArguments.h +++ b/Source/cmInstallCommandArguments.h @@ -30,6 +30,7 @@ class cmInstallCommandArguments const std::string& GetDestination() const; const std::string& GetComponent() const; + bool GetExcludeFromAll() const; const std::string& GetRename() const; const std::string& GetPermissions() const; const std::vector<std::string>& GetConfigurations() const; @@ -48,6 +49,7 @@ class cmInstallCommandArguments cmInstallCommandArguments(); // disabled cmCAString Destination; cmCAString Component; + cmCAEnabler ExcludeFromAll; cmCAString Rename; cmCAStringVector Permissions; cmCAStringVector Configurations; diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index ddf7d08..1041788 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -22,9 +22,11 @@ cmInstallDirectoryGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* literal_args, bool optional): - cmInstallGenerator(dest, configurations, component, message), + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), Directories(dirs), FilePermissions(file_permissions), DirPermissions(dir_permissions), LiteralArguments(literal_args), Optional(optional) diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h index d76ef3c..b391e9e 100644 --- a/Source/cmInstallDirectoryGenerator.h +++ b/Source/cmInstallDirectoryGenerator.h @@ -27,6 +27,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* literal_args, bool optional = false); virtual ~cmInstallDirectoryGenerator(); diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 3e9e6ac..481c3c7 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -33,10 +33,12 @@ cmInstallExportGenerator::cmInstallExportGenerator( std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* filename, const char* name_space, bool exportOld, cmMakefile* mf) - :cmInstallGenerator(destination, configurations, component, message) + :cmInstallGenerator(destination, configurations, component, message, + exclude_from_all) ,ExportSet(exportSet) ,FilePermissions(file_permissions) ,FileName(filename) diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index 37b5593..f0ced17 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -31,6 +31,7 @@ public: const std::vector<std::string>& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* filename, const char* name_space, bool exportOld, cmMakefile* mf); ~cmInstallExportGenerator(); diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index cc62c4b..21d3c2a 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -126,6 +126,7 @@ void cmInstallFilesCommand::CreateInstallGenerator() const // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; + bool no_exclude_from_all = false; std::string no_component = this->Makefile->GetSafeDefinition( "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector<std::string> no_configurations; @@ -135,7 +136,8 @@ void cmInstallFilesCommand::CreateInstallGenerator() const new cmInstallFilesGenerator(this->Makefile, this->Files, destination.c_str(), false, no_permissions, no_configurations, - no_component.c_str(), message, no_rename)); + no_component.c_str(), message, + no_exclude_from_all, no_rename)); } diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index ec02bc7..74ac462 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -24,9 +24,11 @@ cmInstallFilesGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* rename, bool optional): - cmInstallGenerator(dest, configurations, component, message), + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), Makefile(mf), Files(files), Programs(programs), FilePermissions(file_permissions), diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index 871335c..5e2f201 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -29,6 +29,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* rename, bool optional = false); virtual ~cmInstallFilesGenerator(); diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 3be2c2b..4147de6 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -19,11 +19,13 @@ ::cmInstallGenerator(const char* destination, std::vector<std::string> const& configurations, const char* component, - MessageLevel message): + MessageLevel message, + bool exclude_from_all): cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations), Destination(destination? destination:""), Component(component? component:""), - Message(message) + Message(message), + ExcludeFromAll(exclude_from_all) { } @@ -145,12 +147,15 @@ void cmInstallGenerator //---------------------------------------------------------------------------- std::string -cmInstallGenerator::CreateComponentTest(const char* component) +cmInstallGenerator::CreateComponentTest(const char* component, bool exclude_from_all) { - std::string result = "NOT CMAKE_INSTALL_COMPONENT OR " - "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \""; + std::string result = "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \""; result += component; result += "\""; + if(!exclude_from_all) + { + result += " OR NOT CMAKE_INSTALL_COMPONENT"; + } return result; } @@ -162,7 +167,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os) // Begin this block of installation. std::string component_test = - this->CreateComponentTest(this->Component.c_str()); + this->CreateComponentTest(this->Component.c_str(),this->ExcludeFromAll); os << indent << "if(" << component_test << ")\n"; // Generate the script possibly with per-configuration code. diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index c89ab8a..5073282 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -36,7 +36,8 @@ class cmInstallGenerator: public cmScriptGenerator cmInstallGenerator(const char* destination, std::vector<std::string> const& configurations, const char* component, - MessageLevel message); + MessageLevel message, + bool exclude_from_all); virtual ~cmInstallGenerator(); void AddInstallRule( @@ -66,12 +67,14 @@ public: protected: virtual void GenerateScript(std::ostream& os); - std::string CreateComponentTest(const char* component); + std::string CreateComponentTest(const char* component, + bool exclude_from_all); // Information shared by most generator types. std::string Destination; std::string Component; MessageLevel Message; + bool ExcludeFromAll; }; #endif diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 3a0a322..4dc1f3a 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -86,6 +86,7 @@ void cmInstallProgramsCommand::FinalPass() // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; + bool no_exclude_from_all = false; std::string no_component = this->Makefile->GetSafeDefinition( "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector<std::string> no_configurations; @@ -95,7 +96,8 @@ void cmInstallProgramsCommand::FinalPass() new cmInstallFilesGenerator(this->Makefile, this->Files, destination.c_str(), true, no_permissions, no_configurations, - no_component.c_str(), message, no_rename)); + no_component.c_str(), message, + no_exclude_from_all, no_rename)); } /** diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index bcfbe63..72e4b61 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -14,8 +14,9 @@ //---------------------------------------------------------------------------- cmInstallScriptGenerator ::cmInstallScriptGenerator(const char* script, bool code, - const char* component) : - cmInstallGenerator(0, std::vector<std::string>(), component, MessageDefault), + const char* component, bool exclude_from_all) : + cmInstallGenerator(0, std::vector<std::string>(), component, MessageDefault, + exclude_from_all), Script(script), Code(code) { } @@ -31,7 +32,7 @@ void cmInstallScriptGenerator::GenerateScript(std::ostream& os) { Indent indent; std::string component_test = - this->CreateComponentTest(this->Component.c_str()); + this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll); os << indent << "if(" << component_test << ")\n"; if(this->Code) diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h index 54a7b21..7e7c0c8 100644 --- a/Source/cmInstallScriptGenerator.h +++ b/Source/cmInstallScriptGenerator.h @@ -21,7 +21,7 @@ class cmInstallScriptGenerator: public cmInstallGenerator { public: cmInstallScriptGenerator(const char* script, bool code, - const char* component); + const char* component, bool exclude_from_all); virtual ~cmInstallScriptGenerator(); protected: diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c9624c8..4fba1a0 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -26,9 +26,12 @@ cmInstallTargetGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, - bool optional): - cmInstallGenerator(dest, configurations, component, message), Target(&t), - ImportLibrary(implib), FilePermissions(file_permissions), Optional(optional) + bool exclude_from_all, + bool optional): + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), + Target(&t), ImportLibrary(implib), + FilePermissions(file_permissions), Optional(optional) { this->ActionsPerConfig = true; this->NamelinkMode = NamelinkModeNone; diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 8cf72f9..de16601 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -28,6 +28,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, bool optional ); virtual ~cmInstallTargetGenerator(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 9c04109..9c60424 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3034,7 +3034,7 @@ cmInstallTargetGenerator( t, dest, implib, "", std::vector<std::string>(), "Unspecified", cmInstallGenerator::SelectMessageLevel(t.GetMakefile()), - false) {} + false, false) {} }; //---------------------------------------------------------------------------- @@ -3057,7 +3057,7 @@ cmLocalGenerator // Include the user-specified pre-install script for this target. if(const char* preinstall = l->second.GetProperty("PRE_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(preinstall, false, 0); + cmInstallScriptGenerator g(preinstall, false, 0, false); g.Generate(os, config, configurationTypes); } @@ -3118,7 +3118,7 @@ cmLocalGenerator // Include the user-specified post-install script for this target. if(const char* postinstall = l->second.GetProperty("POST_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(postinstall, false, 0); + cmInstallScriptGenerator g(postinstall, false, 0, false); g.Generate(os, config, configurationTypes); } } correction_cmake_3_4_2_install_exclude.patch [^] (23,369 bytes) 2016-01-29 03:34 [Show Content] [Hide Content] diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 3c76bd6..23943c3 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -31,7 +31,8 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target, impLib, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), message, - args.GetOptional() || forceOpt); + args.GetExcludeFromAll(), + args.GetOptional() || forceOpt); } static cmInstallFilesGenerator* CreateInstallFilesGenerator( @@ -46,7 +47,8 @@ static cmInstallFilesGenerator* CreateInstallFilesGenerator( programs, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), message, - args.GetRename().c_str(), args.GetOptional()); + args.GetExcludeFromAll(), args.GetRename().c_str(), + args.GetOptional()); } @@ -116,6 +118,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) int componentCount = 0; bool doing_script = false; bool doing_code = false; + bool exclude_from_all = false; // Scan the args once for COMPONENT. Only allow one. // @@ -127,6 +130,10 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) ++i; component = args[i]; } + if(args[i] == "EXCLUDE_FROM_ALL") + { + exclude_from_all = true; + } } if(componentCount>1) @@ -174,7 +181,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) } this->Makefile->AddInstallGenerator( new cmInstallScriptGenerator(script.c_str(), false, - component.c_str())); + component.c_str(), exclude_from_all)); } else if(doing_code) { @@ -182,7 +199,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) std::string code = args[i]; this->Makefile->AddInstallGenerator( new cmInstallScriptGenerator(code.c_str(), true, - component.c_str())); + component.c_str(), exclude_from_all)); } } @@ -906,6 +913,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) Doing doing = DoingDirs; bool in_match_mode = false; bool optional = false; + bool exclude_from_all = false; bool message_never = false; std::vector<std::string> dirs; const char* destination = 0; @@ -1087,6 +1095,19 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) // Switch to setting the component property. doing = DoingComponent; } + else if(args[i] == "EXCLUDE_FROM_ALL") + { + if(in_match_mode) + { + std::ostringstream e; + e << args[0] << " does not allow \"" + << args[i] << "\" after PATTERN or REGEX."; + this->SetError(e.str().c_str()); + return false; + } + exclude_from_all = true; + doing = DoingNone; + } else if(doing == DoingDirs) { // Convert this directory to a full path. @@ -1230,6 +1251,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) configurations, component.c_str(), message, + exclude_from_all, literal_args.c_str(), optional)); @@ -1357,7 +1379,8 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), ica.GetConfigurations(), - ica.GetComponent().c_str(), message, fname.c_str(), + ica.GetComponent().c_str(), message, + ica.GetExcludeFromAll(), fname.c_str(), name_space.GetCString(), exportOld.IsEnabled(), this->Makefile); this->Makefile->AddInstallGenerator(exportGenerator); diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 6509501..a127cdb 100644 --- a/Help/command/install.rst +++ b/Help/command/install.rst @@ -45,9 +45,9 @@ is associated, such as "runtime" or "development". During component-specific installation only install rules associated with the given component name will be executed. During a full installation - all components are installed. If ``COMPONENT`` is not provided a - default component "Unspecified" is created. The default component - name may be controlled with the + all components are installed unless marked with EXCLUDE_FROM_ALL. + If ``COMPONENT`` is not provided a default component "Unspecified" is + created. The default component name may be controlled with the :variable:`CMAKE_INSTALL_DEFAULT_COMPONENT_NAME` variable. ``RENAME`` @@ -76,7 +76,8 @@ [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] [COMPONENT <component>] - [OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP] + [OPTIONAL] [EXCLUDE_FROM_ALL] + [NAMELINK_ONLY|NAMELINK_SKIP] ] [...]) The ``TARGETS`` form specifies rules for installing targets from a project. There are five kinds of target files that may be @@ -187,7 +188,7 @@ file itself, call ``install(EXPORT)``, documented below. Installing a target with the :prop_tgt:`EXCLUDE_FROM_ALL` target property -set to ``TRUE`` has undefined behavior. +set to ``TRUE`` in add_executable or add_library has undefined behavior. Installing Files ^^^^^^^^^^^^^^^^ @@ -187,7 +188,7 @@ install(<FILES|PROGRAMS> files... DESTINATION <dir> [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] - [COMPONENT <component>] + [COMPONENT <component>] [EXCLUDE_FROM_ALL] [RENAME <name>] [OPTIONAL]) The ``FILES`` form specifies rules for installing files for a project. @@ -221,7 +223,8 @@ [DIRECTORY_PERMISSIONS permissions...] [USE_SOURCE_PERMISSIONS] [OPTIONAL] [CONFIGURATIONS [Debug|Release|...]] - [COMPONENT <component>] [FILES_MATCHING] + [COMPONENT <component>] [EXCLUDE_FROM_ALL] + [FILES_MATCHING] [[PATTERN <pattern> | REGEX <regex>] [EXCLUDE] [PERMISSIONS permissions...]] [...]) @@ -297,7 +300,7 @@ public: [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] [EXPORT_LINK_INTERFACE_LIBRARIES] - [COMPONENT <component>]) + [COMPONENT <component>] [EXCLUDE_FROM_ALL]) The EXPORT form generates and installs a CMake file containing code to import targets from the installation tree into another project. diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 91ea861..c681416 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -27,14 +27,15 @@ cmInstallCommandArguments::cmInstallCommandArguments( const std::string& defaultComponent) :Parser() ,ArgumentGroup() -,Destination (&Parser, "DESTINATION" , &ArgumentGroup) -,Component (&Parser, "COMPONENT" , &ArgumentGroup) -,Rename (&Parser, "RENAME" , &ArgumentGroup) -,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup) -,Configurations(&Parser, "CONFIGURATIONS", &ArgumentGroup) -,Optional (&Parser, "OPTIONAL" , &ArgumentGroup) -,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup) -,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup) +,Destination (&Parser, "DESTINATION" , &ArgumentGroup) +,Component (&Parser, "COMPONENT" , &ArgumentGroup) +,ExcludeFromAll(&Parser, "EXCLUDE_FROM_ALL", &ArgumentGroup) +,Rename (&Parser, "RENAME" , &ArgumentGroup) +,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup) +,Configurations(&Parser, "CONFIGURATIONS" , &ArgumentGroup) +,Optional (&Parser, "OPTIONAL" , &ArgumentGroup) +,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup) +,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup) ,GenericArguments(0) ,DefaultComponentName(defaultComponent) { @@ -110,6 +111,19 @@ bool cmInstallCommandArguments::GetOptional() const return false; } +bool cmInstallCommandArguments::GetExcludeFromAll() const +{ + if (this->ExcludeFromAll.IsEnabled()) + { + return true; + } + if (this->GenericArguments!=0) + { + return this->GenericArguments->GetExcludeFromAll(); + } + return false; +} + bool cmInstallCommandArguments::GetNamelinkOnly() const { if (this->NamelinkOnly.IsEnabled()) diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h index 90347e6..694f1ed 100644 --- a/Source/cmInstallCommandArguments.h +++ b/Source/cmInstallCommandArguments.h @@ -30,6 +30,7 @@ class cmInstallCommandArguments const std::string& GetDestination() const; const std::string& GetComponent() const; + bool GetExcludeFromAll() const; const std::string& GetRename() const; const std::string& GetPermissions() const; const std::vector<std::string>& GetConfigurations() const; @@ -48,6 +49,7 @@ class cmInstallCommandArguments cmInstallCommandArguments(); // disabled cmCAString Destination; cmCAString Component; + cmCAEnabler ExcludeFromAll; cmCAString Rename; cmCAStringVector Permissions; cmCAStringVector Configurations; diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index ddf7d08..1041788 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -22,9 +22,11 @@ cmInstallDirectoryGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* literal_args, bool optional): - cmInstallGenerator(dest, configurations, component, message), + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), Directories(dirs), FilePermissions(file_permissions), DirPermissions(dir_permissions), LiteralArguments(literal_args), Optional(optional) diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h index d76ef3c..b391e9e 100644 --- a/Source/cmInstallDirectoryGenerator.h +++ b/Source/cmInstallDirectoryGenerator.h @@ -27,6 +27,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* literal_args, bool optional = false); virtual ~cmInstallDirectoryGenerator(); diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 3e9e6ac..481c3c7 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -33,10 +33,12 @@ cmInstallExportGenerator::cmInstallExportGenerator( std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* filename, const char* name_space, bool exportOld, cmMakefile* mf) - :cmInstallGenerator(destination, configurations, component, message) + :cmInstallGenerator(destination, configurations, component, message, + exclude_from_all) ,ExportSet(exportSet) ,FilePermissions(file_permissions) ,FileName(filename) diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index 37b5593..f0ced17 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -31,6 +31,7 @@ public: const std::vector<std::string>& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* filename, const char* name_space, bool exportOld, cmMakefile* mf); ~cmInstallExportGenerator(); diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index cc62c4b..21d3c2a 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -126,6 +126,7 @@ void cmInstallFilesCommand::CreateInstallGenerator() const // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; + bool no_exclude_from_all = false; std::string no_component = this->Makefile->GetSafeDefinition( "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector<std::string> no_configurations; @@ -135,7 +136,8 @@ void cmInstallFilesCommand::CreateInstallGenerator() const new cmInstallFilesGenerator(this->Makefile, this->Files, destination.c_str(), false, no_permissions, no_configurations, - no_component.c_str(), message, no_rename)); + no_component.c_str(), message, + no_exclude_from_all, no_rename)); } diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index ec02bc7..74ac462 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -24,9 +24,11 @@ cmInstallFilesGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* rename, bool optional): - cmInstallGenerator(dest, configurations, component, message), + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), Makefile(mf), Files(files), Programs(programs), FilePermissions(file_permissions), diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index 871335c..5e2f201 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -29,6 +29,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* rename, bool optional = false); virtual ~cmInstallFilesGenerator(); diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 3be2c2b..4147de6 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -19,11 +19,13 @@ ::cmInstallGenerator(const char* destination, std::vector<std::string> const& configurations, const char* component, - MessageLevel message): + MessageLevel message, + bool exclude_from_all): cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations), Destination(destination? destination:""), Component(component? component:""), - Message(message) + Message(message), + ExcludeFromAll(exclude_from_all) { } @@ -145,12 +147,15 @@ void cmInstallGenerator //---------------------------------------------------------------------------- std::string -cmInstallGenerator::CreateComponentTest(const char* component) +cmInstallGenerator::CreateComponentTest(const char* component, bool exclude_from_all) { - std::string result = "NOT CMAKE_INSTALL_COMPONENT OR " - "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \""; + std::string result = "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \""; result += component; result += "\""; + if(!exclude_from_all) + { + result += " OR NOT CMAKE_INSTALL_COMPONENT"; + } return result; } @@ -162,7 +167,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os) // Begin this block of installation. std::string component_test = - this->CreateComponentTest(this->Component.c_str()); + this->CreateComponentTest(this->Component.c_str(),this->ExcludeFromAll); os << indent << "if(" << component_test << ")\n"; // Generate the script possibly with per-configuration code. diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index c89ab8a..5073282 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -36,7 +36,8 @@ class cmInstallGenerator: public cmScriptGenerator cmInstallGenerator(const char* destination, std::vector<std::string> const& configurations, const char* component, - MessageLevel message); + MessageLevel message, + bool exclude_from_all); virtual ~cmInstallGenerator(); void AddInstallRule( @@ -66,12 +67,14 @@ public: protected: virtual void GenerateScript(std::ostream& os); - std::string CreateComponentTest(const char* component); + std::string CreateComponentTest(const char* component, + bool exclude_from_all); // Information shared by most generator types. std::string Destination; std::string Component; MessageLevel Message; + bool ExcludeFromAll; }; #endif diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 3a0a322..4dc1f3a 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -86,6 +86,7 @@ void cmInstallProgramsCommand::FinalPass() // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; + bool no_exclude_from_all = false; std::string no_component = this->Makefile->GetSafeDefinition( "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector<std::string> no_configurations; @@ -95,7 +96,8 @@ void cmInstallProgramsCommand::FinalPass() new cmInstallFilesGenerator(this->Makefile, this->Files, destination.c_str(), true, no_permissions, no_configurations, - no_component.c_str(), message, no_rename)); + no_component.c_str(), message, + no_exclude_from_all, no_rename)); } /** diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index bcfbe63..72e4b61 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -14,8 +14,9 @@ //---------------------------------------------------------------------------- cmInstallScriptGenerator ::cmInstallScriptGenerator(const char* script, bool code, - const char* component) : - cmInstallGenerator(0, std::vector<std::string>(), component, MessageDefault), + const char* component, bool exclude_from_all) : + cmInstallGenerator(0, std::vector<std::string>(), component, MessageDefault, + exclude_from_all), Script(script), Code(code) { } @@ -31,7 +32,7 @@ void cmInstallScriptGenerator::GenerateScript(std::ostream& os) { Indent indent; std::string component_test = - this->CreateComponentTest(this->Component.c_str()); + this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll); os << indent << "if(" << component_test << ")\n"; if(this->Code) diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h index 54a7b21..7e7c0c8 100644 --- a/Source/cmInstallScriptGenerator.h +++ b/Source/cmInstallScriptGenerator.h @@ -21,7 +21,7 @@ class cmInstallScriptGenerator: public cmInstallGenerator { public: cmInstallScriptGenerator(const char* script, bool code, - const char* component); + const char* component, bool exclude_from_all); virtual ~cmInstallScriptGenerator(); protected: diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c9624c8..4fba1a0 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -26,9 +26,12 @@ cmInstallTargetGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, - bool optional): - cmInstallGenerator(dest, configurations, component, message), Target(&t), - ImportLibrary(implib), FilePermissions(file_permissions), Optional(optional) + bool exclude_from_all, + bool optional): + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), + Target(&t), ImportLibrary(implib), + FilePermissions(file_permissions), Optional(optional) { this->ActionsPerConfig = true; this->NamelinkMode = NamelinkModeNone; diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 8cf72f9..de16601 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -28,6 +28,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, bool optional ); virtual ~cmInstallTargetGenerator(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 9c04109..9c60424 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3034,7 +3034,7 @@ cmInstallTargetGenerator( t, dest, implib, "", std::vector<std::string>(), "Unspecified", cmInstallGenerator::SelectMessageLevel(t.GetMakefile()), - false) {} + false, false) {} }; //---------------------------------------------------------------------------- @@ -3057,7 +3057,7 @@ cmLocalGenerator // Include the user-specified pre-install script for this target. if(const char* preinstall = l->second.GetProperty("PRE_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(preinstall, false, 0); + cmInstallScriptGenerator g(preinstall, false, 0, false); g.Generate(os, config, configurationTypes); } @@ -3118,7 +3118,7 @@ cmLocalGenerator // Include the user-specified post-install script for this target. if(const char* postinstall = l->second.GetProperty("POST_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(postinstall, false, 0); + cmInstallScriptGenerator g(postinstall, false, 0, false); g.Generate(os, config, configurationTypes); } } correction2_cmake_3_4_2_install_exclude.patch [^] (22,995 bytes) 2016-01-29 03:42 [Show Content] [Hide Content] diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 3c76bd6..23943c3 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -33,7 +33,8 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target, impLib, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), message, - args.GetOptional() || forceOpt); + args.GetExcludeFromAll(), + args.GetOptional() || forceOpt); } static cmInstallFilesGenerator* CreateInstallFilesGenerator( @@ -48,7 +49,8 @@ static cmInstallFilesGenerator* CreateInstallFilesGenerator( programs, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), message, - args.GetRename().c_str(), args.GetOptional()); + args.GetExcludeFromAll(), args.GetRename().c_str(), + args.GetOptional()); } @@ -117,6 +119,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) int componentCount = 0; bool doing_script = false; bool doing_code = false; + bool exclude_from_all = false; // Scan the args once for COMPONENT. Only allow one. // @@ -128,6 +131,10 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) ++i; component = args[i]; } + if(args[i] == "EXCLUDE_FROM_ALL") + { + exclude_from_all = true; + } } if(componentCount>1) @@ -175,7 +182,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) } this->Makefile->AddInstallGenerator( new cmInstallScriptGenerator(script.c_str(), false, - component.c_str())); + component.c_str(), exclude_from_all)); } else if(doing_code) { @@ -183,7 +200,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) std::string code = args[i]; this->Makefile->AddInstallGenerator( new cmInstallScriptGenerator(code.c_str(), true, - component.c_str())); + component.c_str(), exclude_from_all)); } } @@ -949,6 +956,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) Doing doing = DoingDirs; bool in_match_mode = false; bool optional = false; + bool exclude_from_all = false; bool message_never = false; std::vector<std::string> dirs; const char* destination = 0; @@ -1130,6 +1138,19 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) // Switch to setting the component property. doing = DoingComponent; } + else if(args[i] == "EXCLUDE_FROM_ALL") + { + if(in_match_mode) + { + std::ostringstream e; + e << args[0] << " does not allow \"" + << args[i] << "\" after PATTERN or REGEX."; + this->SetError(e.str().c_str()); + return false; + } + exclude_from_all = true; + doing = DoingNone; + } else if(doing == DoingDirs) { // Convert this directory to a full path. @@ -1273,6 +1294,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) configurations, component.c_str(), message, + exclude_from_all, literal_args.c_str(), optional)); @@ -1400,7 +1422,8 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), ica.GetConfigurations(), - ica.GetComponent().c_str(), message, fname.c_str(), + ica.GetComponent().c_str(), message, + ica.GetExcludeFromAll(), fname.c_str(), name_space.GetCString(), exportOld.IsEnabled()); this->Makefile->AddInstallGenerator(exportGenerator); diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 6509501..a127cdb 100644 --- a/Help/command/install.rst +++ b/Help/command/install.rst @@ -45,9 +45,9 @@ is associated, such as "runtime" or "development". During component-specific installation only install rules associated with the given component name will be executed. During a full installation - all components are installed. If ``COMPONENT`` is not provided a - default component "Unspecified" is created. The default component - name may be controlled with the + all components are installed unless marked with EXCLUDE_FROM_ALL. + If ``COMPONENT`` is not provided a default component "Unspecified" is + created. The default component name may be controlled with the :variable:`CMAKE_INSTALL_DEFAULT_COMPONENT_NAME` variable. ``RENAME`` @@ -76,7 +76,8 @@ [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] [COMPONENT <component>] - [OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP] + [OPTIONAL] [EXCLUDE_FROM_ALL] + [NAMELINK_ONLY|NAMELINK_SKIP] ] [...]) The ``TARGETS`` form specifies rules for installing targets from a project. There are five kinds of target files that may be @@ -187,7 +188,7 @@ file itself, call ``install(EXPORT)``, documented below. Installing a target with the :prop_tgt:`EXCLUDE_FROM_ALL` target property -set to ``TRUE`` has undefined behavior. +set to ``TRUE`` in add_executable or add_library has undefined behavior. Installing Files ^^^^^^^^^^^^^^^^ @@ -187,7 +188,7 @@ install(<FILES|PROGRAMS> files... DESTINATION <dir> [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] - [COMPONENT <component>] + [COMPONENT <component>] [EXCLUDE_FROM_ALL] [RENAME <name>] [OPTIONAL]) The ``FILES`` form specifies rules for installing files for a project. @@ -221,7 +223,8 @@ [DIRECTORY_PERMISSIONS permissions...] [USE_SOURCE_PERMISSIONS] [OPTIONAL] [CONFIGURATIONS [Debug|Release|...]] - [COMPONENT <component>] [FILES_MATCHING] + [COMPONENT <component>] [EXCLUDE_FROM_ALL] + [FILES_MATCHING] [[PATTERN <pattern> | REGEX <regex>] [EXCLUDE] [PERMISSIONS permissions...]] [...]) @@ -297,7 +300,7 @@ public: [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] [EXPORT_LINK_INTERFACE_LIBRARIES] - [COMPONENT <component>]) + [COMPONENT <component>] [EXCLUDE_FROM_ALL]) The EXPORT form generates and installs a CMake file containing code to import targets from the installation tree into another project. diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 91ea861..c681416 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -27,14 +27,15 @@ cmInstallCommandArguments::cmInstallCommandArguments( const std::string& defaultComponent) :Parser() ,ArgumentGroup() -,Destination (&Parser, "DESTINATION" , &ArgumentGroup) -,Component (&Parser, "COMPONENT" , &ArgumentGroup) -,Rename (&Parser, "RENAME" , &ArgumentGroup) -,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup) -,Configurations(&Parser, "CONFIGURATIONS", &ArgumentGroup) -,Optional (&Parser, "OPTIONAL" , &ArgumentGroup) -,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup) -,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup) +,Destination (&Parser, "DESTINATION" , &ArgumentGroup) +,Component (&Parser, "COMPONENT" , &ArgumentGroup) +,ExcludeFromAll(&Parser, "EXCLUDE_FROM_ALL", &ArgumentGroup) +,Rename (&Parser, "RENAME" , &ArgumentGroup) +,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup) +,Configurations(&Parser, "CONFIGURATIONS" , &ArgumentGroup) +,Optional (&Parser, "OPTIONAL" , &ArgumentGroup) +,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup) +,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup) ,GenericArguments(0) ,DefaultComponentName(defaultComponent) { @@ -110,6 +111,19 @@ bool cmInstallCommandArguments::GetOptional() const return false; } +bool cmInstallCommandArguments::GetExcludeFromAll() const +{ + if (this->ExcludeFromAll.IsEnabled()) + { + return true; + } + if (this->GenericArguments!=0) + { + return this->GenericArguments->GetExcludeFromAll(); + } + return false; +} + bool cmInstallCommandArguments::GetNamelinkOnly() const { if (this->NamelinkOnly.IsEnabled()) diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h index 90347e6..694f1ed 100644 --- a/Source/cmInstallCommandArguments.h +++ b/Source/cmInstallCommandArguments.h @@ -30,6 +30,7 @@ class cmInstallCommandArguments const std::string& GetDestination() const; const std::string& GetComponent() const; + bool GetExcludeFromAll() const; const std::string& GetRename() const; const std::string& GetPermissions() const; const std::vector<std::string>& GetConfigurations() const; @@ -48,6 +49,7 @@ class cmInstallCommandArguments cmInstallCommandArguments(); // disabled cmCAString Destination; cmCAString Component; + cmCAEnabler ExcludeFromAll; cmCAString Rename; cmCAStringVector Permissions; cmCAStringVector Configurations; diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index ddf7d08..1041788 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -24,9 +24,11 @@ cmInstallDirectoryGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* literal_args, bool optional): - cmInstallGenerator(dest, configurations, component, message), + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), LocalGenerator(0), Directories(dirs), FilePermissions(file_permissions), DirPermissions(dir_permissions), diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h index d76ef3c..b391e9e 100644 --- a/Source/cmInstallDirectoryGenerator.h +++ b/Source/cmInstallDirectoryGenerator.h @@ -27,6 +27,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* literal_args, bool optional = false); virtual ~cmInstallDirectoryGenerator(); diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 3e9e6ac..481c3c7 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -33,9 +33,11 @@ cmInstallExportGenerator::cmInstallExportGenerator( std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* filename, const char* name_space, bool exportOld) - :cmInstallGenerator(destination, configurations, component, message) + :cmInstallGenerator(destination, configurations, component, message, + exclude_from_all) ,ExportSet(exportSet) ,FilePermissions(file_permissions) ,FileName(filename) diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index 37b5593..f0ced17 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -31,6 +31,7 @@ public: const std::vector<std::string>& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* filename, const char* name_space, bool exportOld); ~cmInstallExportGenerator(); diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index cc62c4b..21d3c2a 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -122,6 +122,7 @@ void cmInstallFilesCommand::CreateInstallGenerator() const // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; + bool no_exclude_from_all = false; std::string no_component = this->Makefile->GetSafeDefinition( "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector<std::string> no_configurations; @@ -131,7 +132,8 @@ void cmInstallFilesCommand::CreateInstallGenerator() const new cmInstallFilesGenerator(this->Files, destination.c_str(), false, no_permissions, no_configurations, - no_component.c_str(), message, no_rename)); + no_component.c_str(), message, + no_exclude_from_all, no_rename)); } diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index ec02bc7..74ac462 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -24,9 +24,11 @@ cmInstallFilesGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* rename, bool optional): - cmInstallGenerator(dest, configurations, component, message), + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), LocalGenerator(0), Files(files), FilePermissions(file_permissions), diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index 871335c..5e2f201 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -26,6 +26,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, const char* rename, bool optional = false); virtual ~cmInstallFilesGenerator(); diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 3be2c2b..4147de6 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -19,11 +19,13 @@ ::cmInstallGenerator(const char* destination, std::vector<std::string> const& configurations, const char* component, - MessageLevel message): + MessageLevel message, + bool exclude_from_all): cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations), Destination(destination? destination:""), Component(component? component:""), - Message(message) + Message(message), + ExcludeFromAll(exclude_from_all) { } @@ -146,12 +148,15 @@ void cmInstallGenerator //---------------------------------------------------------------------------- std::string -cmInstallGenerator::CreateComponentTest(const char* component) +cmInstallGenerator::CreateComponentTest(const char* component, bool exclude_from_all) { - std::string result = "NOT CMAKE_INSTALL_COMPONENT OR " - "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \""; + std::string result = "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \""; result += component; result += "\""; + if(!exclude_from_all) + { + result += " OR NOT CMAKE_INSTALL_COMPONENT"; + } return result; } @@ -163,7 +168,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os) // Begin this block of installation. std::string component_test = - this->CreateComponentTest(this->Component.c_str()); + this->CreateComponentTest(this->Component.c_str(),this->ExcludeFromAll); os << indent << "if(" << component_test << ")\n"; // Generate the script possibly with per-configuration code. diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index c89ab8a..5073282 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -36,7 +36,8 @@ class cmInstallGenerator: public cmScriptGenerator cmInstallGenerator(const char* destination, std::vector<std::string> const& configurations, const char* component, - MessageLevel message); + MessageLevel message, + bool exclude_from_all); virtual ~cmInstallGenerator(); void AddInstallRule( @@ -67,12 +68,14 @@ public: protected: virtual void GenerateScript(std::ostream& os); - std::string CreateComponentTest(const char* component); + std::string CreateComponentTest(const char* component, + bool exclude_from_all); // Information shared by most generator types. std::string Destination; std::string Component; MessageLevel Message; + bool ExcludeFromAll; }; #endif diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 3a0a322..4dc1f3a 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -85,6 +85,7 @@ void cmInstallProgramsCommand::FinalPass() // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; + bool no_exclude_from_all = false; std::string no_component = this->Makefile->GetSafeDefinition( "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector<std::string> no_configurations; @@ -94,7 +95,8 @@ void cmInstallProgramsCommand::FinalPass() new cmInstallFilesGenerator(this->Files, destination.c_str(), true, no_permissions, no_configurations, - no_component.c_str(), message, no_rename)); + no_component.c_str(), message, + no_exclude_from_all, no_rename)); } /** diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index bcfbe63..72e4b61 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -14,8 +14,9 @@ //---------------------------------------------------------------------------- cmInstallScriptGenerator ::cmInstallScriptGenerator(const char* script, bool code, - const char* component) : - cmInstallGenerator(0, std::vector<std::string>(), component, MessageDefault), + const char* component, bool exclude_from_all) : + cmInstallGenerator(0, std::vector<std::string>(), component, MessageDefault, + exclude_from_all), Script(script), Code(code) { } @@ -31,7 +32,7 @@ void cmInstallScriptGenerator::GenerateScript(std::ostream& os) { Indent indent; std::string component_test = - this->CreateComponentTest(this->Component.c_str()); + this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll); os << indent << "if(" << component_test << ")\n"; if(this->Code) diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h index 54a7b21..7e7c0c8 100644 --- a/Source/cmInstallScriptGenerator.h +++ b/Source/cmInstallScriptGenerator.h @@ -21,7 +21,7 @@ class cmInstallScriptGenerator: public cmInstallGenerator { public: cmInstallScriptGenerator(const char* script, bool code, - const char* component); + const char* component, bool exclude_from_all); virtual ~cmInstallScriptGenerator(); protected: diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c9624c8..4fba1a0 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -30,8 +30,10 @@ cmInstallTargetGenerator std::vector<std::string> const& configurations, const char* component, MessageLevel message, - bool optional): - cmInstallGenerator(dest, configurations, component, message), + bool exclude_from_all, + bool optional): + cmInstallGenerator(dest, configurations, component, message, + exclude_from_all), TargetName(targetName), Target(0), FilePermissions(file_permissions), diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 8cf72f9..de16601 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -29,6 +29,7 @@ public: std::vector<std::string> const& configurations, const char* component, MessageLevel message, + bool exclude_from_all, bool optional ); virtual ~cmInstallTargetGenerator(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 9c04109..9c60424 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2471,7 +2471,7 @@ cmInstallTargetGenerator( t, dest, implib, "", std::vector<std::string>(), "Unspecified", cmInstallGenerator::SelectMessageLevel(lg->GetMakefile()), - false) + false, false) { this->Compute(lg); } @@ -2497,7 +2497,7 @@ cmLocalGenerator // Include the user-specified pre-install script for this target. if(const char* preinstall = l->second.GetProperty("PRE_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(preinstall, false, 0); + cmInstallScriptGenerator g(preinstall, false, 0, false); g.Generate(os, config, configurationTypes); } @@ -2558,7 +2558,7 @@ cmLocalGenerator // Include the user-specified post-install script for this target. if(const char* postinstall = l->second.GetProperty("POST_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(postinstall, false, 0); + cmInstallScriptGenerator g(postinstall, false, 0, false); g.Generate(os, config, configurationTypes); } } | ||||||||
Relationships | |
Relationships |
Notes | |
(0035899) Brad King (manager) 2014-05-19 09:29 |
Interesting proposal. I think a change along these lines could also improve a case mentioned in the install() command documentation: http://www.cmake.org/cmake/help/v3.0/command/install.html [^] "Installing a target with the EXCLUDE_FROM_ALL target property set to TRUE has undefined behavior." That refers to the use case when a target build is EXCLUDE_FROM_ALL and so is not created by "make" and may then be missing when "make install" is issued. This looks intended to support the same use case by making the install rule excluded from the default installation too. Perhaps install(TARGETS) should activate ExcludeFromAll when the corresponding property is set on the target. |
(0039154) Nick Lewis (reporter) 2015-07-16 12:22 |
Rebased patch on 3.2.2. Still no automatic setting of install(EXCLUDE_FROM_ALL) based on the setting of add_executable(EXCLUDE_FROM_ALL) though |
(0039156) Brad King (manager) 2015-07-17 09:49 |
Thanks for working on this. I think it will be better discussed on the cmake-developers mailing list: http://www.cmake.org/mailman/listinfo/cmake-developers [^] That allows for design discussion with a broader audience than the issue tracker. |
(0040353) Nick Lewis (reporter) 2016-01-29 03:46 |
correction2_cmake_3_4_2_install_exclude.patch is the correct patch for cmake 3.4.2 - please ignore cmake_3_4_2_install_exclude.patch and correction_cmake_3_4_2_install_exclude.patch (or delete them) |
(0040356) Brad King (manager) 2016-01-29 08:44 |
Re 0014921:0040353: Thanks for updating the patch again, but please see 0014921:0039156. Also, the test suite will need to be updated to cover the feature. |
(0040359) Nick Lewis (reporter) 2016-01-29 09:46 |
Re 0014921:0039156 - The proposal was put on the cmake-developers mailing list as follows: MIME-Version: 1.0 Received: by 10.140.102.239 with HTTP; Mon, 20 Jul 2015 00:36:10 -0700 (PDT) In-Reply-To: <moe4e0$oh2$1@ger.gmane.org> References: <CAKtwun52wXV5Gc65vqk7wDtBH06+5F3HLsERT+dD3u5pi=UaiQ@mail.gmail.com> <moe4e0$oh2$1@ger.gmane.org> Date: Mon, 20 Jul 2015 08:36:10 +0100 Delivered-To: nick.lewis@usa.g4s.com Message-ID: <CAKtwun6jhOH_6Wy=CeDgoEjZCXCkFnmedjgtWsAU6-hNAmNQnQ@mail.gmail.com> Subject: Re: [cmake-developers] install(EXCLUDE_FROM_ALL) new feature - request for comment From: Nick Lewis <nick.lewis@usa.g4s.com> To: Stephen Kelly <steveire@gmail.com> Content-Type: multipart/alternative; boundary=94eb2c05fdb0725fbb051b49970f --94eb2c05fdb0725fbb051b49970f Content-Type: text/plain; charset=UTF-8 There is currently no way to exclude a component install() from a full installation. Current workarounds using OPTIONAL do not work reliably because they depend on previous builds and on the order of the execution of the build and install commands for the components and the default target Let us take an example of a project that has some tests in a component that need to be installed into a dedicated test package. The user expectation is that the result could be achieved by typing the following: make make tests make install DESTDIR=/testpkgs make install-tests However this results in test components in the default installation as well as the testpkg Judging by questions on the mail list, users typically try to overcome this problem by adding the EXCLUDE_FROM_ALL keyword to the install() command but this is currently unsupported. The patch uploaded to the issue tracker provides support for it. Brad has further suggested that the install(EXCLUDE_FROM_ALL) should be implicitly set when installing components built with add_executable/library(EXCLUDE_FROM_ALL) I welcome your views on these ideas Best Regards Nick |
(0040360) Brad King (manager) 2016-01-29 09:55 |
Yes, sorry, I see it in the archives: http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/13700 [^] |
(0040361) Brad King (manager) 2016-01-29 09:57 |
Re 0014921:0040360: Actually, your message posted in 0014921:0040359 was addressed privately to Stephen Kelly and never made it to the list. Anyway, I think the patch is a good start. Please revise it to update the test suite to cover the feature and then start a new thread on the list with the proposal text and patch together. Thanks! |
(0040435) Brad King (manager) 2016-02-03 14:32 |
Thanks for starting the new thread. For reference, it is here: http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/15634 [^] |
(0040463) Brad King (manager) 2016-02-10 11:23 |
Changes from the thread linked in 0014921:0040435 are now in 'master': install: Add EXCLUDE_FROM_ALL option https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=18ce97c4 [^] Tests: Add cases for install() command EXCLUDE_FROM_ALL option https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d321c196 [^] Help: Add notes for topic 'install-EXCLUDE_FROM_ALL' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=586e56d0 [^] |
(0041258) Kitware Robot (administrator) 2016-06-10 14:21 |
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2014-05-19 04:47 | Nick Lewis | New Issue | |
2014-05-19 04:47 | Nick Lewis | File Added: cmake_install_exclude.patch | |
2014-05-19 09:29 | Brad King | Note Added: 0035899 | |
2015-07-16 12:20 | Nick Lewis | File Added: cmake_3_2_2_install_exclude.patch | |
2015-07-16 12:22 | Nick Lewis | Note Added: 0039154 | |
2015-07-17 09:49 | Brad King | Note Added: 0039156 | |
2016-01-29 03:29 | Nick Lewis | File Added: cmake_3_4_2_install_exclude.patch | |
2016-01-29 03:34 | Nick Lewis | File Added: correction_cmake_3_4_2_install_exclude.patch | |
2016-01-29 03:42 | Nick Lewis | File Added: correction2_cmake_3_4_2_install_exclude.patch | |
2016-01-29 03:46 | Nick Lewis | Note Added: 0040353 | |
2016-01-29 08:44 | Brad King | Note Added: 0040356 | |
2016-01-29 09:46 | Nick Lewis | Note Added: 0040359 | |
2016-01-29 09:55 | Brad King | Note Added: 0040360 | |
2016-01-29 09:57 | Brad King | Note Added: 0040361 | |
2016-02-03 14:32 | Brad King | Note Added: 0040435 | |
2016-02-10 11:23 | Brad King | Note Added: 0040463 | |
2016-02-10 11:24 | Brad King | Status | new => resolved |
2016-02-10 11:24 | Brad King | Resolution | open => fixed |
2016-02-10 11:24 | Brad King | Fixed in Version | => CMake 3.6 |
2016-02-10 11:24 | Brad King | Target Version | => CMake 3.6 |
2016-06-10 14:21 | Kitware Robot | Note Added: 0041258 | |
2016-06-10 14:21 | Kitware Robot | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |