summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-10-04 11:04:25 +0000
committerKitware Robot <kwrobot@kitware.com>2017-10-04 07:05:41 -0400
commit8b5539d1c27145a5b71d551c12fabe273a5f93dc (patch)
tree9a9593e372fd180115fb1efbe79d5b72e2756a1f
parent19fce0471311d423ee88f3904c0b70946a31bcb1 (diff)
parent303cd7037a5de2b26373ed4184fd36e68e0f01da (diff)
downloadcmake-8b5539d1c27145a5b71d551c12fabe273a5f93dc.tar.gz
Merge topic 'src-flags-genex-target'
303cd703 VS,Xcode: Fix TARGET_PROPERTY genex in source COMPILE_FLAGS property Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Nikita Nemkin <nikita@nemkin.ru> Merge-request: !1336
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx3
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx4
-rw-r--r--Tests/GeneratorExpression/CMakeLists.txt4
-rw-r--r--Tests/GeneratorExpression/echo.c3
-rw-r--r--Tests/GeneratorExpression/srcgenex.c12
6 files changed, 20 insertions, 8 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 304a188f8a..c79ee475c1 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -668,7 +668,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
std::string configName = "NO-PER-CONFIG-SUPPORT-IN-XCODE";
std::unique_ptr<cmCompiledGeneratorExpression> compiledExpr =
ge.Parse(cflags);
- const char* processed = compiledExpr->Evaluate(lg, configName);
+ const char* processed =
+ compiledExpr->Evaluate(lg, configName, false, gtgt);
if (compiledExpr->GetHadContextSensitiveCondition()) {
std::ostringstream e;
/* clang-format off */
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 802719109e..d8030b7fbb 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1454,7 +1454,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
if (const char* cflags = sf.GetProperty("COMPILE_FLAGS")) {
cmGeneratorExpression ge;
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(cflags);
- fc.CompileFlags = cge->Evaluate(lg, *i);
+ fc.CompileFlags = cge->Evaluate(lg, *i, false, gt);
needfc = true;
}
if (lg->FortranProject) {
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 6535008450..eb5a3e4634 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2125,8 +2125,8 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
if (configDependentFlags) {
cmGeneratorExpression ge;
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(flags);
- std::string evaluatedFlags =
- cge->Evaluate(this->LocalGenerator, *config);
+ std::string evaluatedFlags = cge->Evaluate(
+ this->LocalGenerator, *config, false, this->GeneratorTarget);
clOptions.Parse(evaluatedFlags.c_str());
} else {
clOptions.Parse(flags.c_str());
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index 8ac3419120..83fd11d658 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -258,11 +258,13 @@ add_custom_target(check-part4 ALL
VERBATIM
)
+add_executable(srcgenex srcgenex.c)
+set_property(SOURCE srcgenex.c PROPERTY COMPILE_FLAGS "-DNAME=$<TARGET_PROPERTY:NAME>")
+
#-----------------------------------------------------------------------------
# Cover test properties with generator expressions.
add_executable(echo echo.c)
add_executable(pwd pwd.c)
-set_property(SOURCE echo.c PROPERTY COMPILE_FLAGS $<1:-DSRC_GENEX_WORKS>)
add_test(NAME echo-configuration COMMAND echo $<CONFIGURATION>)
set_property(TEST echo-configuration PROPERTY
diff --git a/Tests/GeneratorExpression/echo.c b/Tests/GeneratorExpression/echo.c
index 41596a21d9..06b0844b34 100644
--- a/Tests/GeneratorExpression/echo.c
+++ b/Tests/GeneratorExpression/echo.c
@@ -3,9 +3,6 @@
int main(int argc, char* argv[])
{
-#ifndef SRC_GENEX_WORKS
-#error SRC_GENEX_WORKS not defined
-#endif
printf("%s\n", argv[1]);
return EXIT_SUCCESS;
}
diff --git a/Tests/GeneratorExpression/srcgenex.c b/Tests/GeneratorExpression/srcgenex.c
new file mode 100644
index 0000000000..56d3c3f957
--- /dev/null
+++ b/Tests/GeneratorExpression/srcgenex.c
@@ -0,0 +1,12 @@
+int srcgenex(void)
+{
+ return 0;
+}
+
+int main(int argc, char* argv[])
+{
+#ifndef NAME
+#error NAME not defined
+#endif
+ return NAME();
+}