summaryrefslogtreecommitdiffstats
path: root/Tests/Fortran
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/Fortran')
-rw-r--r--Tests/Fortran/CMakeLists.txt19
-rw-r--r--Tests/Fortran/hello.f4
-rw-r--r--Tests/Fortran/testf.f7
-rw-r--r--Tests/Fortran/world.def2
-rw-r--r--Tests/Fortran/world.f6
5 files changed, 35 insertions, 3 deletions
diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt
index adcadd4..709ea5f 100644
--- a/Tests/Fortran/CMakeLists.txt
+++ b/Tests/Fortran/CMakeLists.txt
@@ -7,8 +7,25 @@ message("CMAKE_Fortran_COMPILER_INIT = ${CMAKE_Fortran_COMPILER_INIT}")
message("CMAKE_Fortran_COMPILER_FULLPATH = ${CMAKE_Fortran_COMPILER_FULLPATH}")
message("CMAKE_Fortran_COMPILER = ${CMAKE_Fortran_COMPILER}")
message("CMAKE_Fortran_FLAGS = ${CMAKE_Fortran_FLAGS}")
-add_executable(testf hello.f)
+set(_SHARED SHARED)
+if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(XL|VisualAge)$")
+ # We do not implement SHARED Fortran libs on AIX yet!
+ # Workaround: Set LINKER_LANGUAGE to C, which uses 'xlc' and Fortran implicits.
+ set(_SHARED STATIC)
+elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
+ # g77 2.96 does not support shared libs on Itanium because g2c is not -fPIC
+ execute_process(COMMAND ${CMAKE_Fortran_COMPILER} --version
+ OUTPUT_VARIABLE output ERROR_VARIABLE output)
+ if("${output}" MATCHES "Red Hat .* 2\\.96")
+ set(_SHARED STATIC)
+ endif()
+endif()
+
+add_library(hello STATIC hello.f)
+add_library(world ${_SHARED} world.f world.def)
+add_executable(testf testf.f)
+target_link_libraries(testf hello world)
function(test_fortran_c_interface_module)
message(STATUS "Testing FortranCInterface module")
diff --git a/Tests/Fortran/hello.f b/Tests/Fortran/hello.f
index c9ee3c2..aa0de77 100644
--- a/Tests/Fortran/hello.f
+++ b/Tests/Fortran/hello.f
@@ -1,6 +1,6 @@
- PROGRAM GREETINGS
+ SUBROUTINE HELLO
- PRINT *, 'Real programmers write Fortran!'
+ PRINT *, 'Hello'
END
diff --git a/Tests/Fortran/testf.f b/Tests/Fortran/testf.f
new file mode 100644
index 0000000..abf6c6d
--- /dev/null
+++ b/Tests/Fortran/testf.f
@@ -0,0 +1,7 @@
+ PROGRAM TESTF
+
+ CALL HELLO()
+ CALL WORLD()
+
+ END
+
diff --git a/Tests/Fortran/world.def b/Tests/Fortran/world.def
new file mode 100644
index 0000000..ead7710
--- /dev/null
+++ b/Tests/Fortran/world.def
@@ -0,0 +1,2 @@
+EXPORTS
+ WORLD
diff --git a/Tests/Fortran/world.f b/Tests/Fortran/world.f
new file mode 100644
index 0000000..0487dff
--- /dev/null
+++ b/Tests/Fortran/world.f
@@ -0,0 +1,6 @@
+ SUBROUTINE WORLD
+
+ PRINT *, 'World!'
+
+ END
+