Skip to content

Allow optional features in projects #609

Open
@awvwgk

Description

@awvwgk

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    specificationIssue regarding fpm manifest and model

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions