summaryrefslogtreecommitdiffstats
path: root/Tests/FortranOnly
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2023-07-21 20:46:06 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2023-07-22 10:53:36 (GMT)
commit2870a6754085b981d72236c3b716627929e2d9b4 (patch)
treec5a3ccf29ade4e47cfc18c2ad6ab51c0bc3143cb /Tests/FortranOnly
parent3ea7204de47d78b1aa8ee3cddfa59d034fc601d8 (diff)
downloadCMake-2870a6754085b981d72236c3b716627929e2d9b4.zip
CMake-2870a6754085b981d72236c3b716627929e2d9b4.tar.gz
CMake-2870a6754085b981d72236c3b716627929e2d9b4.tar.bz2
Tests/FortranOnly: add a test case for issue #25112
Add a test case for Fortran `OBJECT` libraries providing modules to consumers.
Diffstat (limited to 'Tests/FortranOnly')
-rw-r--r--Tests/FortranOnly/CMakeLists.txt6
-rw-r--r--Tests/FortranOnly/objmain.f905
-rw-r--r--Tests/FortranOnly/objmod.f907
3 files changed, 18 insertions, 0 deletions
diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt
index ed2a440..b092c42 100644
--- a/Tests/FortranOnly/CMakeLists.txt
+++ b/Tests/FortranOnly/CMakeLists.txt
@@ -184,3 +184,9 @@ if(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF AND
set_property(TARGET no_preprocess_target PROPERTY Fortran_PREPROCESS OFF)
set_property(SOURCE no_preprocess_source_upper.F no_preprocess_source_fpp.fpp PROPERTY Fortran_PREPROCESS OFF)
endif()
+
+# Issue 25112
+set(CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include")
+add_library(objmod OBJECT objmod.f90)
+add_executable(objmain objmain.f90)
+target_link_libraries(objmain PRIVATE objmod)
diff --git a/Tests/FortranOnly/objmain.f90 b/Tests/FortranOnly/objmain.f90
new file mode 100644
index 0000000..d41d454
--- /dev/null
+++ b/Tests/FortranOnly/objmain.f90
@@ -0,0 +1,5 @@
+program main
+ use objmod, only : hello
+ implicit none
+ call hello()
+end program
diff --git a/Tests/FortranOnly/objmod.f90 b/Tests/FortranOnly/objmod.f90
new file mode 100644
index 0000000..6b79cc7
--- /dev/null
+++ b/Tests/FortranOnly/objmod.f90
@@ -0,0 +1,7 @@
+module objmod
+ implicit none
+contains
+ subroutine hello()
+ print '(a)', "hello world"
+ end subroutine hello
+end module objmod