diff options
author | Nick Lewis <nick.lewis@amag.com> | 2016-02-01 10:01:39 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-02-04 14:16:56 (GMT) |
commit | 18ce97c4a20b7da4e11006ad80f17cb55e128db1 (patch) | |
tree | 411ffa3d6c2fa573a2b69be606810859b72d729f /Source/cmInstallCommand.cxx | |
parent | bfd1b3aabaa9a2ec46ca6ebfa50d56dfa8846fb3 (diff) | |
download | CMake-18ce97c4a20b7da4e11006ad80f17cb55e128db1.zip CMake-18ce97c4a20b7da4e11006ad80f17cb55e128db1.tar.gz CMake-18ce97c4a20b7da4e11006ad80f17cb55e128db1.tar.bz2 |
install: Add EXCLUDE_FROM_ALL option (#14921)
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.
Add an EXCLUDE_FROM_ALL option to the install() command to tell it that
the installation rule should not be included unless its component is
explicitly specified for installation.
Diffstat (limited to 'Source/cmInstallCommand.cxx')
-rw-r--r-- | Source/cmInstallCommand.cxx | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 15a83ee..aa92d74 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -33,6 +33,7 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target, impLib, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), message, + args.GetExcludeFromAll(), args.GetOptional() || forceOpt); } @@ -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 +190,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)); @@ -1401,7 +1423,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); |