diff options
author | Craig Scott <craig.scott@crascit.com> | 2020-10-12 23:19:22 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-10-12 23:19:33 (GMT) |
commit | 343c8fe8abb156cc00d2b9c27a6674f0fc41cfc2 (patch) | |
tree | 0c907ba6bedd5922b3e4b7643122834a625ffb17 | |
parent | 0673ad599e2e4e22546449184787c6c1a04b8ae5 (diff) | |
parent | 64690f6df043b65b083c258b2c53910508336469 (diff) | |
download | CMake-343c8fe8abb156cc00d2b9c27a6674f0fc41cfc2.zip CMake-343c8fe8abb156cc00d2b9c27a6674f0fc41cfc2.tar.gz CMake-343c8fe8abb156cc00d2b9c27a6674f0fc41cfc2.tar.bz2 |
Merge topic 'export-namelink-only'
64690f6df0 export: Do not fail generation for namelink-only case
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5352
-rw-r--r-- | Source/cmInstallCommand.cxx | 46 | ||||
-rw-r--r-- | Tests/RunCMake/export/NamelinkOnlyExport.cmake | 9 | ||||
-rw-r--r-- | Tests/RunCMake/export/RunCMakeTest.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/export/UnknownExport-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/export/UnknownExport-stderr.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/export/UnknownExport.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/install/EXPORT-NamelinkOnly.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/install/EXPORT-UnknownExport-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/install/EXPORT-UnknownExport-stderr.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/install/EXPORT-UnknownExport.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/install/RunCMakeTest.cmake | 2 |
11 files changed, 66 insertions, 19 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 83609e2..9a5dbef 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -461,6 +461,28 @@ bool HandleTargetsMode(std::vector<std::string> const& args, std::unique_ptr<cmInstallFilesGenerator> publicHeaderGenerator; std::unique_ptr<cmInstallFilesGenerator> resourceGenerator; + auto addTargetExport = [&]() { + // Add this install rule to an export if one was specified. + // (If this is a namelink-only rule no export file will be generated.) + if (!exports.empty()) { + auto te = cm::make_unique<cmTargetExport>(); + te->TargetName = target.GetName(); + te->ArchiveGenerator = archiveGenerator.get(); + te->BundleGenerator = bundleGenerator.get(); + te->FrameworkGenerator = frameworkGenerator.get(); + te->HeaderGenerator = publicHeaderGenerator.get(); + te->LibraryGenerator = libraryGenerator.get(); + te->RuntimeGenerator = runtimeGenerator.get(); + te->ObjectsGenerator = objectGenerator.get(); + te->InterfaceIncludeDirectories = + cmJoin(includesArgs.GetIncludeDirs(), ";"); + + helper.Makefile->GetGlobalGenerator() + ->GetExportSets()[exports] + .AddTargetExport(std::move(te)); + } + }; + // Avoid selecting default destinations for PUBLIC_HEADER and // PRIVATE_HEADER if any artifacts are specified. bool artifactsSpecified = false; @@ -476,6 +498,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args, if (target.IsDLLPlatform()) { // When in namelink only mode skip all libraries on Windows. if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) { + addTargetExport(); continue; } @@ -507,6 +530,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args, if (target.IsFrameworkOnApple()) { // When in namelink only mode skip frameworks. if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) { + addTargetExport(); continue; } @@ -551,6 +575,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args, if (target.IsFrameworkOnApple()) { // When in namelink only mode skip frameworks. if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) { + addTargetExport(); continue; } @@ -744,25 +769,8 @@ bool HandleTargetsMode(std::vector<std::string> const& args, } } - // Add this install rule to an export if one was specified and - // this is not a namelink-only rule. - if (!exports.empty() && !namelinkOnly) { - auto te = cm::make_unique<cmTargetExport>(); - te->TargetName = target.GetName(); - te->ArchiveGenerator = archiveGenerator.get(); - te->BundleGenerator = bundleGenerator.get(); - te->FrameworkGenerator = frameworkGenerator.get(); - te->HeaderGenerator = publicHeaderGenerator.get(); - te->LibraryGenerator = libraryGenerator.get(); - te->RuntimeGenerator = runtimeGenerator.get(); - te->ObjectsGenerator = objectGenerator.get(); - te->InterfaceIncludeDirectories = - cmJoin(includesArgs.GetIncludeDirs(), ";"); - - helper.Makefile->GetGlobalGenerator() - ->GetExportSets()[exports] - .AddTargetExport(std::move(te)); - } + // Add this install rule to an export if one was specified. + addTargetExport(); // Keep track of whether we're installing anything in each category installsArchive = installsArchive || archiveGenerator; diff --git a/Tests/RunCMake/export/NamelinkOnlyExport.cmake b/Tests/RunCMake/export/NamelinkOnlyExport.cmake new file mode 100644 index 0000000..4bdd180 --- /dev/null +++ b/Tests/RunCMake/export/NamelinkOnlyExport.cmake @@ -0,0 +1,9 @@ +enable_language(CXX) +add_library(foo SHARED empty.cpp) +install(TARGETS foo EXPORT fooExport + RUNTIME DESTINATION bin + LIBRARY + DESTINATION lib + NAMELINK_ONLY +) +export(EXPORT fooExport FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake") diff --git a/Tests/RunCMake/export/RunCMakeTest.cmake b/Tests/RunCMake/export/RunCMakeTest.cmake index 1c74762..95c8d5c 100644 --- a/Tests/RunCMake/export/RunCMakeTest.cmake +++ b/Tests/RunCMake/export/RunCMakeTest.cmake @@ -15,3 +15,5 @@ run_cmake(ForbiddenToExportPropertyWithGenExp) run_cmake(ExportPropertiesUndefined) run_cmake(DependOnNotExport) run_cmake(DependOnDoubleExport) +run_cmake(UnknownExport) +run_cmake(NamelinkOnlyExport) diff --git a/Tests/RunCMake/export/UnknownExport-result.txt b/Tests/RunCMake/export/UnknownExport-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/export/UnknownExport-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/export/UnknownExport-stderr.txt b/Tests/RunCMake/export/UnknownExport-stderr.txt new file mode 100644 index 0000000..a8f8453 --- /dev/null +++ b/Tests/RunCMake/export/UnknownExport-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at UnknownExport\.cmake:[0-9]+ \(export\): + export Export set "fooExport" not found\. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/export/UnknownExport.cmake b/Tests/RunCMake/export/UnknownExport.cmake new file mode 100644 index 0000000..bf82d1f --- /dev/null +++ b/Tests/RunCMake/export/UnknownExport.cmake @@ -0,0 +1,2 @@ +enable_language(CXX) +export(EXPORT fooExport FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake") diff --git a/Tests/RunCMake/install/EXPORT-NamelinkOnly.cmake b/Tests/RunCMake/install/EXPORT-NamelinkOnly.cmake new file mode 100644 index 0000000..1c310d1 --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-NamelinkOnly.cmake @@ -0,0 +1,12 @@ +enable_language(C) +add_library(foo SHARED empty.c) +install(TARGETS foo EXPORT fooExport + RUNTIME DESTINATION bin + LIBRARY + DESTINATION lib + NAMELINK_ONLY +) +install(EXPORT fooExport + DESTINATION "lib/cmake/" + FILE "foo.cmake" +) diff --git a/Tests/RunCMake/install/EXPORT-UnknownExport-result.txt b/Tests/RunCMake/install/EXPORT-UnknownExport-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-UnknownExport-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/install/EXPORT-UnknownExport-stderr.txt b/Tests/RunCMake/install/EXPORT-UnknownExport-stderr.txt new file mode 100644 index 0000000..bd49fa2 --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-UnknownExport-stderr.txt @@ -0,0 +1 @@ +CMake Error: INSTALL\(EXPORT\) given unknown export "fooExport" diff --git a/Tests/RunCMake/install/EXPORT-UnknownExport.cmake b/Tests/RunCMake/install/EXPORT-UnknownExport.cmake new file mode 100644 index 0000000..2dbba4e --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-UnknownExport.cmake @@ -0,0 +1,5 @@ +enable_language(C) +install(EXPORT fooExport + DESTINATION "lib/cmake/" + FILE "foo.cmake" +) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index 3573fbd..5aab88c 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -76,6 +76,8 @@ run_cmake(DIRECTORY-DESTINATION-bad) run_cmake(FILES-DESTINATION-bad) run_cmake(TARGETS-DESTINATION-bad) run_cmake(EXPORT-OldIFace) +run_cmake(EXPORT-UnknownExport) +run_cmake(EXPORT-NamelinkOnly) run_cmake(CMP0062-OLD) run_cmake(CMP0062-NEW) run_cmake(CMP0062-WARN) |