Skip to content

Commit 161d9e7

Browse files
authored
document custom module directory (#170)
1 parent 7d07ad9 commit 161d9e7

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

pages/spec/manifest.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ Development dependencies allow to declare *dev-dependencies* in the manifest roo
623623
## Installation configuration
624624

625625
In the *install* section components for the installation can be selected.
626-
By default only executables are installed, library projects can set the *library* boolean to also installatation the module files and the archive.
626+
By default only executables are installed, library projects can set the *library* boolean to also install the module files and the archive.
627627

628628
*Example*
629629

@@ -632,6 +632,50 @@ By default only executables are installed, library projects can set the *library
632632
library = true
633633
```
634634

635+
### Custom module directory
636+
637+
:::{note}
638+
Available since fpm v0.14.0
639+
:::
640+
641+
Fortran projects generate compiled module files (`.mod`) during compilation, which contain interface information needed by other modules that use them. By default, fpm installs these module files to the `include/` directory within the installation prefix.
642+
643+
You can customize the installation directory for module files using the *module-dir* entry:
644+
645+
```toml
646+
[install]
647+
library = true
648+
module-dir = "modules"
649+
```
650+
651+
This is particularly useful for:
652+
653+
- **Separating module files from C headers**: Keep Fortran `.mod` files separate from C/C++ header files
654+
- **Following system conventions**: Some systems expect module files in specific directories (e.g., `/usr/lib/gfortran/modules/`)
655+
- **Organizing complex projects**: Large projects with many modules can benefit from dedicated module directories
656+
657+
*Example with custom module directory:*
658+
659+
```toml
660+
[install]
661+
library = true
662+
module-dir = "fortran/modules"
663+
```
664+
665+
The module directory path is relative to the installation prefix. For example, with an installation prefix of `/usr/local`, the above configuration would install module files to `/usr/local/fortran/modules/`.
666+
667+
*Example installation layout:*
668+
669+
```text
670+
/usr/local/
671+
├── bin/ # Executables
672+
├── lib/ # Library archives (.a, .so, .dll)
673+
└── fortran/
674+
└── modules/ # Fortran module files (.mod)
675+
```
676+
677+
If *module-dir* is not specified, module files are installed to the default `include/` directory alongside any header files, maintaining backward compatibility.
678+
635679
## Preprocessor configuration
636680

637681
Under the *preprocess* section, you can specify one or more preprocessor to use in an fpm project.

0 commit comments

Comments
 (0)