Browse Source

Genex: Fix TARGET_PROPERTY value of SOURCES

Refactoring in commit v3.8.0-rc1~445^2~2 (cmTarget: Move sanity checks
and computed property access to callers, 2016-10-13) exposed a typo in
commit v3.8.0-rc1~445^2~3 (cmGeneratorTarget: Implement
cmTargetPropertyComputer interface, 2016-10-13).  Together they broke
the `$<TARGET_PROPERTY:mytgt,SOURCES>` generator expression in the case
that the `SOURCES` target property is populated in part by the
`target_sources` command.  Add the missing `;`-separator.

Fixes: #17243
Brad King 8 years ago
parent
commit
068cc545d9

+ 1 - 1
Source/cmGeneratorTarget.cxx

@@ -158,7 +158,7 @@ const char* cmGeneratorTarget::GetSourcesProperty() const
   }
   static std::string value;
   value.clear();
-  value = cmJoin(values, "");
+  value = cmJoin(values, ";");
   return value.c_str();
 }
 

+ 1 - 0
Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake

@@ -32,6 +32,7 @@ run_cmake(COMPILE_LANGUAGE-unknown-lang)
 run_cmake(TARGET_FILE-recursion)
 run_cmake(OUTPUT_NAME-recursion)
 run_cmake(TARGET_PROPERTY-LOCATION)
+run_cmake(TARGET_PROPERTY-SOURCES)
 run_cmake(LINK_ONLY-not-linking)
 
 run_cmake(ImportedTarget-TARGET_BUNDLE_DIR)

+ 9 - 0
Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES-check.cmake

@@ -0,0 +1,9 @@
+file(READ ${RunCMake_TEST_BINARY_DIR}/foo.txt foo_sources)
+
+# VS generators inject CMakeLists.txt as a source.  Remove it.
+string(REGEX REPLACE ";[^;]*CMakeLists.txt$" "" foo_sources "${foo_sources}")
+
+set(foo_expected "empty.c;empty2.c;empty3.c")
+if(NOT foo_sources STREQUAL foo_expected)
+  set(RunCMake_TEST_FAILED "foo SOURCES was:\n [[${foo_sources}]]\nbut expected:\n [[${foo_expected}]]")
+endif()

+ 5 - 0
Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake

@@ -0,0 +1,5 @@
+cmake_policy(SET CMP0070 NEW)
+enable_language(C)
+add_library(foo empty.c empty2.c)
+target_sources(foo PRIVATE empty3.c)
+file(GENERATE OUTPUT foo.txt CONTENT "$<TARGET_PROPERTY:foo,SOURCES>")

+ 0 - 0
Tests/RunCMake/GeneratorExpression/empty2.c


+ 0 - 0
Tests/RunCMake/GeneratorExpression/empty3.c