Diagnose and reject custom targets given to the export() command immediately. Previously we would generate an internal error later.
@@ -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
{
@@ -0,0 +1 @@
+1
@@ -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\)$
@@ -0,0 +1,2 @@
+add_custom_target(CustomTarget)
+export(TARGETS CustomTarget FILE somefile.cmake)
@@ -1,5 +1,6 @@
include(RunCMake)
+run_cmake(CustomTarget)
run_cmake(TargetNotFound)
run_cmake(AppendExport)
run_cmake(OldIface)