From bf114602daf09031ec7cf524758e95439bf21627 Mon Sep 17 00:00:00 2001 From: Deniz Bahadir Date: Fri, 18 Sep 2020 14:48:33 +0200 Subject: install(EXPORT): Fix exporting target w/ source named using CONFIG genex Fixes: #21203 --- Source/cmExportFileGenerator.cxx | 4 +--- Tests/ExportImport/Export/CMakeLists.txt | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 58aa391..cbae4e5 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -565,11 +565,9 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( ifaceProperties); if (gtarget->GetType() != cmStateEnums::INTERFACE_LIBRARY) { - getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); - std::vector configNames = gtarget->Target->GetMakefile()->GetGeneratorConfigs( - cmMakefile::ExcludeEmptyConfig); + cmMakefile::IncludeEmptyConfig); for (std::string const& cn : configNames) { getCompatibleInterfaceProperties(gtarget, ifaceProperties, cn); diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 387fe6b..6d9b4ab 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -669,3 +669,18 @@ endif() # IMPORTED_LINK_INTERFACE_LANGUAGES entries should not be targets. add_library(C INTERFACE) add_library(CXX INTERFACE) + +#------------------------------------------------------------------------------ +# test export of targets built from sources named using $ generator-expression +# FIXME: Enable test on Xcode generator when it supports per-config sources. +if(NOT XCODE) + file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/Generated_$.cpp" CONTENT "// content") + add_library(testStaticFromGeneratedSource STATIC) + target_sources(testStaticFromGeneratedSource PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/Generated_$.cpp") + + add_library(testLibFromGeneratedSource SHARED empty.cpp) + target_link_libraries(testLibFromGeneratedSource PRIVATE testStaticFromGeneratedSource) + + install(TARGETS testLibFromGeneratedSource EXPORT testLibFromGeneratedSource_Export) + install(EXPORT testLibFromGeneratedSource_Export DESTINATION lib) +endif() -- cgit v0.12