NAI SSK CMake Build Guide for Linux

Overview

This document describes how to use CMake to install, configure, and build the software libraries and sample applications of NAI’s Software Support Kit (SSK) 2.x.

Environment Setup

CMake

CMake 3.22.1 or later must be installed to build the Linux SSK. Using any web browser, navigate to https://cmake.org/files/v3.22 and download the “cmake-3.22.1-linux-x86_64.tar.gz” package.

Building and Running a Project

PACKAGE LAYOUT

The NAI SSK contains NAI libraries and code to access all onboard and offboard modules. Inside, you’ll find a “base” folder, a “docs” folder, and the root CMakeLists.txt file that’s used as the entry point for CMake to configure a build folder.

“base” Folder

The base folder contains the all the “C” source code for the SSK.

Project NameDescription (Listed in order of recommended build order)
nai_bspHandles OS and processor specific routines, implements interface driver code.
nai_libsLibrary routines used by user applications.
nai_sample_appsSample applications to demonstrate module functionality.
naistdlibAdditional C libraries.

“docs” Folder

The “docs” folder contains local copies of the SSK’s API documentation and quick-start guides that are available on the Docs website.

“cmake/configs” Folder

The “cmake/configs” folder exists in the “nai_libs” directory and contains the toolchain files for all supported configurations to be chosen from when generating the build folder with CMake. A generic native Linux host will use the linux_x86-64.cmake toolchain.

CONFIGURING AND BUILDING THE SSK

Instructions

  1. Open the root folder of the SSK in the terminal.
  2. Run the following command with the necessary flags to generate the build folder in the specified location:
    cmake [flags] -B [build_folder] —toolchain ./cmake/configs/linux_x86-64.cmake
    a. To generate a Release or Debug build, add the flag:
    ** -DCMAKE_BUILD_TYPE=[Release|Debug]**
    b. To generate shared object (.so) or archive (.a) libraries, add the flag:
    ** -DBUILD_SHARED_LIBS=[ON|OFF]**

Note

To build for an NAI SBC, replace linux-x86_64.cmake with the toolchain for your board (e.g. 68int6.cmake).

  1. Run the following command to compile the build:
    cmake —build [build_folder] -j
  2. All compiled binaries and libraries will be found in [build_folder]/bin and [build_folder]/lib, respectively.

Note

In order to change any of the configured flags (switching between .so and .a or Release and Debug), you cannot reuse the same build folder. You must either delete the previously generated build folder or direct CMake to generate a new build folder in a different location. Only then should you rerun the CMake commands with the updated flags.

Example

In this example, the SSK is extracted to “~/nai/ssk/” and the goal is to generate a static, debug build in the folder “build_debug_a”.

  1. Run cd ~/nai/ssk/ to navigate to the root folder of the SSK.
  2. To generate the build folder “build_debug_a” for a static, debug build, use the command:
    cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug -B build_debug_a —toolchain ./cmake/configs/linux-x86-64.cmake
  3. To compile this configuration, run the command:
    cmake —build build_debug_a -j
  4. All compiled binaries and libraries will be found in build_debug_a/bin and build_debug_a/lib, respectively.
    a. Truncated outputs of ls -l build_debug_a/bin and ls -l build_debug_a/lib