diff options
author | Brad King <brad.king@kitware.com> | 2020-02-11 19:59:21 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-02-11 19:59:21 (GMT) |
commit | dd8d5004a9e109b0835979c722767679d3bececa (patch) | |
tree | 90d82e7dc3e96bdaeff0c6086eb7a37defc9beed /Source/cmInstallCommand.cxx | |
parent | 155540d89eb5ac00fd8ba03a9580de2382af6386 (diff) | |
parent | 45d5abf4a8356f3d49ce49490d608afeacbc4802 (diff) | |
download | CMake-dd8d5004a9e109b0835979c722767679d3bececa.zip CMake-dd8d5004a9e109b0835979c722767679d3bececa.tar.gz CMake-dd8d5004a9e109b0835979c722767679d3bececa.tar.bz2 |
Merge branch 'backport-3.16-install-default-fix'
Diffstat (limited to 'Source/cmInstallCommand.cxx')
-rw-r--r-- | Source/cmInstallCommand.cxx | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index c67358f..d669ed7 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -461,6 +461,10 @@ bool HandleTargetsMode(std::vector<std::string> const& args, std::unique_ptr<cmInstallFilesGenerator> publicHeaderGenerator; std::unique_ptr<cmInstallFilesGenerator> resourceGenerator; + // 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; @@ -480,11 +484,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 && !runtimeGenerator) { archiveGenerator = CreateInstallTargetGenerator( @@ -517,6 +523,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(), @@ -558,6 +567,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)); @@ -625,6 +637,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)); @@ -637,6 +652,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); } @@ -673,9 +689,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"); @@ -687,9 +711,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"); |