Skip to content

Commit

Permalink
Add cmake documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rbberger committed Feb 21, 2024
1 parent b764a44 commit 2f3e474
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/sphinx/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Documentation approved for unlimited release. LA-UR-21-31131.
src/getting-started
src/philosophy
src/building
src/integration
src/using-eos
src/models
src/modifiers
Expand Down
47 changes: 47 additions & 0 deletions doc/sphinx/src/integration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Integrating `singularity-eos` into a CMake project
==================================================

Installing singularity-eos into a prefix, either manually or via Spack gives
you an installation that can be used in other projects via CMake. Assuming
your installation is visible to CMake, either by installing in a known prefix
or setting ``CMAKE_PREFIX_PATH`` manually, a CMake project can integrate
Singularity-EOS via ``find_package(singularity-eos)`` and using the provided
targets to link to it.

.. code:: cmake
find_package(singularity-eos)
...
target_link_libraries(yourTarget PRIVATE singularity-eos::singularity-eos)
The ``singularity-eos`` config module provides the following targets:

``singularity-eos::singularity-eos_Interface``:
The C++ header-only library, adding the necessary include directories and
other dependencies such as mpark-variant and ports-of-call.

``singularity-eos::singularity-eos_Library``:
The static or shared library installed when building with
``SINGULARITY_BUILD_CLOSURE=on``. If ``SINGULARITY_USE_FORTRAN=on``, this also includes the
Fortran bindings and adds include path for its Fortran module.

``singularity-eos::singularity-eos``
Convenience target that contains either
``singularity-eos::singularity-eos_Interface``,
``singularity-eos::singularity-eos_Library``, or both, depending on the
COMPONENTS selection during ``find_package``. By default, if no COMPONENTS
are specified both are included.

Example: Integrating singularity-eos into a Fortran code
--------------------------------------------------------

Fortran projects do not require the C++ header-only library and its
dependencies, but only the compiled Fortran bindings provided by
Singularity-EOS. To avoid unnecessary dependency checks by CMake, a Fortran
project would integrate Singularity-EOS as follows:

.. code:: cmake
find_package(singularity-eos COMPONENTS Library)
...
target_link_libraries(yourTarget PRIVATE singularity-eos::singularity-eos)

0 comments on commit 2f3e474

Please sign in to comment.