Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if(NOT TARGET "MPI::MPI_Fortran" AND SDFTD3_WITH_MPI)
endif()

# Collect subprojects
if(NOT TARGET "toml-f::toml-f")
if(NOT TARGET "toml-f::toml-f" AND SDFTD3_WITH_APP)
find_package("toml-f" REQUIRED)
endif()
if(NOT TARGET "mctc-lib::mctc-lib")
Expand All @@ -50,10 +50,10 @@ set(
lib-deps
"mctc-lib::mctc-lib"
)
set(
exe-deps
"toml-f::toml-f"
)
set(exe-deps)
if(SDFTD3_WITH_APP)
list(APPEND exe-deps "toml-f::toml-f")
endif()

# Collect source of the project
set(srcs)
Expand Down Expand Up @@ -112,7 +112,9 @@ target_include_directories(
)

# Add example application
add_subdirectory("app")
if(SDFTD3_WITH_APP)
add_subdirectory("app")
endif()

# Export targets for other projects
add_library("${PROJECT_NAME}" INTERFACE)
Expand Down
1 change: 1 addition & 0 deletions config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if(NOT DEFINED WITH_TESTS)
set(WITH_TESTS TRUE)
endif()
option(SDFTD3_WITH_API "Enable support for C API via iso_c_binding module" ${WITH_API})
option(SDFTD3_WITH_APP "Build the standalone application" TRUE)
option(SDFTD3_WITH_OpenMP "Enable support for shared memory parallelisation with OpenMP" ${WITH_OpenMP})
option(SDFTD3_WITH_MPI "Enable support for distributed memory parallelisation with MPI" ${WITH_MPI})
option(SDFTD3_WITH_TESTS "Enable compilation of unit tests" ${WITH_TESTS})
Expand Down
16 changes: 9 additions & 7 deletions config/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ mctc_dep = dependency(
)
lib_deps += mctc_dep

# Create the TOML Fortran library as subproject
tomlf_dep = dependency(
'toml-f',
fallback: ['toml-f', 'tomlf_dep'],
default_options: ['default_library=static'],
)
exe_deps += tomlf_dep
if get_option('app')
# Create the TOML Fortran library as subproject
tomlf_dep = dependency(
'toml-f',
fallback: ['toml-f', 'tomlf_dep'],
default_options: ['default_library=static'],
)
exe_deps += tomlf_dep
endif
10 changes: 9 additions & 1 deletion doc/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This library depends on few Fortran modules to provide the desired functionality

- `mctc-lib`_: Modular computation tool chain library
- `mstore`_: Molecular structure store (testing only)
- `toml-f`_: TOML parser for Fortran
- `toml-f`_: TOML parser for Fortran (command line application only)

When building from source the dependencies will be downloaded automatically if not available on the system.
To build offline install the dependencies before building the library or provide the source of the dependencies in the *subprojects* directory.
Expand Down Expand Up @@ -95,6 +95,10 @@ To setup a new build run

meson setup _build --prefix=$HOME/.local

The command line application is built by default and requires ``toml-f``.
To build only the library, configure with ``-Dapp=false``.
Note that `mctc-lib`_ can also depend on ``toml-f`` through its JSON support, please see the `mctc-lib`_ documentation for more details.

The Fortran and C compiler can be selected with the ``FC`` and ``CC`` environment variable, respectively.
The installation location is selected using the ``--prefix`` option.
The required Fortran modules will be fetched automatically from the upstream repositories and checked out in the *subprojects* directory.
Expand Down Expand Up @@ -149,6 +153,10 @@ Configure a new build with

cmake -B _build -G Ninja -DCMAKE_INSTALL_PREFIX=$HOME/.local

The command line application is built by default and requires ``toml-f``.
To build only the library and omit this dependency, configure with
``-DSDFTD3_WITH_APP=OFF``.

The Python extension can be enabled with CMake 3.18 or newer by adding
``-DSDFTD3_WITH_PYTHON=ON`` and selecting the interpreter with
``-DPython3_EXECUTABLE=/path/to/python3``.
Expand Down
6 changes: 4 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ sdftd3_parameters = files(
)

# Add applications
subdir('app')
if get_option('app')
subdir('app')
endif

# Package the license files
sdftd3_lic = files(
Expand Down Expand Up @@ -103,7 +105,7 @@ if install
)

asciidoc = find_program('asciidoctor', required: false)
if asciidoc.found()
if asciidoc.found() and get_option('app')
install_man(
configure_file(
command: [asciidoc, '-b', 'manpage', '@INPUT@', '-o', '@OUTPUT@'],
Expand Down
6 changes: 6 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ option(
value: true,
description: 'Build C API using iso_c_binding module',
)
option(
'app',
type: 'boolean',
value: true,
description: 'Build the command line application',
)
option(
'python',
type: 'boolean',
Expand Down
4 changes: 3 additions & 1 deletion test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ subdir('unit')
if get_option('mpi')
subdir('mpi')
endif
subdir('validation')
if get_option('app')
subdir('validation')
endif
Loading