summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2023-11-17 15:53:34 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2023-11-21 14:17:36 (GMT)
commit7c1e52be875548c243168a5630a054e84b47026a (patch)
tree43ba341a7b19e522935ec2cfccb18b9ac0c8d3ae
parent9cfff766eb26ab8b29aa509e42d6b367dd00c7b7 (diff)
downloadCMake-7c1e52be875548c243168a5630a054e84b47026a.zip
CMake-7c1e52be875548c243168a5630a054e84b47026a.tar.gz
CMake-7c1e52be875548c243168a5630a054e84b47026a.tar.bz2
Tests/FortranModules: add test for TARGET_OBJECTS-as-sources module usage
Test module usage across a `$<TARGET_OBJECTS>`-as-sources use case. See: #25425
-rw-r--r--Tests/FortranModules/CMakeLists.txt4
-rw-r--r--Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/CMakeLists.txt6
-rw-r--r--Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/CMakeLists.txt1
-rw-r--r--Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/obj.f9011
-rw-r--r--Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/use.f9013
-rw-r--r--Tests/FortranModules/ModulesViaTargetObjectsSource/CMakeLists.txt4
-rw-r--r--Tests/FortranModules/ModulesViaTargetObjectsSource/obj.f9011
-rw-r--r--Tests/FortranModules/ModulesViaTargetObjectsSource/use.f9013
8 files changed, 63 insertions, 0 deletions
diff --git a/Tests/FortranModules/CMakeLists.txt b/Tests/FortranModules/CMakeLists.txt
index 16ea0d4..8e95152e 100644
--- a/Tests/FortranModules/CMakeLists.txt
+++ b/Tests/FortranModules/CMakeLists.txt
@@ -137,3 +137,7 @@ add_subdirectory(Issue25252-iface-sources)
add_subdirectory(Issue25365-target-objects)
add_subdirectory(Issue25365-target-objects-iface)
+
+# Issue#25425
+add_subdirectory(ModulesViaTargetObjectsSource)
+add_subdirectory(ModulesViaSubdirTargetObjectsSource)
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/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