KasperskyOS Community Edition 1.2
CMakeLists.txt root file
CMakeLists.txt root file
The CMakeLists.txt
boot file contains general build instructions for the entire solution.
The CMakeLists.txt
boot file must contain the following commands:
cmake_minimum_required (VERSION 3.25)
indicates the minimum supported version ofCMake
.For a KasperskyOS-based solution build,
CMake
version 3.25 or later is required.The required version of
CMake
is provided in KasperskyOS Community Edition and is used by default.include (platform)
connects theplatform
library ofCMake
.initialize_platform()
initializes theplatform
library.project_header_default("STANDARD_GNU_11:YES" "STRICT_WARNINGS:NO")
sets the flags of the compiler and linker.- [Optional] Connect and configure packages for the provided system programs and drivers that need to be included in the solution:
- A package is connected by using the
find_package()
command. - After connecting a package, you must add the package-related directories to the list of search directories by using the
include_directories()
command. - For some packages, you must also set the values of properties by using the
set_target_properties()
command.
CMake
descriptions of system programs and drivers provided in KasperskyOS Community Edition, and descriptions of their exported variables and properties are located in the corresponding files at/opt/KasperskyOS-Community-Edition-<version>/sysroot-aarch64-kos/lib/cmake/<program name>/<program name>-config.cmake
- A package is connected by using the
- The
Einit
initializing program must be built using theadd_subdirectory(einit)
command. - All applications to be built must be added by using the
add_subdirectory(<program directory name>)
command.
Example CMakeLists.txt boot file
CMakeLists.txt
cmake_minimum_required(VERSION 3.12)
project (example)
# Initializes the CMake library for the KasperskyOS SDK.
include (platform)
initialize_platform ()
project_header_default ("STANDARD_GNU_11:YES" "STRICT_WARNINGS:NO")
# Add package importing components for working with Virtual File System.
# Components are imported from the following directory: /opt/KasperskyOS-Community-Edition-<version>/sysroot-aarch64-kos/lib/cmake/vfs/vfs-config.cmake
find_package (vfs REQUIRED COMPONENTS ENTITY CLIENT_LIB)
include_directories (${vfs_INCLUDE})
# Add a package importing components for building an audit program and
# connecting to it.
find_package (klog REQUIRED)
include_directories (${klog_INCLUDE})
# Build the Einit initializing program
add_subdirectory (einit)
# Build the hello application
add_subdirectory (hello)
Article ID: cmake_lists_root, Last review: May 21, 2024