mltk.utils.cmake

Utilities for invoking CMake

See the source code on Github: mltk/utils/cmake.py

Functions

build_mltk_target([target, mltk_target, ...])

Build an MLTK CMake target

get_build_directory([platform, target, ...])

invoke_mltk_target(target[, build_target, ...])

Invoke an MLTK CMake target

parse_variables(cmake_variables)

Convert a list or dictionary of CMake variables into a dictionary

build_mltk_target(target=None, mltk_target=None, additional_variables=None, debug=False, clean=False, source_dir=None, build_dir=None, build_subdir=None, platform=None, logger=None, verbose=False, jobs=None, accelerator=None, use_user_options=False, config_only=False, build_only=False)[source]

Build an MLTK CMake target

Parameters:
  • target (Optional[str]) – Name of CMake target to build

  • mltk_target (Optional[str]) – Name of MLTK_TARGET, if omitted use target

  • additional_variables (Union[List[str], Dict[str, str], None]) – List or dictionary of additional CMake variables to add to the build command

  • debug (bool) – If true then build with debugging (i.e. full symbols and no optimization)

  • clean (bool) – Clean the build directory before building

  • source_dir (Optional[str]) – Path to source directory, if omitted use mltk root directory

  • build_dir (Optional[str]) – Path to build directory, if omitted use <temp dir>/mltk/build

  • build_subdir (Optional[str]) – Name of sub build directory, if omitted use target name

  • platform (Optional[str]) – Build platform, if omitted use current OS

  • logger (Optional[Logger]) – Optional python logger

  • verbose (bool) – Enable verbose logging while building

  • accelerator (Optional[str]) – Name of accelerator to use for TFLITE_MICRO_ACCELERATOR CMake variable

  • jobs (Optional[int]) – Number of parallel build jobs

  • use_user_options (bool) – Use the user_options.cmake in the source directory. Default is to IGNORE user_options.cmake

  • config_only (bool) – Only configure the CMake project, do not build it

  • build_only (bool) – Only build the target, do not configure it first. In this case, the project must have been previosly configured

Return type:

str

Returns:

The path to the build directory

invoke_mltk_target(target, build_target=None, debug=False, build_dir=None, build_subdir=None, platform=None, logger=None, verbose=False)[source]

Invoke an MLTK CMake target

Return type:

str

Parameters:
  • target (str) –

  • build_target (Optional[str]) –

  • debug (bool) –

  • build_dir (Optional[str]) –

  • build_subdir (Optional[str]) –

  • platform (Optional[str]) –

  • logger (Optional[Logger]) –

  • verbose (bool) –

get_build_directory(platform=None, target=None, debug=False, build_dir=None, build_subdir=None)[source]
Return type:

str

Parameters:
  • platform (Optional[str]) –

  • target (Optional[str]) –

  • debug (bool) –

  • build_dir (Optional[str]) –

  • build_subdir (Optional[str]) –

parse_variables(cmake_variables)[source]

Convert a list or dictionary of CMake variables into a dictionary

Return type:

Dict[str, str]

Parameters:

cmake_variables (Union[List[str], Dict[str, str]]) –