summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-07-22 15:04:32 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-07-22 15:04:32 (GMT)
commite00e8713de13570b8ca41291c0a863a8be00686c (patch)
tree9c9100fc6cb1c07ca0250421c9f812fb16c3beb9
parent4c3d431210d8c30b4b6fc67f75af73406dd396fa (diff)
parent7e9f908ef54a3c2fe42ae8f9376c77e5bc988a9a (diff)
downloadCMake-e00e8713de13570b8ca41291c0a863a8be00686c.zip
CMake-e00e8713de13570b8ca41291c0a863a8be00686c.tar.gz
CMake-e00e8713de13570b8ca41291c0a863a8be00686c.tar.bz2
Merge topic 'export-no-custom-target'
7e9f908e export: Reject custom target exports earlier (#15657) 3b09398a Tests: Teach RunCMake.export to enable languages only when needed
-rw-r--r--Source/cmExportCommand.cxx6
-rw-r--r--Tests/RunCMake/export/AppendExport-stderr.txt2
-rw-r--r--Tests/RunCMake/export/AppendExport.cmake1
-rw-r--r--Tests/RunCMake/export/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/export/CustomTarget-result.txt1
-rw-r--r--Tests/RunCMake/export/CustomTarget-stderr.txt4
-rw-r--r--Tests/RunCMake/export/CustomTarget.cmake2
-rw-r--r--Tests/RunCMake/export/OldIface-stderr.txt2
-rw-r--r--Tests/RunCMake/export/OldIface.cmake1
-rw-r--r--Tests/RunCMake/export/RunCMakeTest.cmake1
10 files changed, 19 insertions, 3 deletions
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index 43d26f9..96ea77b 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -177,6 +177,12 @@ bool cmExportCommand
this->SetError(e.str());
return false;
}
+ if (target->GetType() == cmTarget::UTILITY)
+ {
+ this->SetError("given custom target \"" + *currentTarget
+ + "\" which may not be exported.");
+ return false;
+ }
}
else
{
diff --git a/Tests/RunCMake/export/AppendExport-stderr.txt b/Tests/RunCMake/export/AppendExport-stderr.txt
index 6e385d4..d71620e 100644
--- a/Tests/RunCMake/export/AppendExport-stderr.txt
+++ b/Tests/RunCMake/export/AppendExport-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at AppendExport.cmake:8 \(export\):
+CMake Error at AppendExport.cmake:[0-9]+ \(export\):
export EXPORT signature does not recognise the APPEND option.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/export/AppendExport.cmake b/Tests/RunCMake/export/AppendExport.cmake
index f36010b..2a99dfc 100644
--- a/Tests/RunCMake/export/AppendExport.cmake
+++ b/Tests/RunCMake/export/AppendExport.cmake
@@ -1,3 +1,4 @@
+enable_language(CXX)
add_library(foo empty.cpp)
export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake")
install(TARGETS foo EXPORT fooExport
diff --git a/Tests/RunCMake/export/CMakeLists.txt b/Tests/RunCMake/export/CMakeLists.txt
index be9d403..12cd3c7 100644
--- a/Tests/RunCMake/export/CMakeLists.txt
+++ b/Tests/RunCMake/export/CMakeLists.txt
@@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 2.8.4)
-project(${RunCMake_TEST})
+project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/export/CustomTarget-result.txt b/Tests/RunCMake/export/CustomTarget-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/export/CustomTarget-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/export/CustomTarget-stderr.txt b/Tests/RunCMake/export/CustomTarget-stderr.txt
new file mode 100644
index 0000000..57a9af3
--- /dev/null
+++ b/Tests/RunCMake/export/CustomTarget-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at CustomTarget.cmake:[0-9]+ \(export\):
+ export given custom target "CustomTarget" which may not be exported.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/export/CustomTarget.cmake b/Tests/RunCMake/export/CustomTarget.cmake
new file mode 100644
index 0000000..4d2bf18
--- /dev/null
+++ b/Tests/RunCMake/export/CustomTarget.cmake
@@ -0,0 +1,2 @@
+add_custom_target(CustomTarget)
+export(TARGETS CustomTarget FILE somefile.cmake)
diff --git a/Tests/RunCMake/export/OldIface-stderr.txt b/Tests/RunCMake/export/OldIface-stderr.txt
index afb4ae3..818c2cb 100644
--- a/Tests/RunCMake/export/OldIface-stderr.txt
+++ b/Tests/RunCMake/export/OldIface-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at OldIface.cmake:8 \(export\):
+CMake Error at OldIface.cmake:[0-9]+ \(export\):
export EXPORT signature does not recognise the
EXPORT_LINK_INTERFACE_LIBRARIES option.
Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/export/OldIface.cmake b/Tests/RunCMake/export/OldIface.cmake
index 5fb8e25..833b023 100644
--- a/Tests/RunCMake/export/OldIface.cmake
+++ b/Tests/RunCMake/export/OldIface.cmake
@@ -1,3 +1,4 @@
+enable_language(CXX)
add_library(foo empty.cpp)
export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake")
install(TARGETS foo EXPORT fooExport
diff --git a/Tests/RunCMake/export/RunCMakeTest.cmake b/Tests/RunCMake/export/RunCMakeTest.cmake
index 4b04f18..6d0b7ca 100644
--- a/Tests/RunCMake/export/RunCMakeTest.cmake
+++ b/Tests/RunCMake/export/RunCMakeTest.cmake
@@ -1,5 +1,6 @@
include(RunCMake)
+run_cmake(CustomTarget)
run_cmake(TargetNotFound)
run_cmake(AppendExport)
run_cmake(OldIface)