mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-24 07:08:38 -05:00
install: Fix regression when using default destinations
In commit 9fc20a4f3e (install: Add sane set of defaults for DESTINATION
and file type parameters, 2018-11-02, v3.14.0-rc1~410^2~1), a regression
was introduced, in which an `install(TARGETS)` with a
RUNTIME/LIBRARY/ARCHIVE DESTINATION but no PUBLIC_HEADER/PRIVATE_HEADER
DESTINATION would then install the headers. The old behavior did not do
this. Restore the old behavior.
Fixes: #20326
This commit is contained in:
@@ -460,6 +460,10 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
|
||||
cmInstallFilesGenerator* publicHeaderGenerator = nullptr;
|
||||
cmInstallFilesGenerator* resourceGenerator = nullptr;
|
||||
|
||||
// Avoid selecting default destinations for PUBLIC_HEADER and
|
||||
// PRIVATE_HEADER if any artifacts are specified.
|
||||
bool artifactsSpecified = false;
|
||||
|
||||
// Track whether this is a namelink-only rule.
|
||||
bool namelinkOnly = false;
|
||||
|
||||
@@ -479,11 +483,13 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
|
||||
// The import library uses the ARCHIVE properties.
|
||||
archiveGenerator = CreateInstallTargetGenerator(
|
||||
target, archiveArgs, true, helper.Makefile->GetBacktrace());
|
||||
artifactsSpecified = true;
|
||||
}
|
||||
if (!runtimeArgs.GetDestination().empty()) {
|
||||
// The DLL uses the RUNTIME properties.
|
||||
runtimeGenerator = CreateInstallTargetGenerator(
|
||||
target, runtimeArgs, false, helper.Makefile->GetBacktrace());
|
||||
artifactsSpecified = true;
|
||||
}
|
||||
if ((archiveGenerator == nullptr) && (runtimeGenerator == nullptr)) {
|
||||
archiveGenerator = CreateInstallTargetGenerator(
|
||||
@@ -516,6 +522,9 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
|
||||
}
|
||||
} else {
|
||||
// The shared library uses the LIBRARY properties.
|
||||
if (!libraryArgs.GetDestination().empty()) {
|
||||
artifactsSpecified = true;
|
||||
}
|
||||
if (namelinkMode != cmInstallTargetGenerator::NamelinkModeOnly) {
|
||||
libraryGenerator = CreateInstallTargetGenerator(
|
||||
target, libraryArgs, false, helper.Makefile->GetBacktrace(),
|
||||
@@ -557,6 +566,9 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
|
||||
}
|
||||
} else {
|
||||
// Static libraries use ARCHIVE properties.
|
||||
if (!archiveArgs.GetDestination().empty()) {
|
||||
artifactsSpecified = true;
|
||||
}
|
||||
archiveGenerator = CreateInstallTargetGenerator(
|
||||
target, archiveArgs, false, helper.Makefile->GetBacktrace(),
|
||||
helper.GetArchiveDestination(&archiveArgs));
|
||||
@@ -624,6 +636,9 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
|
||||
}
|
||||
} else {
|
||||
// Executables use the RUNTIME properties.
|
||||
if (!runtimeArgs.GetDestination().empty()) {
|
||||
artifactsSpecified = true;
|
||||
}
|
||||
runtimeGenerator = CreateInstallTargetGenerator(
|
||||
target, runtimeArgs, false, helper.Makefile->GetBacktrace(),
|
||||
helper.GetRuntimeDestination(&runtimeArgs));
|
||||
@@ -636,6 +651,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
|
||||
!archiveArgs.GetDestination().empty() &&
|
||||
target.IsExecutableWithExports()) {
|
||||
// The import library uses the ARCHIVE properties.
|
||||
artifactsSpecified = true;
|
||||
archiveGenerator = CreateInstallTargetGenerator(
|
||||
target, archiveArgs, true, helper.Makefile->GetBacktrace(), true);
|
||||
}
|
||||
@@ -672,9 +688,17 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
|
||||
}
|
||||
|
||||
// Create the files install generator.
|
||||
privateHeaderGenerator = CreateInstallFilesGenerator(
|
||||
helper.Makefile, absFiles, privateHeaderArgs, false,
|
||||
helper.GetIncludeDestination(&privateHeaderArgs));
|
||||
if (!artifactsSpecified ||
|
||||
!privateHeaderArgs.GetDestination().empty()) {
|
||||
privateHeaderGenerator = CreateInstallFilesGenerator(
|
||||
helper.Makefile, absFiles, privateHeaderArgs, false,
|
||||
helper.GetIncludeDestination(&privateHeaderArgs));
|
||||
} else {
|
||||
std::ostringstream e;
|
||||
e << "INSTALL TARGETS - target " << target.GetName() << " has "
|
||||
<< "PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION.";
|
||||
cmSystemTools::Message(e.str(), "Warning");
|
||||
}
|
||||
}
|
||||
|
||||
files = target.GetProperty("PUBLIC_HEADER");
|
||||
@@ -686,9 +710,17 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
|
||||
}
|
||||
|
||||
// Create the files install generator.
|
||||
publicHeaderGenerator = CreateInstallFilesGenerator(
|
||||
helper.Makefile, absFiles, publicHeaderArgs, false,
|
||||
helper.GetIncludeDestination(&publicHeaderArgs));
|
||||
if (!artifactsSpecified ||
|
||||
!publicHeaderArgs.GetDestination().empty()) {
|
||||
publicHeaderGenerator = CreateInstallFilesGenerator(
|
||||
helper.Makefile, absFiles, publicHeaderArgs, false,
|
||||
helper.GetIncludeDestination(&publicHeaderArgs));
|
||||
} else {
|
||||
std::ostringstream e;
|
||||
e << "INSTALL TARGETS - target " << target.GetName() << " has "
|
||||
<< "PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION.";
|
||||
cmSystemTools::Message(e.str(), "Warning");
|
||||
}
|
||||
}
|
||||
|
||||
files = target.GetProperty("RESOURCE");
|
||||
|
||||
Reference in New Issue
Block a user