export: Reject custom target exports earlier (#15657)

Diagnose and reject custom targets given to the export() command
immediately.  Previously we would generate an internal error later.
This commit is contained in:
Brad King 2015-07-21 14:37:20 -04:00
parent 3b09398ae2
commit 7e9f908ef5
5 changed files with 14 additions and 0 deletions

View File

@ -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
{

View File

@ -0,0 +1 @@
1

View File

@ -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\)$

View File

@ -0,0 +1,2 @@
add_custom_target(CustomTarget)
export(TARGETS CustomTarget FILE somefile.cmake)

View File

@ -1,5 +1,6 @@
include(RunCMake)
run_cmake(CustomTarget)
run_cmake(TargetNotFound)
run_cmake(AppendExport)
run_cmake(OldIface)