Process generator expressions in the COMPILE_DEFINITIONS target property.
This commit is contained in:
parent
08cb4fa4c0
commit
083de7ed35
|
@ -342,5 +342,20 @@ std::string cmGeneratorTarget::GetCompileDefinitions(const char *config)
|
|||
|
||||
const char *prop = this->Target->GetProperty(defPropName.c_str());
|
||||
|
||||
return prop ? prop : "";
|
||||
if (!prop)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
cmListFileBacktrace lfbt;
|
||||
cmGeneratorExpression ge(lfbt);
|
||||
|
||||
cmGeneratorExpressionDAGChecker dagChecker(lfbt,
|
||||
this->GetName(),
|
||||
defPropName, 0, 0);
|
||||
return ge.Parse(prop).Evaluate(this->Makefile,
|
||||
config,
|
||||
false,
|
||||
this,
|
||||
&dagChecker);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,15 @@ enum {
|
|||
#endif
|
||||
};
|
||||
|
||||
#ifdef TEST_GENERATOR_EXPRESSIONS
|
||||
#ifndef CMAKE_IS_DECLARATIVE
|
||||
#error Expect declarative definition
|
||||
#endif
|
||||
#ifdef GE_NOT_DEFINED
|
||||
#error Expect not defined generator expression
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -7,3 +7,9 @@ set_target_properties(target_prop_executable PROPERTIES COMPILE_DEFINITIONS CMAK
|
|||
|
||||
set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS_REALLY="Very Fun" CMAKE_IS=Fun)
|
||||
set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS_FUN CMAKE_IS_="Fun")
|
||||
|
||||
set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS
|
||||
TEST_GENERATOR_EXPRESSIONS
|
||||
"$<1:CMAKE_IS_DECLARATIVE>"
|
||||
"$<0:GE_NOT_DEFINED>"
|
||||
)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
1
|
|
@ -0,0 +1,6 @@
|
|||
CMake Error:
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<TARGET_PROPERTY:COMPILE_DEFINITIONS>
|
||||
|
||||
Self reference on target "TargetPropertyGeneratorExpressions".$
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
|
||||
"int main(int, char **) { return 0; }\n")
|
||||
|
||||
add_executable(TargetPropertyGeneratorExpressions
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
|
||||
set_property(TARGET TargetPropertyGeneratorExpressions
|
||||
PROPERTY
|
||||
COMPILE_DEFINITIONS "$<TARGET_PROPERTY:COMPILE_DEFINITIONS>"
|
||||
)
|
|
@ -0,0 +1 @@
|
|||
1
|
|
@ -0,0 +1,6 @@
|
|||
CMake Error:
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,COMPILE_DEFINITIONS>
|
||||
|
||||
Self reference on target "TargetPropertyGeneratorExpressions".$
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
|
||||
"int main(int, char **) { return 0; }\n")
|
||||
|
||||
add_executable(TargetPropertyGeneratorExpressions
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
|
||||
set_property(TARGET TargetPropertyGeneratorExpressions PROPERTY
|
||||
COMPILE_DEFINITIONS
|
||||
"$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,COMPILE_DEFINITIONS>"
|
||||
)
|
|
@ -4,3 +4,5 @@ run_cmake(BadSelfReference1)
|
|||
run_cmake(BadSelfReference2)
|
||||
run_cmake(BadSelfReference3)
|
||||
run_cmake(BadSelfReference4)
|
||||
run_cmake(BadSelfReference5)
|
||||
run_cmake(BadSelfReference6)
|
||||
|
|
Loading…
Reference in New Issue