mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-12 09:08:58 -05:00
Genex: Reject TARGET_OBJECTS on non-object libraries earlier
Move the diagnostic that rejects the TARGET_OBJECTS generator expression in non-buildsystem context until after the check for whether the named target is an object library. This order will makes more sense than the previous order once TARGET_OBJECTS is allowed in non-buildsystem context.
This commit is contained in:
@@ -1226,15 +1226,6 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
|
||||
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
||||
CM_OVERRIDE
|
||||
{
|
||||
if (!context->EvaluateForBuildsystem) {
|
||||
std::ostringstream e;
|
||||
e << "The evaluation of the TARGET_OBJECTS generator expression "
|
||||
"is only suitable for consumption by CMake. It is not suitable "
|
||||
"for writing out elsewhere.";
|
||||
reportError(context, content->GetOriginalExpression(), e.str());
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string tgtName = parameters.front();
|
||||
cmGeneratorTarget* gt = context->LG->FindGeneratorTargetToUse(tgtName);
|
||||
if (!gt) {
|
||||
@@ -1251,6 +1242,14 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
|
||||
reportError(context, content->GetOriginalExpression(), e.str());
|
||||
return std::string();
|
||||
}
|
||||
if (!context->EvaluateForBuildsystem) {
|
||||
std::ostringstream e;
|
||||
e << "The evaluation of the TARGET_OBJECTS generator expression "
|
||||
"is only suitable for consumption by CMake. It is not suitable "
|
||||
"for writing out elsewhere.";
|
||||
reportError(context, content->GetOriginalExpression(), e.str());
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::vector<std::string> objects;
|
||||
gt->GetTargetObjectNames(context->Config, objects);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
CMake Error at OutputNameMatchesObjects.cmake:2 \(file\):
|
||||
CMake Error at OutputNameMatchesObjects.cmake:[0-9]+ \(file\):
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<TARGET_OBJECTS:foo>
|
||||
|
||||
The evaluation of the TARGET_OBJECTS generator expression is only suitable
|
||||
for consumption by CMake. It is not suitable for writing out elsewhere.
|
||||
Objects of target "foo" referenced but is not an OBJECT library.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:6 \(include\)
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
(CMake Error at BadContext.cmake:4 \(file\):
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<TARGET_OBJECTS:NoTarget>
|
||||
|
||||
The evaluation of the TARGET_OBJECTS generator expression is only suitable
|
||||
for consumption by CMake. It is not suitable for writing out elsewhere.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
*)+
|
||||
(CMake Error at BadContext.cmake:5 \(file\):
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<TARGET_OBJECTS:NoTarget>
|
||||
|
||||
The evaluation of the TARGET_OBJECTS generator expression is only suitable
|
||||
for consumption by CMake. It is not suitable for writing out elsewhere.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
*)+
|
||||
CMake Error:
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<TARGET_OBJECTS:NoTarget>
|
||||
|
||||
The evaluation of the TARGET_OBJECTS generator expression is only suitable
|
||||
for consumption by CMake. It is not suitable for writing out elsewhere.
|
||||
@@ -0,0 +1,24 @@
|
||||
(CMake Error at NoTarget.cmake:4 \(file\):
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<TARGET_OBJECTS:NoTarget>
|
||||
|
||||
Objects of target "NoTarget" referenced but no such target exists.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
*)+
|
||||
(CMake Error at NoTarget.cmake:5 \(file\):
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<TARGET_OBJECTS:NoTarget>
|
||||
|
||||
Objects of target "NoTarget" referenced but no such target exists.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
*)+
|
||||
CMake Error:
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<TARGET_OBJECTS:NoTarget>
|
||||
|
||||
Objects of target "NoTarget" referenced but no such target exists.
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,8 @@
|
||||
CMake Error at NotObjlibTarget.cmake:3 \(file\):
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<TARGET_OBJECTS:StaticLib>
|
||||
|
||||
Objects of target "StaticLib" referenced but is not an OBJECT library.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
@@ -0,0 +1,3 @@
|
||||
add_library(StaticLib empty.cpp)
|
||||
|
||||
file(GENERATE OUTPUT test_output CONTENT $<TARGET_OBJECTS:StaticLib>)
|
||||
@@ -1,3 +1,4 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(BadContext)
|
||||
run_cmake(NoTarget)
|
||||
run_cmake(NotObjlibTarget)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
int empty()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user