mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 14:08:35 +08:00
EXCLUDE_FROM_ALL: Don't warn if installing target excluded from all
The original warning pre-dates support for install components. There are now legitimate scenarios where an install(TARGETS) command may list a target that is excluded from all, e.g. hierarchical projects that will never install the component such a target belongs to. Fixes: #18938
This commit is contained in:
@@ -6,8 +6,16 @@ Exclude the target from the all target.
|
|||||||
A property on a target that indicates if the target is excluded from
|
A property on a target that indicates if the target is excluded from
|
||||||
the default build target. If it is not, then with a Makefile for
|
the default build target. If it is not, then with a Makefile for
|
||||||
example typing make will cause this target to be built. The same
|
example typing make will cause this target to be built. The same
|
||||||
concept applies to the default build of other generators. Installing
|
concept applies to the default build of other generators.
|
||||||
a target with EXCLUDE_FROM_ALL set to true has undefined behavior.
|
|
||||||
|
With ``EXCLUDE_FROM_ALL`` set to false or not set at all, the target
|
||||||
|
will be brought up to date as part of doing a ``make install`` or its
|
||||||
|
equivalent for the CMake generator being used. If a target has
|
||||||
|
``EXCLUDE_FROM_ALL`` set to true, then any attempt to install that
|
||||||
|
target has undefined behavior. Note that such a target can still safely
|
||||||
|
be listed in an :command:`install(TARGETS)` command as long as the install
|
||||||
|
components the target belongs to are not part of the set of components
|
||||||
|
that anything tries to install.
|
||||||
|
|
||||||
This property is enabled by default for targets that are created in
|
This property is enabled by default for targets that are created in
|
||||||
directories that have :prop_dir:`EXCLUDE_FROM_ALL` set to ``TRUE``.
|
directories that have :prop_dir:`EXCLUDE_FROM_ALL` set to ``TRUE``.
|
||||||
|
@@ -370,3 +370,7 @@ Other Changes
|
|||||||
:variable:`CPACK_DEBIAN_ARCHIVE_TYPE` variable, because ``dpkg`` has
|
:variable:`CPACK_DEBIAN_ARCHIVE_TYPE` variable, because ``dpkg`` has
|
||||||
never supported the PAX tar format. The ``paxr`` value will be mapped
|
never supported the PAX tar format. The ``paxr`` value will be mapped
|
||||||
to ``gnutar`` and a deprecation message emitted.
|
to ``gnutar`` and a deprecation message emitted.
|
||||||
|
|
||||||
|
* CMake no longer issues a warning if a target listed in an
|
||||||
|
:command:`install(TARGETS)` command has its :prop_tgt:`EXCLUDE_FROM_ALL`
|
||||||
|
property set to true.
|
||||||
|
@@ -41,22 +41,6 @@ cmInstallTargetGenerator::cmInstallTargetGenerator(
|
|||||||
|
|
||||||
cmInstallTargetGenerator::~cmInstallTargetGenerator() = default;
|
cmInstallTargetGenerator::~cmInstallTargetGenerator() = default;
|
||||||
|
|
||||||
void cmInstallTargetGenerator::GenerateScript(std::ostream& os)
|
|
||||||
{
|
|
||||||
// Warn if installing an exclude-from-all target.
|
|
||||||
if (this->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
|
|
||||||
std::ostringstream msg;
|
|
||||||
msg << "WARNING: Target \"" << this->Target->GetName()
|
|
||||||
<< "\" has EXCLUDE_FROM_ALL set and will not be built by default "
|
|
||||||
<< "but an install rule has been provided for it. CMake does "
|
|
||||||
<< "not define behavior for this case.";
|
|
||||||
cmSystemTools::Message(msg.str(), "Warning");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Perform the main install script generation.
|
|
||||||
this->cmInstallGenerator::GenerateScript(os);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmInstallTargetGenerator::GenerateScriptForConfig(
|
void cmInstallTargetGenerator::GenerateScriptForConfig(
|
||||||
std::ostream& os, const std::string& config, Indent indent)
|
std::ostream& os, const std::string& config, Indent indent)
|
||||||
{
|
{
|
||||||
|
@@ -69,7 +69,6 @@ public:
|
|||||||
cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; }
|
cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void GenerateScript(std::ostream& os) override;
|
|
||||||
void GenerateScriptForConfig(std::ostream& os, const std::string& config,
|
void GenerateScriptForConfig(std::ostream& os, const std::string& config,
|
||||||
Indent indent) override;
|
Indent indent) override;
|
||||||
void GenerateScriptForConfigObjectLibrary(std::ostream& os,
|
void GenerateScriptForConfigObjectLibrary(std::ostream& os,
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
^WARNING: Target "notall" has EXCLUDE_FROM_ALL set and will not be built by default but an install rule has been provided for it\. CMake does not define behavior for this case\.$
|
|
Reference in New Issue
Block a user