mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-20 21:28:23 -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:
@@ -461,6 +461,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
cmInstallFilesGenerator* publicHeaderGenerator = nullptr;
|
cmInstallFilesGenerator* publicHeaderGenerator = nullptr;
|
||||||
cmInstallFilesGenerator* resourceGenerator = 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.
|
// Track whether this is a namelink-only rule.
|
||||||
bool namelinkOnly = false;
|
bool namelinkOnly = false;
|
||||||
|
|
||||||
@@ -480,11 +484,13 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
// The import library uses the ARCHIVE properties.
|
// The import library uses the ARCHIVE properties.
|
||||||
archiveGenerator = CreateInstallTargetGenerator(
|
archiveGenerator = CreateInstallTargetGenerator(
|
||||||
target, archiveArgs, true, this->Makefile->GetBacktrace());
|
target, archiveArgs, true, this->Makefile->GetBacktrace());
|
||||||
|
artifactsSpecified = true;
|
||||||
}
|
}
|
||||||
if (!runtimeArgs.GetDestination().empty()) {
|
if (!runtimeArgs.GetDestination().empty()) {
|
||||||
// The DLL uses the RUNTIME properties.
|
// The DLL uses the RUNTIME properties.
|
||||||
runtimeGenerator = CreateInstallTargetGenerator(
|
runtimeGenerator = CreateInstallTargetGenerator(
|
||||||
target, runtimeArgs, false, this->Makefile->GetBacktrace());
|
target, runtimeArgs, false, this->Makefile->GetBacktrace());
|
||||||
|
artifactsSpecified = true;
|
||||||
}
|
}
|
||||||
if ((archiveGenerator == nullptr) && (runtimeGenerator == nullptr)) {
|
if ((archiveGenerator == nullptr) && (runtimeGenerator == nullptr)) {
|
||||||
archiveGenerator = CreateInstallTargetGenerator(
|
archiveGenerator = CreateInstallTargetGenerator(
|
||||||
@@ -518,6 +524,9 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// The shared library uses the LIBRARY properties.
|
// The shared library uses the LIBRARY properties.
|
||||||
|
if (!libraryArgs.GetDestination().empty()) {
|
||||||
|
artifactsSpecified = true;
|
||||||
|
}
|
||||||
if (namelinkMode != cmInstallTargetGenerator::NamelinkModeOnly) {
|
if (namelinkMode != cmInstallTargetGenerator::NamelinkModeOnly) {
|
||||||
libraryGenerator = CreateInstallTargetGenerator(
|
libraryGenerator = CreateInstallTargetGenerator(
|
||||||
target, libraryArgs, false, this->Makefile->GetBacktrace(),
|
target, libraryArgs, false, this->Makefile->GetBacktrace(),
|
||||||
@@ -560,6 +569,9 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Static libraries use ARCHIVE properties.
|
// Static libraries use ARCHIVE properties.
|
||||||
|
if (!archiveArgs.GetDestination().empty()) {
|
||||||
|
artifactsSpecified = true;
|
||||||
|
}
|
||||||
archiveGenerator = CreateInstallTargetGenerator(
|
archiveGenerator = CreateInstallTargetGenerator(
|
||||||
target, archiveArgs, false, this->Makefile->GetBacktrace(),
|
target, archiveArgs, false, this->Makefile->GetBacktrace(),
|
||||||
this->GetArchiveDestination(&archiveArgs));
|
this->GetArchiveDestination(&archiveArgs));
|
||||||
@@ -630,6 +642,9 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Executables use the RUNTIME properties.
|
// Executables use the RUNTIME properties.
|
||||||
|
if (!runtimeArgs.GetDestination().empty()) {
|
||||||
|
artifactsSpecified = true;
|
||||||
|
}
|
||||||
runtimeGenerator = CreateInstallTargetGenerator(
|
runtimeGenerator = CreateInstallTargetGenerator(
|
||||||
target, runtimeArgs, false, this->Makefile->GetBacktrace(),
|
target, runtimeArgs, false, this->Makefile->GetBacktrace(),
|
||||||
this->GetRuntimeDestination(&runtimeArgs));
|
this->GetRuntimeDestination(&runtimeArgs));
|
||||||
@@ -641,6 +656,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
if (dll_platform && !archiveArgs.GetDestination().empty() &&
|
if (dll_platform && !archiveArgs.GetDestination().empty() &&
|
||||||
target.IsExecutableWithExports()) {
|
target.IsExecutableWithExports()) {
|
||||||
// The import library uses the ARCHIVE properties.
|
// The import library uses the ARCHIVE properties.
|
||||||
|
artifactsSpecified = true;
|
||||||
archiveGenerator = CreateInstallTargetGenerator(
|
archiveGenerator = CreateInstallTargetGenerator(
|
||||||
target, archiveArgs, true, this->Makefile->GetBacktrace(), true);
|
target, archiveArgs, true, this->Makefile->GetBacktrace(), true);
|
||||||
}
|
}
|
||||||
@@ -679,9 +695,17 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the files install generator.
|
// Create the files install generator.
|
||||||
privateHeaderGenerator = CreateInstallFilesGenerator(
|
if (!artifactsSpecified ||
|
||||||
this->Makefile, absFiles, privateHeaderArgs, false,
|
!privateHeaderArgs.GetDestination().empty()) {
|
||||||
this->GetIncludeDestination(&privateHeaderArgs));
|
privateHeaderGenerator = CreateInstallFilesGenerator(
|
||||||
|
this->Makefile, absFiles, privateHeaderArgs, false,
|
||||||
|
this->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");
|
files = target.GetProperty("PUBLIC_HEADER");
|
||||||
@@ -694,9 +718,17 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the files install generator.
|
// Create the files install generator.
|
||||||
publicHeaderGenerator = CreateInstallFilesGenerator(
|
if (!artifactsSpecified ||
|
||||||
this->Makefile, absFiles, publicHeaderArgs, false,
|
!publicHeaderArgs.GetDestination().empty()) {
|
||||||
this->GetIncludeDestination(&publicHeaderArgs));
|
publicHeaderGenerator = CreateInstallFilesGenerator(
|
||||||
|
this->Makefile, absFiles, publicHeaderArgs, false,
|
||||||
|
this->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");
|
files = target.GetProperty("RESOURCE");
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ if(WIN32)
|
|||||||
[[mybin/exe\.exe]]
|
[[mybin/exe\.exe]]
|
||||||
[[mybin/(lib)?lib1\.dll]]
|
[[mybin/(lib)?lib1\.dll]]
|
||||||
[[myinclude]]
|
[[myinclude]]
|
||||||
[[myinclude/obj4\.h]]
|
[[myinclude/obj3\.h]]
|
||||||
[[myinclude/obj5\.h]]
|
|
||||||
[[mylib]]
|
[[mylib]]
|
||||||
[[mylib/(lib)?lib1\.(dll\.a|lib)]]
|
[[mylib/(lib)?lib1\.(dll\.a|lib)]]
|
||||||
[[mylib/(lib)?lib2\.(a|lib)]]
|
[[mylib/(lib)?lib2\.(a|lib)]]
|
||||||
@@ -24,8 +23,7 @@ elseif(CYGWIN)
|
|||||||
[[mybin/cyglib1\.dll]]
|
[[mybin/cyglib1\.dll]]
|
||||||
[[mybin/exe\.exe]]
|
[[mybin/exe\.exe]]
|
||||||
[[myinclude]]
|
[[myinclude]]
|
||||||
[[myinclude/obj4\.h]]
|
[[myinclude/obj3\.h]]
|
||||||
[[myinclude/obj5\.h]]
|
|
||||||
[[mylib]]
|
[[mylib]]
|
||||||
[[mylib/liblib1\.dll\.a]]
|
[[mylib/liblib1\.dll\.a]]
|
||||||
[[mylib/liblib2\.a]]
|
[[mylib/liblib2\.a]]
|
||||||
@@ -39,8 +37,7 @@ else()
|
|||||||
[[mybin]]
|
[[mybin]]
|
||||||
[[mybin/exe]]
|
[[mybin/exe]]
|
||||||
[[myinclude]]
|
[[myinclude]]
|
||||||
[[myinclude/obj4\.h]]
|
[[myinclude/obj3\.h]]
|
||||||
[[myinclude/obj5\.h]]
|
|
||||||
[[mylib]]
|
[[mylib]]
|
||||||
[[mylib/liblib1\.(dylib|so)]]
|
[[mylib/liblib1\.(dylib|so)]]
|
||||||
[[mylib/liblib2\.a]]
|
[[mylib/liblib2\.a]]
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
^INSTALL TARGETS - target lib3 has PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION\.
|
||||||
|
INSTALL TARGETS - target lib4 has PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION\.$
|
||||||
@@ -2,6 +2,7 @@ enable_language(C)
|
|||||||
|
|
||||||
add_executable(exe main.c)
|
add_executable(exe main.c)
|
||||||
add_library(lib1 SHARED obj1.c)
|
add_library(lib1 SHARED obj1.c)
|
||||||
|
set_property(TARGET lib1 PROPERTY PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj3.h)
|
||||||
add_library(lib2 STATIC obj3.c)
|
add_library(lib2 STATIC obj3.c)
|
||||||
add_library(lib3 SHARED obj4.c)
|
add_library(lib3 SHARED obj4.c)
|
||||||
set_property(TARGET lib3 PROPERTY PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj4.h)
|
set_property(TARGET lib3 PROPERTY PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj4.h)
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ if(WIN32)
|
|||||||
[[bin/exe\.exe]]
|
[[bin/exe\.exe]]
|
||||||
[[bin/(lib)?lib1\.dll]]
|
[[bin/(lib)?lib1\.dll]]
|
||||||
[[include]]
|
[[include]]
|
||||||
[[include/obj4\.h]]
|
[[include/obj3\.h]]
|
||||||
[[include/obj5\.h]]
|
|
||||||
[[lib]]
|
[[lib]]
|
||||||
[[lib/(lib)?lib1\.(dll\.a|lib)]]
|
[[lib/(lib)?lib1\.(dll\.a|lib)]]
|
||||||
[[lib/(lib)?lib2\.(a|lib)]]
|
[[lib/(lib)?lib2\.(a|lib)]]
|
||||||
@@ -20,8 +19,7 @@ elseif(CYGWIN)
|
|||||||
[[bin/cyglib1\.dll]]
|
[[bin/cyglib1\.dll]]
|
||||||
[[bin/exe\.exe]]
|
[[bin/exe\.exe]]
|
||||||
[[include]]
|
[[include]]
|
||||||
[[include/obj4\.h]]
|
[[include/obj3\.h]]
|
||||||
[[include/obj5\.h]]
|
|
||||||
[[lib]]
|
[[lib]]
|
||||||
[[lib/liblib1\.dll\.a]]
|
[[lib/liblib1\.dll\.a]]
|
||||||
[[lib/liblib2\.a]]
|
[[lib/liblib2\.a]]
|
||||||
@@ -35,8 +33,7 @@ else()
|
|||||||
[[bin]]
|
[[bin]]
|
||||||
[[bin/exe]]
|
[[bin/exe]]
|
||||||
[[include]]
|
[[include]]
|
||||||
[[include/obj4\.h]]
|
[[include/obj3\.h]]
|
||||||
[[include/obj5\.h]]
|
|
||||||
[[lib]]
|
[[lib]]
|
||||||
[[lib/liblib1\.(dylib|so)]]
|
[[lib/liblib1\.(dylib|so)]]
|
||||||
[[lib/liblib2\.a]]
|
[[lib/liblib2\.a]]
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
^INSTALL TARGETS - target lib3 has PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION\.
|
||||||
|
INSTALL TARGETS - target lib4 has PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION\.$
|
||||||
@@ -2,6 +2,7 @@ enable_language(C)
|
|||||||
|
|
||||||
add_executable(exe main.c)
|
add_executable(exe main.c)
|
||||||
add_library(lib1 SHARED obj1.c)
|
add_library(lib1 SHARED obj1.c)
|
||||||
|
set_property(TARGET lib1 PROPERTY PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj3.h)
|
||||||
add_library(lib2 STATIC obj3.c)
|
add_library(lib2 STATIC obj3.c)
|
||||||
add_library(lib3 SHARED obj4.c)
|
add_library(lib3 SHARED obj4.c)
|
||||||
set_property(TARGET lib3 PROPERTY PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj4.h)
|
set_property(TARGET lib3 PROPERTY PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj4.h)
|
||||||
|
|||||||
Reference in New Issue
Block a user