Using CMake from the contents of KasperskyOS Community Edition

To automate the process of preparing the solution image, you need to configure the CMake build system. You can base this system on the build system parameters used in the examples from KasperskyOS Community Edition.

CMakeLists.txt files use the standard CMake syntax, and commands and macros from libraries provided in KasperskyOS Community Edition.

Recommended structure of project directories

When creating a KasperskyOS-based solution, it is recommended to use the following directory structure in a project:

Example structure of project directories

example$ tree

.

├── CMakeLists.txt

├── hello

│ ├── CMakeLists.txt

│ ├── src

│ │ ├── hello.c

├── einit

│ ├── CMakeLists.txt

│ ├── src

│ │ ├── init.yaml.in

│ │ ├── security.psl.in

├── resources

│ ├── Hello.idl

│ ├── Hello.cdl

│ ├── Hello.edl

Building a solution image

To build a solution image, you must use the cmake tool (the toolchain/bin/cmake executable file from KasperskyOS Community Edition).

Build script example:

build.sh

#!/bin/bash

# Script to be run in the project root.

# You can get information about the cmake tool run parameters

# via the shell command cmake --help, and from

# the official CMake documentation.

TARGET="aarch64-kos"

SDK_PREFIX="/opt/KasperskyOS-SDK"

# Initialize the build system

cmake \

-G "Unix Makefiles" \

-D CMAKE_BUILD_TYPE:STRING=Release \

-D CMAKE_TOOLCHAIN_FILE=$SDK_PREFIX/toolchain/share/toolchain-$TARGET.cmake \

-S . \

-B build

# Build

# To build a solution image for QEMU, you must specify the target defined in the

# NAME parameter of the CMake command build_kos_qemu_image() in the CMakeLists.txt file

# for building the Einit program.

# To build a solution image for the hardware platform, you must specify the target

# defined in the NAME parameter of the CMake command build_kos_hw_image() in the

# CMakeLists.txt file for building the Einit program.

# To build a solution image for QEMU and start QEMU with this image, you must

# specify the sim target.

cmake --build build --target sim

In this section

CMakeLists.txt boot file

CMakeLists.txt files for building applications

CMakeLists.txt file for building the Einit program

init.yaml.in template

security.psl.in template

Page top