Description
Motivation
Not all parts of a project are always needed. Many Fortran projects can be build with and without MPI support for example. Currently there is no mechanism to express such features in the package manifest. An option is to rely on preprocessor and set reasonable default using constructs like shown below:
#ifndef WITH_FEATURE
#define WITH_FEATURE 0
#endif
Since preprocessor might be the easiest way to express project local optional features, we could include such mechanism in fpm.
Specification
A project could declare a features table and export this to the project via a preprocessor variable:
[features]
qp.preprocessor = "WITH_QP"
When used as a dependency the feature could be toggled using
[dependencies]
test-drive = {git="https://github.com/fortran-lang/test-drive", features=["qp"]}
Prior Art
Cargo has features: https://doc.rust-lang.org/cargo/reference/features.html
Additional Information
A use case would be fortran-lang/test-drive#7
The mechanism required in fpm is similar to the one described in #577 (comment)