소스 검색

Merge branch 'ninja-multi-per-config-sources' into release-3.18

Merge-request: !5430
Brad King 5 년 전
부모
커밋
e9109dec36

+ 3 - 1
Source/cmGlobalNinjaGenerator.cxx

@@ -1202,7 +1202,9 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
   std::string outputPath = this->NinjaOutputPath(alias);
   std::string outputPath = this->NinjaOutputPath(alias);
   std::string buildAlias = this->BuildAlias(outputPath, config);
   std::string buildAlias = this->BuildAlias(outputPath, config);
   cmNinjaDeps outputs;
   cmNinjaDeps outputs;
-  this->AppendTargetOutputs(target, outputs, config);
+  if (config != "all") {
+    this->AppendTargetOutputs(target, outputs, config);
+  }
   // Mark the target's outputs as ambiguous to ensure that no other target
   // Mark the target's outputs as ambiguous to ensure that no other target
   // uses the output as an alias.
   // uses the output as an alias.
   for (std::string const& output : outputs) {
   for (std::string const& output : outputs) {

+ 8 - 0
Tests/RunCMake/NinjaMultiConfig/PerConfigSources.cmake

@@ -0,0 +1,8 @@
+enable_language(C)
+file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/main_$<CONFIG>.c" CONTENT
+[[int main(void)
+{
+  return 0;
+}
+]])
+add_executable(exe "${CMAKE_BINARY_DIR}/main_$<CONFIG>.c")

+ 4 - 0
Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake

@@ -246,6 +246,10 @@ unset(RunCMake_TEST_BINARY_DIR)
 
 
 run_cmake(CustomCommandDepfile)
 run_cmake(CustomCommandDepfile)
 
 
+set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all")
+run_cmake(PerConfigSources)
+unset(RunCMake_TEST_OPTIONS)
+
 set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/PostfixAndLocation-build)
 set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/PostfixAndLocation-build)
 set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_CROSS_CONFIGS=all")
 set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_CROSS_CONFIGS=all")
 run_cmake_configure(PostfixAndLocation)
 run_cmake_configure(PostfixAndLocation)