export(): Check targets exist at configure-time (#14608)
Commit 66b290e7 (export(): Process the export() command at generate time., 2012-10-06 ) refactored export() so that it could evaluate strings at generate-time. This was intended for evaluating target properties, but that commit also removed a check for target existence at configure-time. Restore that check and add a test for this case.
This commit is contained in:
parent
f282a0bf83
commit
1cd1430b1f
@ -135,6 +135,14 @@ bool cmExportCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmOStringStream e;
|
||||||
|
e << "given target \"" << *currentTarget
|
||||||
|
<< "\" which is not built by this project.";
|
||||||
|
this->SetError(e.str().c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmGlobalGenerator *gg = this->Makefile->GetLocalGenerator()
|
cmGlobalGenerator *gg = this->Makefile->GetLocalGenerator()
|
||||||
|
@ -98,6 +98,7 @@ add_RunCMake_test(Syntax)
|
|||||||
|
|
||||||
add_RunCMake_test(add_dependencies)
|
add_RunCMake_test(add_dependencies)
|
||||||
add_RunCMake_test(build_command)
|
add_RunCMake_test(build_command)
|
||||||
|
add_RunCMake_test(export)
|
||||||
add_RunCMake_test(cmake_minimum_required)
|
add_RunCMake_test(cmake_minimum_required)
|
||||||
add_RunCMake_test(find_package)
|
add_RunCMake_test(find_package)
|
||||||
add_RunCMake_test(get_filename_component)
|
add_RunCMake_test(get_filename_component)
|
||||||
|
3
Tests/RunCMake/export/CMakeLists.txt
Normal file
3
Tests/RunCMake/export/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8.4)
|
||||||
|
project(${RunCMake_TEST})
|
||||||
|
include(${RunCMake_TEST}.cmake)
|
3
Tests/RunCMake/export/RunCMakeTest.cmake
Normal file
3
Tests/RunCMake/export/RunCMakeTest.cmake
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
include(RunCMake)
|
||||||
|
|
||||||
|
run_cmake(TargetNotFound)
|
1
Tests/RunCMake/export/TargetNotFound-result.txt
Normal file
1
Tests/RunCMake/export/TargetNotFound-result.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
4
Tests/RunCMake/export/TargetNotFound-stderr.txt
Normal file
4
Tests/RunCMake/export/TargetNotFound-stderr.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
CMake Error at TargetNotFound.cmake:1 \(export\):
|
||||||
|
export given target "nonexistenttarget" which is not built by this project.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
1
Tests/RunCMake/export/TargetNotFound.cmake
Normal file
1
Tests/RunCMake/export/TargetNotFound.cmake
Normal file
@ -0,0 +1 @@
|
|||||||
|
export(TARGETS nonexistenttarget FILE somefile.cmake)
|
Loading…
x
Reference in New Issue
Block a user