rsLQR
0.1
|
This page provides details about both building the rsLQR from source, as well as using it in other project.
The rsLQR library uses CMake as its build system, and follows standard CMake practices. To build the library, follow these steps, starting in the root directory of the repository:
The library provides several options for controlling the build, these are detailed below:
Variable Name | Options | Default | Description |
---|---|---|---|
RSLQR_BUILD_TESTS | ON/OFF | ON | Specifies whether or not the test suite should be built |
RSLQR_CODE_COVERAGE | ON/OFF | OFF | Build the library and build code coverage reports. Note this option turns off compiler optimizations so runtime performance will be slow. |
RSLQR_LINALG_LIBRARY | InternalRoutines, Eigen, BLAS | InternalRoutines | Select the linear algebra library to use. |
RSLQR_NTHREADS_TEST | Integer | 2 | Select default number of threads to use for tests. |
RSLQR_RUN_FULL_TEST | ON/OFF | ON | Disabling this option will run a less computationally intensive set of tests. |
If the RSLQR_LINALG_LIBRARY
option is set to BLAS
, it will download the open-source LAPACK distribution with includes the default NetLib BLAS routines. Note that this build wil take significantly longer since it builds LAPACK and BLAS from source as part of the build.
If the RSLQR_LINALG_LIBRARY
option is set to Eigen
, the Eigen C++ linear algebra library must be installed on the host computer.
From our benchmarks, the default internal routines provide the best performance when running the algorithm with many threads.
The CMAKE_BUILD_TYPE
defaults to Release
if non is specified.
These options can be specified during the configure step, e.g.:
or via any CMake cache editor, like the CMake GUI:
The current values of these variables can be queried via the command line:
The library can be installed locally onto your machine using the standard CMake installation steps. After building the library (see previous section), the library can be installed by building the install
target:
For a custom install location, you need to specify the CMAKE_INSTALL_PREFIX
This will generate the following output in the install directory for a Linux system:
If the library is installed locally using the previous section, then the library can be incorporated into another CMake project using standard the find_package
procedure. In the CMakeLists.txt
file of your project, include the following:
Which imports the following targets:
To use the library in your application, simply link against the rsLQR::rslqr
target, e.g.
See the "Install Example" in the examples/
directory for a working example.
It's often not convenient to require users to build another library in order to use your application. You can easily incorporate this library as part of your CMake project, importing all of its targets, via the FetchContent
CMake module. This downloads the GitHub repository locally into your build
folder, adds it's CMake build to your top-level CMake build, and builds the library as part of your build system. This project uses this approach to bundle the cJSON library.
To use this approach, copy these lines into your CMakeLists.txt
:
From here, it looks identical to the previous example, since our build system provides alias targets matching all of the installed targets. So to link against the rsLQR library, you simply link against the rsLQR::rslqr
target like we did before:
See the "Import Example" in the examples/
directory for a working example.