diff options
| author | ruki <[email protected]> | 2020-07-05 10:38:35 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-07-05 10:38:35 +0800 |
| commit | c0842437b9cb2116284818d56a52e1a60bc68663 (patch) | |
| tree | 99606b7bac7d846dc18a9561f0c5a2bd21a1563f | |
| parent | c14bfc6fa4e30b2a2af6cb7500bd7b7c16896472 (diff) | |
add fortran shared library tests
| -rw-r--r-- | tests/projects/fortran/shared_library/src/main.f90 | 5 | ||||
| -rw-r--r-- | tests/projects/fortran/shared_library/src/test.f90 | 8 | ||||
| -rw-r--r-- | tests/projects/fortran/shared_library/xmake.lua | 11 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gfortran.lua | 16 |
4 files changed, 40 insertions, 0 deletions
diff --git a/tests/projects/fortran/shared_library/src/main.f90 b/tests/projects/fortran/shared_library/src/main.f90 new file mode 100644 index 000000000..9adea3e26 --- /dev/null +++ b/tests/projects/fortran/shared_library/src/main.f90 @@ -0,0 +1,5 @@ +program hello + use test, only: print_hello + implicit none (type, external) + call print_hello() +end program hello diff --git a/tests/projects/fortran/shared_library/src/test.f90 b/tests/projects/fortran/shared_library/src/test.f90 new file mode 100644 index 000000000..b1e97a36c --- /dev/null +++ b/tests/projects/fortran/shared_library/src/test.f90 @@ -0,0 +1,8 @@ +module test + implicit none (type, external) + +contains + subroutine print_hello() + print *, "Hello World!" + end subroutine print_hello +end module test diff --git a/tests/projects/fortran/shared_library/xmake.lua b/tests/projects/fortran/shared_library/xmake.lua new file mode 100644 index 000000000..7bc4e77f1 --- /dev/null +++ b/tests/projects/fortran/shared_library/xmake.lua @@ -0,0 +1,11 @@ +add_rules("mode.debug", "mode.release") + +target("testlib") + set_kind("shared") + add_files("src/test.f90") + +target("test") + set_kind("binary") + add_deps("testlib") + add_files("src/main.f90") + diff --git a/xmake/modules/core/tools/gfortran.lua b/xmake/modules/core/tools/gfortran.lua index 16a6dfdb6..aab8848ac 100644 --- a/xmake/modules/core/tools/gfortran.lua +++ b/xmake/modules/core/tools/gfortran.lua @@ -20,3 +20,19 @@ -- inherit gcc inherit("gcc") + +-- init it +function init(self) + + -- init super + _super.init(self) + + -- init shflags + self:set("fcshflags", "-shared") + + -- add -fPIC for shared + if not is_plat("windows", "mingw") then + self:add("fcshflags", "-fPIC") + self:add("shared.fcflags", "-fPIC") + end +end |
