Skip to content

Commit

Permalink
[Docs] add CMake API reference
Browse files Browse the repository at this point in the history
  • Loading branch information
tttapa committed Dec 17, 2023
1 parent 4c5cbad commit c3dbeb2
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 20 deletions.
1 change: 1 addition & 0 deletions doxygen/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ breathe @ git+https://github.com/tttapa/breathe@main
sphinx @ git+https://github.com/tttapa/sphinx@master
sphinx-tabs~=3.4.4
sphinxcontrib-matlabdomain~=0.20.2
sphinxcontrib-moderncmakedomain~=3.27.0
furo==2023.08.19
matplotlib
1 change: 1 addition & 0 deletions doxygen/sphinx/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
'matplotlib.sphinxext.plot_directive',
'sphinxcontrib.matlab',
'sphinx_tabs.tabs',
'sphinxcontrib.moderncmakedomain',
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
1 change: 1 addition & 0 deletions doxygen/sphinx/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ be found in the `Doxygen pages <../Doxygen/index.html>`_.
examples/index.rst
reference/python-api.rst
reference/cpp-api.rst
reference/cmake-api.rst
reference/matlab-api.rst
contribution/*
changelog
Expand Down
52 changes: 52 additions & 0 deletions doxygen/sphinx/source/reference/cmake-api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
CMake API Reference
===================

To include alpaqa in your CMake project, use the ``find_package`` command:

.. code-block:: cmake
find_package(alpaqa 1.0.0 [EXACT] [QUIET] [REQUIRED]
[COMPONENTS <components> ...]
[OPTIONAL_COMPONENTS <components> ...])
Components and targets
----------------------

alpaqa comes with multiple optional components, some of which can be packaged
and installed independently. The available components are:

+--------------+--------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------+
| Component | Description | Targets |
+==============+==============================================================================================================+=====================================================================================================+
| ``Core`` | The main alpaqa solvers and other core functionality. If no components are specified, this is the default. | ``alpaqa`` |
+--------------+--------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------+
| ``Dl`` | The dynamic loading C API headers for creating problems that can be loaded by the alpaqa solvers. | ``dl-api`` |
+--------------+--------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------+
| ``CasADi`` | Classes for loading and building problem definitions using CasADi. | ``casadi-loader``, ``casadi-ocp-loader`` |
+--------------+--------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------+
| ``Extra`` | Additional solvers and problem loaders that fall outside of the core library. | ``dl-loader``, ``cutest-interface``, ``ipopt-adapter``, ``lbfgsb-adapter``, ``qpalm-adapter`` ... |
+--------------+--------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------+
| ``Tools`` | Command-line tools for invoking the solvers. | ``driver``, ``gradient-checker`` |
+--------------+--------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------+

Targets are prefixed with ``alpaqa::``. For example, to link with the main alpaqa library,
use:

.. code-block:: cmake
target_link_libraries(<target> PUBLIC alpaqa::alpaqa)
To check whether a certain target is available, you can use:

.. code-block:: cmake
if (TARGET alpaqa::qpalm-adapter)
# ...
endif()
Commands
--------

.. cmake-module::
../../../../src/cmake/dl-problem.cmake
22 changes: 2 additions & 20 deletions examples/CMake/Solver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,26 +127,8 @@ cmake --preset conan-release # or conan-default on Windows
cmake --build --preset conan-release -j
```

The available components are:

| Component | Description | Targets |
|:----------|:------------|:--------|
| `Core` | The main alpaqa solvers and other core functionality. If no components are specified, this is the default. | `alpaqa` |
| `Dl` | The dynamic loading C API headers for creating problems that can be loaded by the alpaqa solvers. | `dl-api` |
| `CasADi` | Classes for loading and building problem definitions using CasADi. | `casadi-loader`, `casadi-ocp-loader` |
| `Extra` | Additional solvers and problem loaders that fall outside of the core library. | `dl-loader`, `cutest-interface`, `ipopt-adapter`, `lbfgsb-adapter`, `qpalm-adapter` ... |
| `Tools` | Command-line tools for invoking the solvers. | `driver`, `gradient-checker` |

Some interfaces require third-party packages to be installed, and need to be
enabled when building the Conan package (using the `-o` option).

To check whether a certain target is available, you can use:

```cmake
if (TARGET alpaqa::qpalm-adapter)
# ...
endif()
```
A complete list of the available components and targets can be found on the
[CMake API Reference](https://kul-optec.github.io/alpaqa/1.0.0a16/Sphinx/reference/cmake-api.html) page.

### Disabling tests

Expand Down

0 comments on commit c3dbeb2

Please sign in to comment.