summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeniz Bahadir <dbahadir@benocs.com>2020-10-09 12:13:13 +0200
committerDeniz Bahadir <dbahadir@benocs.com>2020-10-09 22:29:22 +0200
commit64690f6df043b65b083c258b2c53910508336469 (patch)
tree4200ba898a14d89aaf2950364f47cfce33cdb785
parent3fb2112880ca3be6299721f5add1928483de0b1b (diff)
downloadcmake-64690f6df043b65b083c258b2c53910508336469.tar.gz
export: Do not fail generation for namelink-only case
-rw-r--r--Source/cmInstallCommand.cxx46
-rw-r--r--Tests/RunCMake/export/NamelinkOnlyExport.cmake9
-rw-r--r--Tests/RunCMake/export/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/export/UnknownExport-result.txt1
-rw-r--r--Tests/RunCMake/export/UnknownExport-stderr.txt4
-rw-r--r--Tests/RunCMake/export/UnknownExport.cmake2
-rw-r--r--Tests/RunCMake/install/EXPORT-NamelinkOnly.cmake12
-rw-r--r--Tests/RunCMake/install/EXPORT-UnknownExport-result.txt1
-rw-r--r--Tests/RunCMake/install/EXPORT-UnknownExport-stderr.txt1
-rw-r--r--Tests/RunCMake/install/EXPORT-UnknownExport.cmake5
-rw-r--r--Tests/RunCMake/install/RunCMakeTest.cmake2
11 files changed, 66 insertions, 19 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 83609e26f8..9a5dbef30a 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 0000000000..4bdd180abb
--- /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 1c747623a7..95c8d5cf45 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 0000000000..d00491fd7e
--- /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 0000000000..a8f8453ec4
--- /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 0000000000..bf82d1f324
--- /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 0000000000..1c310d1f9a
--- /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 0000000000..d00491fd7e
--- /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 0000000000..bd49fa26e2
--- /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 0000000000..2dbba4e282
--- /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 3573fbd6e9..5aab88ca80 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)