A TOML parser implementation for data serialization and deserialization in Fortran.

Find us on…

GitHub Download the Source

TOML-Fortran

License Release Build Build docs codecov

A TOML parser implementation for data serialization and deserialization in Fortran.

Getting Started

template template

Meson

Create a new meson project and include toml-f either as git-submodule in your subprojects directory or create a wrap file to fetch it from upstream:

[wrap-git]
directory = toml-f
url = https://github.com/toml-f/toml-f
revision = head

To load the project the necessary boilerplate code for subprojects is just

tomlf_prj = subproject(
  'toml-f',
  version: '>=0.2',
  default_options: [
    'default_library=static',
  ],
)
tomlf_dep = tomlf_prj.get_variable('tomlf_dep')

Now you can add tomlf_dep to your dependencies and access the public API by the tomlf module.

We recommend to set the default library type of toml-f to static when linking your applications or library against it. Note for library type both and shared toml-f will install itself along with your project.

For more fine-tuned control you can access:

  • the library target with tomlf_lib
  • the private include dir of this target, containing the Fortran module files, with tomlf_inc
  • the license files of toml-f with tomlf_lic

If you are linking your application statically against toml-f and still want to distribute the license files of toml-f (thank you), just use

install_data(
  tomlf_prj.get_variable('tomlf_lic'),
  install_dir: get_option('datadir')/'licenses'/meson.project_name()/'toml-f',
)

CMake

Create a new CMake project and include toml-f as git-submodule in your subprojects directory with

git submodule add https://github.com/toml-f/toml-f subprojects/toml-f

To include the project the necessary boilerplate code for subprojects is just

# subprojects/CMakeLists.txt
set(BUILD_SHARED_LIBS OFF)
add_subdirectory("toml-f")
list(
  APPEND lib-deps
  "toml-f-lib"
)
set(lib-deps "${lib-deps}" PARENT_SCOPE)

Now you can add toml-f-lib to your dependencies and access the public API by the tomlf module.

We recommend to disable building toml-f as shared library and just link your applications or library statically against it. The toml-f subproject will decide based on the library type if it should install itself along with your project.

Fortran Package Manager (fpm)

TOML-Fortran supports fpm as build system as well. Just add toml-f to the dependencies in your fpm.toml file:

[dependencies]
[dependencies.toml-f]
git = "https://github.com/toml-f/toml-f"

For a usage example of toml-f you can look-up the example in the TOML-Fortran repository (example-1) or just checkout fpm itself, which is using toml-f.

Developer Info

Sebastian Ehlert