Building LAPKT {#build}

March 25, 2025 ยท View on GitHub

We use cmake to manage the build process. The build handles the compilation of core LAPKT libraries which are written in C++. It also compiles python bindings that allow us to expose the core C++ classes and methods to the python frontend.

The cmake build also restructures the compiled binary the a package that can be shipped as a pip installable.

The cmake script has been tested on standard os images available on Github Actions. The build-test workflow configuration lists all the build and test commands.

(user) can also use the Apptainer configuration to build a self contained package

Build prerequisites

The build requires development tools specific to the operating system that you are using.

Operating SystemTested Versions
Ubuntu20.04/ 22.04/ 24.04
Windows2019

Build steps

  1. If you have a pre-existing build directory, then delete it if you are having compilation issues.

  2. To build LAPKT, run the following command from the root of the lapkt source directory

     cmake -Bbuilds/build -DCMAKE_INSTALL_PREFIX=Release -DCMAKE_BUILD_TYPE=Release -DUSE_SUPERBUILD=ON
    
     cmake --build builds/build -j4 [--target clean](optional)
    

    This would create a package, Release/lapkt_package, at the root of the source directory. Users can directly run/debug lapkt with the following command

     cd <source_dir>
    
     python3 Release/lapkt_package/lapkt.py -h
    
  3. Install the built source code if you want to have system wide access (optional)

     cmake  --install builds/build
    

    Same can be achieved with the pip install as well

     python3 -m pip install --user  Release/_package/
    

    In Ubuntu, this installs the python script lapkt_cmd.py in local binary directory, typically at $HOME/.local/bin/lapkt_cmd.py, and lapkt library files into the python shared module directory, $HOME/.local/lib/python<version>/site-packages/lapkt/.

  4. Test to check everything went correctly

     cd builds/build/ && ctest && cd ../.. \
     cd pytest && python3 -m pytest -W ignore::DeprecationWarning && cd ..
    

Custom build steps (advanced usage)

The build process involves three step, configure, build, and install. Each step can take additional parameter. We list some of the useful configuration parameters below.

Configuration step

    cmake -B<build_dir> -S<src_dir> -DCMAKE_INSTALL_PREFIX=<install_dir> -DCMAKE_BUILD_TYPE={Release|Debug}
ParameterUsage
build_dirbuild output path
src_dirsource directory
CMAKE_INSTALL_PREFIXinstallation path
CMAKE_CXX_COMPILERspecify a g++ version, tested with g++-8, g++-9, g++-10, g++-11 g++-12
CMAKE_C_COMPILERspecify a gcc version, tested with gcc-8, gcc-9, gcc-10, gcc-11 gcc-12
CMAKE_INSTALL_PREFIXinstallation path
CMAKE_BUILD_TYPERelease for production and Debug for debugging the source
USE_SUPERBUILDbuilds all dependencies from source (makes the build independent of any pre-existing installation of dependencies), it is set to ON by default
CMAKE_FDadd fast-downward parser and grounder to the package, default ON
CMAKE_TARSKIadd tarski parser and grounder to the package, default ON
GEN_DOXYGEN_DOCSautomatically generate doxygen html docs from source and md files, default OFF
CMAKE_STATIC_BOOSTStatic link boost, default ON
BUILD_CPP_TESTSbuild ctest executables, default OFF
CMAKE_FF, CMAKE_LEGACY_PLANNERbuild executables for planners that use the FF parser and grounder, only for testing, default OFF
CMAKE_FF, CMAKE_LEGACY_PLANNERbuild executables for planners that use the FF parser and grounder, only for testing, default OFF
BOOST_ROOTPath to Boost installtion (required if USE_SUPERBUILD=OFF is not used), default ""
CATCH2_ROOTPath to Catch2 installtion (required if USE_SUPERBUILD=OFF is not used), default ""

Build step

    cmake --build <build_dir> -j<cpu_count>
ParameterUsage
build_dirbuild path, same as configuration step
cpu_countmaximum CPUs used in parallel

Installation step

    cmake  --install <build_dir>
ParameterUsage
build_dirbuild path, same as configuration step