Skip to content

Commit 01872bd

Browse files
committed
add example package
1 parent 388108d commit 01872bd

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Custom Module Directory Example
2+
3+
This example demonstrates the use of a custom module directory in the `[install]` section of `fpm.toml`.
4+
5+
## Features
6+
7+
- Two simple Fortran modules: `greeting` and `math_utils`
8+
- Custom module installation directory specified as `custom/modules`
9+
- Shows how modules can be installed to a different location than headers
10+
11+
## Configuration
12+
13+
In `fpm.toml`:
14+
15+
```toml
16+
[install]
17+
library = true
18+
module-dir = "custom/modules"
19+
```
20+
21+
This configuration will install compiled `.mod` files to the `custom/modules` directory instead of the default `include` directory.
22+
23+
## Testing
24+
25+
To test this example:
26+
27+
```bash
28+
cd example_packages/custom_module_dir
29+
fpm build
30+
fpm install --prefix /tmp/test_install
31+
# Check that .mod files are in /tmp/test_install/custom/modules/
32+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name = "custom-module-dir"
2+
install.library = true
3+
install.module-dir = "custom/modules"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module greeting
2+
implicit none
3+
private
4+
public :: say_hello
5+
6+
contains
7+
8+
subroutine say_hello(name)
9+
character(len=*), intent(in) :: name
10+
print *, 'Hello, ' // name // '!'
11+
end subroutine say_hello
12+
13+
end module greeting
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module math_utils
2+
implicit none
3+
private
4+
public :: add_numbers, multiply_numbers
5+
6+
contains
7+
8+
function add_numbers(a, b) result(sum)
9+
integer, intent(in) :: a, b
10+
integer :: sum
11+
sum = a + b
12+
end function add_numbers
13+
14+
function multiply_numbers(a, b) result(product)
15+
integer, intent(in) :: a, b
16+
integer :: product
17+
product = a * b
18+
end function multiply_numbers
19+
20+
end module math_utils

0 commit comments

Comments
 (0)