diff options
author | Brad King <brad.king@kitware.com> | 2023-11-27 13:38:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-11-27 13:38:19 (GMT) |
commit | e332f7f666622d5dc2d1c4eda001c1e6b4b7bcfe (patch) | |
tree | dd31d1364f8939bfdb435eac4696646f4ca497cc | |
parent | 34afeb625f932002ddafb87ad2731f6f2bc8f613 (diff) | |
parent | ec1e589bec6567c955db24adeb6294258e3db463 (diff) | |
download | CMake-e332f7f666622d5dc2d1c4eda001c1e6b4b7bcfe.zip CMake-e332f7f666622d5dc2d1c4eda001c1e6b4b7bcfe.tar.gz CMake-e332f7f666622d5dc2d1c4eda001c1e6b4b7bcfe.tar.bz2 |
Merge branch 'revert-exact-collation-depends-3.27' into release-3.27
Merge-request: !8996
18 files changed, 143 insertions, 9 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index d712d71..bc04d1f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1034,11 +1034,6 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( cmNinjaBuild build(this->LanguageDyndepRule(language, config)); build.Outputs.push_back(this->GetDyndepFilePath(language, config)); - build.ImplicitOuts.push_back( - cmStrCat(this->Makefile->GetCurrentBinaryDirectory(), '/', - this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), - this->GetGlobalGenerator()->ConfigDirectory(config), '/', - language, "Modules.json")); for (auto const& scanFiles : scanningFiles) { if (!scanFiles.ScanningOutput.empty()) { build.ExplicitDeps.push_back(scanFiles.ScanningOutput); @@ -1050,10 +1045,17 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( this->WriteTargetDependInfo(language, config); - for (std::string const& l : - this->GetLinkedTargetDirectories(language, config)) { - build.ImplicitDeps.push_back(cmStrCat(l, '/', language, "Modules.json")); - } + // Make sure dyndep files for all our dependencies have already + // been generated so that the '<LANG>Modules.json' files they + // produced as side-effects are available for us to read. + // Ideally we should depend on the '<LANG>Modules.json' files + // from our dependencies directly, but we don't know which of + // our dependencies produces them. Fixing this will require + // refactoring the Ninja generator to generate targets in + // dependency order so that we can collect the needed information. + this->GetLocalGenerator()->AppendTargetDepends( + this->GeneratorTarget, build.OrderOnlyDeps, config, fileConfig, + DependOnTargetArtifact); this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig), build); diff --git a/Tests/FortranModules/CMakeLists.txt b/Tests/FortranModules/CMakeLists.txt index 16ea0d4..1e5ff89 100644 --- a/Tests/FortranModules/CMakeLists.txt +++ b/Tests/FortranModules/CMakeLists.txt @@ -137,3 +137,9 @@ add_subdirectory(Issue25252-iface-sources) add_subdirectory(Issue25365-target-objects) add_subdirectory(Issue25365-target-objects-iface) + +# Issue#25425 +add_subdirectory(ModulesViaTargetObjectsSource) +add_subdirectory(ModulesViaSubdirTargetObjectsSource) +add_subdirectory(ModulesViaTargetObjectsLink) +add_subdirectory(ModulesViaSubdirTargetObjectsLink) diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/CMakeLists.txt b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/CMakeLists.txt new file mode 100644 index 0000000..b52b423 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/CMakeLists.txt @@ -0,0 +1,7 @@ +add_subdirectory(subdir) + +add_library(mvstol_lib dummy.f90) +target_link_libraries(mvstol_lib PRIVATE "$<TARGET_OBJECTS:mvstol_obj>") +target_include_directories(mvstol_lib PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/subdir") +add_library(mvstol_use use.f90) +target_link_libraries(mvstol_use PRIVATE mvstol_lib) diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/dummy.f90 b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/dummy.f90 new file mode 100644 index 0000000..96a8138 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/dummy.f90 @@ -0,0 +1,3 @@ +pure real function dummy() +dummy = 4*atan(1.) +end function diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/CMakeLists.txt b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/CMakeLists.txt new file mode 100644 index 0000000..b2a250d --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/CMakeLists.txt @@ -0,0 +1 @@ +add_library(mvstol_obj STATIC obj.f90) diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/obj.f90 b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/obj.f90 new file mode 100644 index 0000000..6b5ddd5 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/obj.f90 @@ -0,0 +1,11 @@ +module m1 + +implicit none + +contains + +pure real function pi() +pi = 4*atan(1.) +end function + +end module m1 diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/use.f90 b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/use.f90 new file mode 100644 index 0000000..f971909 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/use.f90 @@ -0,0 +1,13 @@ +module lib + +use m1, only : pi + +implicit none + +contains + +pure real function func() +func = pi() +end function + +end module diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/CMakeLists.txt b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/CMakeLists.txt new file mode 100644 index 0000000..255e8a7 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/CMakeLists.txt @@ -0,0 +1,6 @@ +add_subdirectory(subdir) + +add_library(mvstos_lib "$<TARGET_OBJECTS:mvstos_obj>") +target_include_directories(mvstos_lib PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/subdir") +add_library(mvstos_use use.f90) +target_link_libraries(mvstos_use PRIVATE mvstos_lib) diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/CMakeLists.txt b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/CMakeLists.txt new file mode 100644 index 0000000..acc0da9 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/CMakeLists.txt @@ -0,0 +1 @@ +add_library(mvstos_obj OBJECT obj.f90) diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/obj.f90 b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/obj.f90 new file mode 100644 index 0000000..6b5ddd5 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/obj.f90 @@ -0,0 +1,11 @@ +module m1 + +implicit none + +contains + +pure real function pi() +pi = 4*atan(1.) +end function + +end module m1 diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/use.f90 b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/use.f90 new file mode 100644 index 0000000..f971909 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/use.f90 @@ -0,0 +1,13 @@ +module lib + +use m1, only : pi + +implicit none + +contains + +pure real function func() +func = pi() +end function + +end module diff --git a/Tests/FortranModules/ModulesViaTargetObjectsLink/CMakeLists.txt b/Tests/FortranModules/ModulesViaTargetObjectsLink/CMakeLists.txt new file mode 100644 index 0000000..202e59e --- /dev/null +++ b/Tests/FortranModules/ModulesViaTargetObjectsLink/CMakeLists.txt @@ -0,0 +1,5 @@ +add_library(mvtol_obj STATIC obj.f90) +add_library(mvtol_lib dummy.f90) +target_link_libraries(mvtol_lib PRIVATE "$<TARGET_OBJECTS:mvtol_obj>") +add_library(mvtol_use use.f90) +target_link_libraries(mvtol_use PRIVATE mvtol_lib) diff --git a/Tests/FortranModules/ModulesViaTargetObjectsLink/dummy.f90 b/Tests/FortranModules/ModulesViaTargetObjectsLink/dummy.f90 new file mode 100644 index 0000000..96a8138 --- /dev/null +++ b/Tests/FortranModules/ModulesViaTargetObjectsLink/dummy.f90 @@ -0,0 +1,3 @@ +pure real function dummy() +dummy = 4*atan(1.) +end function diff --git a/Tests/FortranModules/ModulesViaTargetObjectsLink/obj.f90 b/Tests/FortranModules/ModulesViaTargetObjectsLink/obj.f90 new file mode 100644 index 0000000..6b5ddd5 --- /dev/null +++ b/Tests/FortranModules/ModulesViaTargetObjectsLink/obj.f90 @@ -0,0 +1,11 @@ +module m1 + +implicit none + +contains + +pure real function pi() +pi = 4*atan(1.) +end function + +end module m1 diff --git a/Tests/FortranModules/ModulesViaTargetObjectsLink/use.f90 b/Tests/FortranModules/ModulesViaTargetObjectsLink/use.f90 new file mode 100644 index 0000000..f971909 --- /dev/null +++ b/Tests/FortranModules/ModulesViaTargetObjectsLink/use.f90 @@ -0,0 +1,13 @@ +module lib + +use m1, only : pi + +implicit none + +contains + +pure real function func() +func = pi() +end function + +end module diff --git a/Tests/FortranModules/ModulesViaTargetObjectsSource/CMakeLists.txt b/Tests/FortranModules/ModulesViaTargetObjectsSource/CMakeLists.txt new file mode 100644 index 0000000..9113a11 --- /dev/null +++ b/Tests/FortranModules/ModulesViaTargetObjectsSource/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(mvtos_obj OBJECT obj.f90) +add_library(mvtos_lib "$<TARGET_OBJECTS:mvtos_obj>") +add_library(mvtos_use use.f90) +target_link_libraries(mvtos_use PRIVATE mvtos_lib) diff --git a/Tests/FortranModules/ModulesViaTargetObjectsSource/obj.f90 b/Tests/FortranModules/ModulesViaTargetObjectsSource/obj.f90 new file mode 100644 index 0000000..6b5ddd5 --- /dev/null +++ b/Tests/FortranModules/ModulesViaTargetObjectsSource/obj.f90 @@ -0,0 +1,11 @@ +module m1 + +implicit none + +contains + +pure real function pi() +pi = 4*atan(1.) +end function + +end module m1 diff --git a/Tests/FortranModules/ModulesViaTargetObjectsSource/use.f90 b/Tests/FortranModules/ModulesViaTargetObjectsSource/use.f90 new file mode 100644 index 0000000..f971909 --- /dev/null +++ b/Tests/FortranModules/ModulesViaTargetObjectsSource/use.f90 @@ -0,0 +1,13 @@ +module lib + +use m1, only : pi + +implicit none + +contains + +pure real function func() +func = pi() +end function + +end module |