From 29c7546a6150b951d5d8e3819ec937dd1a9ad7bc Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 13 Jul 2022 10:22:26 -0400 Subject: 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 --- Source/cmGlobalGenerator.cxx | 4 +++- Tests/RunCMake/export/RunCMakeTest.cmake | 1 + Tests/RunCMake/export/TryCompileExport.cmake | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/export/TryCompileExport.cmake diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 156ecce..c75198d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/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( diff --git a/Tests/RunCMake/export/RunCMakeTest.cmake b/Tests/RunCMake/export/RunCMakeTest.cmake index 0e6020f..ee00b27 100644 --- a/Tests/RunCMake/export/RunCMakeTest.cmake +++ b/Tests/RunCMake/export/RunCMakeTest.cmake @@ -18,3 +18,4 @@ run_cmake(DependOnDoubleExport) run_cmake(UnknownExport) run_cmake(NamelinkOnlyExport) run_cmake(SeparateNamelinkExport) +run_cmake(TryCompileExport) diff --git a/Tests/RunCMake/export/TryCompileExport.cmake b/Tests/RunCMake/export/TryCompileExport.cmake new file mode 100644 index 0000000..5ad7c6e --- /dev/null +++ b/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) -- cgit v0.12