mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-01 04:08:46 -06:00
export: Allow compatible build-tree exports
Modify how cmExportBuildFileGenerator::FindExportInfo collects target export information to properly record the export sets which export a target. (The old behavior treated every invocation as a separate set, which is reasonable for export(TARGETS) but does not allow referencing a target exported multiple times via export(EXPORT). This reflects recent changes to allow this for installed exports.)
This commit is contained in:
@@ -186,15 +186,20 @@ cmExportFileGenerator::ExportInfo cmExportBuildFileGenerator::FindExportInfo(
|
|||||||
target->GetLocalGenerator()->GetGlobalGenerator()->GetBuildExportSets();
|
target->GetLocalGenerator()->GetGlobalGenerator()->GetBuildExportSets();
|
||||||
|
|
||||||
for (auto const& exp : allExportSets) {
|
for (auto const& exp : allExportSets) {
|
||||||
auto const& exportSet = exp.second;
|
cmExportBuildFileGenerator const* const bfg = exp.second;
|
||||||
|
cmExportSet const* const exportSet = bfg->GetExportSet();
|
||||||
std::vector<TargetExport> targets;
|
std::vector<TargetExport> targets;
|
||||||
exportSet->GetTargets(targets);
|
bfg->GetTargets(targets);
|
||||||
if (std::any_of(
|
if (std::any_of(
|
||||||
targets.begin(), targets.end(),
|
targets.begin(), targets.end(),
|
||||||
[&name](TargetExport const& te) { return te.Name == name; })) {
|
[&name](TargetExport const& te) { return te.Name == name; })) {
|
||||||
exportSets.insert(exp.first);
|
if (exportSet) {
|
||||||
|
exportSets.insert(exportSet->GetName());
|
||||||
|
} else {
|
||||||
|
exportSets.insert(exp.first);
|
||||||
|
}
|
||||||
exportFiles.push_back(exp.first);
|
exportFiles.push_back(exp.first);
|
||||||
namespaces.insert(exportSet->GetNamespace());
|
namespaces.insert(bfg->GetNamespace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
CMake Error in CMakeLists.txt:
|
||||||
|
export called with target "exported" which requires target "doubleexported"
|
||||||
|
that is not in this export set, but in another export set which is exported
|
||||||
|
multiple times with different namespaces:.*
|
||||||
|
.*/Tests/RunCMake/export/DependOnDifferentNamespaceExport-build/export1.cmake,.*
|
||||||
|
.*/Tests/RunCMake/export/DependOnDifferentNamespaceExport-build/export2.cmake.
|
||||||
|
+
|
||||||
|
An exported target cannot depend upon another target which is exported in
|
||||||
|
more than one export set or with more than one namespace. Consider
|
||||||
|
consolidating the exports of the "doubleexported" target to a single
|
||||||
|
export.
|
||||||
|
+
|
||||||
|
CMake Generate step failed. Build files cannot be regenerated correctly.
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
add_library(doubleexported INTERFACE)
|
||||||
|
install(TARGETS doubleexported EXPORT exportset)
|
||||||
|
export(EXPORT exportset
|
||||||
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/export1.cmake")
|
||||||
|
export(EXPORT exportset NAMESPACE test::
|
||||||
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/export2.cmake")
|
||||||
|
add_library(exported INTERFACE)
|
||||||
|
target_link_libraries(exported INTERFACE doubleexported)
|
||||||
|
export(TARGETS exported FILE "${CMAKE_CURRENT_BINARY_DIR}/exports.cmake")
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
CMake Error in CMakeLists.txt:
|
CMake Error in CMakeLists.txt:
|
||||||
export called with target "exported" which requires target "doubleexported"
|
export called with target "exported" which requires target "doubleexported"
|
||||||
that is not in this export set, but in multiple other export sets:.*
|
that is not in this export set, but in multiple other export sets:.*
|
||||||
.*/Tests/RunCMake/export/DependOnDoubleExport-build/exportset.cmake,.*
|
.*/Tests/RunCMake/export/DependOnDifferentSetExport-build/exportset.cmake,.*
|
||||||
.*/Tests/RunCMake/export/DependOnDoubleExport-build/manual.cmake.
|
.*/Tests/RunCMake/export/DependOnDifferentSetExport-build/manual.cmake.
|
||||||
+
|
+
|
||||||
An exported target cannot depend upon another target which is exported in
|
An exported target cannot depend upon another target which is exported in
|
||||||
more than one export set or with more than one namespace. Consider
|
more than one export set or with more than one namespace. Consider
|
||||||
consolidating the exports of the "doubleexported" target to a single
|
consolidating the exports of the "doubleexported" target to a single
|
||||||
export.
|
export.
|
||||||
|
+
|
||||||
|
|
||||||
CMake Generate step failed. Build files cannot be regenerated correctly.
|
CMake Generate step failed. Build files cannot be regenerated correctly.
|
||||||
7
Tests/RunCMake/export/DependOnDifferentSetExport.cmake
Normal file
7
Tests/RunCMake/export/DependOnDifferentSetExport.cmake
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
add_library(doubleexported INTERFACE)
|
||||||
|
install(TARGETS doubleexported EXPORT exportset)
|
||||||
|
export(TARGETS doubleexported FILE "${CMAKE_CURRENT_BINARY_DIR}/manual.cmake")
|
||||||
|
export(EXPORT exportset FILE "${CMAKE_CURRENT_BINARY_DIR}/exportset.cmake")
|
||||||
|
add_library(exported INTERFACE)
|
||||||
|
target_link_libraries(exported INTERFACE doubleexported)
|
||||||
|
export(TARGETS exported FILE "${CMAKE_CURRENT_BINARY_DIR}/exports.cmake")
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
add_library(doubleexported INTERFACE)
|
add_library(doubleexported INTERFACE)
|
||||||
install(TARGETS doubleexported EXPORT exportset)
|
install(TARGETS doubleexported EXPORT exportset)
|
||||||
export(TARGETS doubleexported FILE "${CMAKE_CURRENT_BINARY_DIR}/manual.cmake")
|
export(EXPORT exportset FILE "${CMAKE_CURRENT_BINARY_DIR}/export1.cmake")
|
||||||
export(EXPORT exportset FILE "${CMAKE_CURRENT_BINARY_DIR}/exportset.cmake")
|
export(EXPORT exportset FILE "${CMAKE_CURRENT_BINARY_DIR}/export2.cmake")
|
||||||
add_library(exported INTERFACE)
|
add_library(exported INTERFACE)
|
||||||
target_link_libraries(exported INTERFACE doubleexported)
|
target_link_libraries(exported INTERFACE doubleexported)
|
||||||
export(TARGETS exported FILE "${CMAKE_CURRENT_BINARY_DIR}/exports.cmake")
|
export(TARGETS exported FILE "${CMAKE_CURRENT_BINARY_DIR}/exports.cmake")
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ run_cmake(ForbiddenToExportPropertyWithGenExp)
|
|||||||
run_cmake(ExportPropertiesUndefined)
|
run_cmake(ExportPropertiesUndefined)
|
||||||
run_cmake(DependOnNotExport)
|
run_cmake(DependOnNotExport)
|
||||||
run_cmake(DependOnDoubleExport)
|
run_cmake(DependOnDoubleExport)
|
||||||
|
run_cmake(DependOnDifferentSetExport)
|
||||||
|
run_cmake(DependOnDifferentNamespaceExport)
|
||||||
run_cmake(UnknownExport)
|
run_cmake(UnknownExport)
|
||||||
run_cmake(NamelinkOnlyExport)
|
run_cmake(NamelinkOnlyExport)
|
||||||
run_cmake(SeparateNamelinkExport)
|
run_cmake(SeparateNamelinkExport)
|
||||||
|
|||||||
Reference in New Issue
Block a user