Bladeren bron

cmGlobalGenerator: Only compute build files for all targets

If we're creating generation objects for imported targets only, we
don't need the export sets. Only compute build file generators
if generating for all targets.

Fixes: #23709
Kyle Edwards 3 jaren geleden
bovenliggende
commit
29c7546a61

+ 3 - 1
Source/cmGlobalGenerator.cxx

@@ -1361,7 +1361,9 @@ void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes)
     this->CheckTargetProperties();
   }
   this->CreateGeneratorTargets(targetTypes);
-  this->ComputeBuildFileGenerators();
+  if (targetTypes == TargetTypes::AllTargets) {
+    this->ComputeBuildFileGenerators();
+  }
 }
 
 void cmGlobalGenerator::CreateImportedGenerationObjects(

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

@@ -18,3 +18,4 @@ run_cmake(DependOnDoubleExport)
 run_cmake(UnknownExport)
 run_cmake(NamelinkOnlyExport)
 run_cmake(SeparateNamelinkExport)
+run_cmake(TryCompileExport)

+ 9 - 0
Tests/RunCMake/export/TryCompileExport.cmake

@@ -0,0 +1,9 @@
+enable_language(CXX)
+
+add_library(interface INTERFACE)
+install(TARGETS interface EXPORT export)
+export(EXPORT export)
+
+add_library(imported IMPORTED INTERFACE)
+
+try_compile(tc "${CMAKE_CURRENT_BINARY_DIR}/tc" "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" LINK_LIBRARIES imported)