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:43 (GMT)
commit9d2769ecbd497dd51405ae2586ae62b828712a07 (patch)
tree301f75e0a5dc9f8816a683d35926b203fa75463c
parent7c1e52be875548c243168a5630a054e84b47026a (diff)
downloadCMake-9d2769ecbd497dd51405ae2586ae62b828712a07.zip
CMake-9d2769ecbd497dd51405ae2586ae62b828712a07.tar.gz
CMake-9d2769ecbd497dd51405ae2586ae62b828712a07.tar.bz2
Tests/FortranModules: add test for TARGET_OBJECTS-as-linked-items module usage
Test module usage across a `$<TARGET_OBJECTS>`-as-linked-items use case. See: #25425
-rw-r--r--Tests/FortranModules/CMakeLists.txt2
-rw-r--r--Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/CMakeLists.txt7
-rw-r--r--Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/dummy.f903
-rw-r--r--Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/CMakeLists.txt1
-rw-r--r--Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/obj.f9011
-rw-r--r--Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/use.f9013
-rw-r--r--Tests/FortranModules/ModulesViaTargetObjectsLink/CMakeLists.txt5
-rw-r--r--Tests/FortranModules/ModulesViaTargetObjectsLink/dummy.f903
-rw-r--r--Tests/FortranModules/ModulesViaTargetObjectsLink/obj.f9011
-rw-r--r--Tests/FortranModules/ModulesViaTargetObjectsLink/use.f9013
10 files changed, 69 insertions, 0 deletions
diff --git a/Tests/FortranModules/CMakeLists.txt b/Tests/FortranModules/CMakeLists.txt
index 8e95152e..1e5ff89 100644
--- a/Tests/FortranModules/CMakeLists.txt
+++ b/Tests/FortranModules/CMakeLists.txt
@@ -141,3 +141,5 @@ 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/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