platform library
The platform library contains the following commands:
initialize_platform()is the command for initializing theplatformlibrary.The
initialize_platform()command can be called with theFORCE_STATICparameter, which enables forced static linking of executable files:- By default, if the toolchain in the KasperskyOS SDK supports dynamic linking, the
initialize_platform()command causes the-rdynamicflag to be used automatically for building all executable files defined viaCMakeadd_executable()commands. - When calling
initialize_platform (FORCE_STATIC)in theCMakeLists.txtroot file, the toolchain supporting dynamic linking performs static linking of executable files.
The
initialize_platform()command can be called with theNO_NEW_VERSION_CHECKparameter, which disables the check for SDK updates and transmission of the SDK version to the Kaspersky server.To disable the check for SDK updates and transmission of SDK version data to the Kaspersky server, use the following call during the solution build:
initialize_platform(NO_NEW_VERSION_CHECK). For more details about the data provision policy, see Data provision.- By default, if the toolchain in the KasperskyOS SDK supports dynamic linking, the
project_static_executable_header_default()is the command for enabling forced static linking of executable files defined via subsequentCMakeadd_executable()commands in oneCMakeLists.txtfile. The toolchain that supports dynamic linking performs static linking of these executable files.platform_target_force_static()is the command for enabling forced static linking of an executable file defined via theCMakeadd_executable()command. The toolchain that supports dynamic linking performs static linking of this executable file. For example, if theCMakecommandsadd_executable(client "src/client.c")andplatform_target_force_static(client)are called, static linking is performed for theclientprogram.project_header_default()is the command for setting compile flags.Command parameters are defined in pairs consisting of a compile flag and its value:
"FLAG_1:VALUE_1""FLAG_2:VALUE_2"..."FLAG_N:VALUE_N". TheCMakeplatformlibrary converts these pairs into compiler parameters. Frequently used compile flags for C and C++ compilers from the GCC set and the values of these flags are presented in the table below.Compile flags
YESvalueNOvalueDefault value
STANDARD_ANSI
The ISO C90 and 1998 ISO C++ standards are used.
For C and C++ compilers, the value is converted into the parameter
-ansi.The ISO C90 and 1998 ISO C++ standards are not used.
STANDARD_ANSI:NOSTANDARD_C99
The ISO C99 standard is used.
For a C compiler, the value is converted into the parameter
-std=c99.The ISO C99 standard is not used.
STANDARD_C99:NOSTANDARD_GNU_C99
The ISO C99 standard with GNU extensions is used.
For a C compiler, the value is converted into the parameter
-std=gnu99.The ISO C99 standard with GNU extensions is not used.
STANDARD_GNU_C99:NOSTANDARD_11
The ISO C11 and 2011 ISO C++ standards are used.
For a C compiler, the value is converted into the parameter
-std=c11or-std=c1xdepending on the compiler version.For a C++ compiler, the value is converted into the parameter
-std=c++11or-std=c++0xdepending on the compiler version.The ISO C11 and 2011 ISO C++ standards are not used.
STANDARD_11:NOSTANDARD_GNU_11
The ISO C11 and 2011 ISO C++ standards with GNU extensions are used.
For a C compiler, the value is converted into the parameter
-std=gnu1xor-std=gnu11depending on the compiler version.For a C++ compiler, the value is converted into the parameter
-std=gnu++0xor-std=gnu++11depending on the compiler version.The ISO C11 and 2011 ISO C++ standards with GNU extensions are not used.
STANDARD_GNU_11:NOSTANDARD_14
The 2014 ISO C++ standard is used.
For a C++ compiler, the value is converted into the parameter
-std=c++14.The 2014 ISO C++ standard is not used.
STANDARD_14:NOSTANDARD_GNU_14
The 2014 ISO C++ standard with GNU extensions is used.
For a C++ compiler, the value is converted into the parameter
-std=gnu++14.The 2014 ISO C++ standard with GNU extensions is not used.
STANDARD_GNU_14:NOSTANDARD_17
The ISO C17 and 2017 ISO C++ standards are used.
For a C compiler, the value is converted into the parameter
-std=c17.For a C++ compiler, the value is converted into the parameter
-std=c++17.The ISO C17 and 2017 ISO C++ standards are not used.
STANDARD_17:NOSTANDARD_GNU_17
The ISO C17 and 2017 ISO C++ standards with GNU extensions are used.
For a C compiler, the value is converted into the parameter
-std=gnu17.For a C++ compiler, the value is converted into the parameter
-std=gnu++17.The ISO C17 and 2017 ISO C++ standards with GNU extensions are not used.
STANDARD_GNU_17:NOSTRICT_WARNINGS
Warnings are enabled for the detection of potential issues and errors in code written in C and C++.
For C and C++ compilers, the value is converted into the following parameters:
-Wcast-qual,-Wcast-align,-Wundef.For a C compiler, the parameter
-Wmissing-prototypesis additionally used.Warnings are disabled.
STRICT_WARNINGS:YESIf compiler flags in the format
STANDART_*are not defined through command parameters, the parameterSTANDARD_GNU_17:YESis used by default.
When using the initialize_platform(FORCE_STATIC), project_static_executable_header_default() and platform_target_force_static() commands, you may encounter linking errors if the static variants of the required libraries are missing (for example, if they were not built or are not included in the KasperskyOS SDK). Even if the static variants of the required libraries are available, these errors may still occur because the build system searches for the dynamic variants of required libraries by default instead of the expected static variants when using the initialize_platform(FORCE_STATIC), project_static_executable_header_default() and platform_target_force_static() commands. To avoid errors, first make sure that the static variants are available. Then configure the build system to search for static libraries (although this capability may not be available for some libraries), or explicitly define linking with static libraries.
Examples of configuring the build system to search for static libraries:
set (fmt_USE_STATIC ON)
find_package (fmt REQUIRED)
set (fdn_USE_STATIC ON)
find_package (fdn REQUIRED)
set (sqlite_wrapper_USE_STATIC ON)
find_package (sqlite_wrapper REQUIRED)
Example that explicitly defines linking with a static library:
target_link_libraries(${PROJECT_NAME} PUBLIC logger::logger-static)
For more details about using dynamic libraries, see "Using dynamic libraries".
These commands are used in CMakeLists.txt files for the Einit program and application software.