CMake API Reference#
To include alpaqa in your CMake project, use the find_package
command:
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 |
---|---|---|
|
The main alpaqa solvers and other core functionality. If no components are specified, this is the default. |
|
|
The dynamic loading C API headers for creating problems that can be loaded by the alpaqa solvers. |
|
|
Classes for loading and building problem definitions using CasADi. |
|
|
Additional solvers and problem loaders that fall outside of the core library. |
|
|
Command-line tools for invoking the solvers. |
|
Targets are prefixed with alpaqa::
. For example, to link with the main alpaqa library,
use:
target_link_libraries(<target> PUBLIC alpaqa::alpaqa)
To check whether a certain target is available, you can use:
if (TARGET alpaqa::qpalm-adapter)
# ...
endif()
Commands#
- alpaqa_add_dl_problem_module#
Create a target for a problem that can be dymanically loaded by the alpaqa solvers.
alpaqa_add_dl_problem_module(<target> [LINK_ALPAQA] [VISIBILITY_DEFAULT] [NO_CXX_20] [FUNCTION_NAME <name>] [FILES [<file> ...]])
This function creates a CMake module library target with the given name
<target>
, configures the correct visibility settings, generates an export header, and links to the correct alpaqa targets.If the
FILES
option is given, the provided files are added to the target. Otherwise, the source file${target}.cpp
in the current folder is used.In addition to linking to the
alpaqa::dl-api
headers, the mainalpaqa::alpaqa
library is linked as well if theLINK_ALPAQA
option is provided. This is useful if you need any of the utility functions provided by alpaqa.If the
VISIBILITY_DEFAULT
option is given the visibility settings are not altered.By default, C++20 support is enabled, unless the
NO_CXX_20
is given.FUNCTION_NAME
can be used to set the name of the registration function to expose. It should match the function defined in the module (which should have C linkage, usingextern "C"
).Note
This function requires the alpaqa
Dl
component to be loaded:find_package(alpaqa 1.0.0 REQUIRED COMPONENTS Dl)
If
LINK_ALPAQA
is specified, both theCore
andDl
components are required.