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 (str) – Name of CMake target to build

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

  • additional_variables (Union[List[str], Dict[str, str]]) – 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 (str) – Path to source directory, if omitted use mltk root directory

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

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

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

  • logger (Logger) – Optional python logger

  • verbose (bool) – Enable verbose logging while building

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

  • jobs (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 (str) –

  • debug (bool) –

  • build_dir (str) –

  • build_subdir (str) –

  • platform (str) –

  • logger (Logger) –

  • verbose (bool) –

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

str

Parameters:
  • platform (str) –

  • target (str) –

  • debug (bool) –

  • build_dir (str) –

  • build_subdir (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]]) –