cmaize.package_managers/cmake/cmake_package_manager

class cmaize.package_managers/cmake/cmake_package_manager.CMakePackageManager

Bases: PackageManager

CMake package manager going through find_package and FetchContent.

Additional Constructors

CTOR()

Default constructor of CMakePackageManager.

Parameters:

self (CMakePackageManager) – The constructed object.

Methods

add_paths([...])

Adds new search paths for the package manager.

These paths are stored in the search_paths attribute. Duplicate paths will be ignored.

Parameters:

*args

Path or paths to add to the search path.

register_dependency(_rd_result, _rd_proj_specs[, ...])

Register the dependency with the package manager. This does not search for or build the dependency, but makes it known to the package manager for future searching and building.

Parameters:
  • _rd_result (Dependency*) – Returned dependency.

  • _rd_name (desc) – Name of the dependency.

  • **kwargs

    Additional keyword arguments may be necessary.

  • _rd_proj_specs (PackageSpecification)

Returns:

Dependency object created and initialized.

Return type:

Dependency

find_installed(_fi_result, _fi_package_specs[, ...])

Finds an installed package.

This function uses CMake’s find_package in config mode to search for the packages on your system.

Parameters:
  • _fi_result (InstalledTarget*) – Return value for the installed target.

  • _fi_package_specs (PackageSpecification) – Specifications for the package to build.

  • **kwargs

    Additional keyword arguments may be necessary.

Keyword Arguments:
  • BUILD_TARGET (desc) – Name of the target when it is being built.

  • FIND_TARGET (desc) – Name of the target when it is found with find_package.

Returns:

CMaizeTarget object representing the found dependency, or a blank string (“”) if it was not found.

Return type:

InstalledTarget

get_package(_gp_result, _gp_proj_specs[, ...])

Get the requested package if it is installed. This is currently mostly unimplemented and should not yet be used.

Parameters:
  • self (CMakePackageManager) – CMakePackageManager object

  • _gp_result (InstalledTarget*) – Resulting target object return variable

  • _gp_proj_specs (PackageSpecification) – Specifications for the package to build.

Returns:

Resulting target from the package manager

Return type:

InstalledTarget

install_package(_ip_pkg_name[, ...])

Install a given target in the project.

Parameters:
  • self (CMakePackageManager) – CMakePackageManager object

  • _ip_target (BuildTarget*) – CMaizeTarget to install

  • **kwargs

    Additional keyword arguments may be necessary.

  • _ip_pkg_name (str)

Keyword Arguments:
  • NAMESPACE (desc) – Namespace to prepend to the target name. Include the delimiter when providing a namespace (for example, give “MyNamespace::”, not just “MyNamespace”). If no namespace is given, “${PROJECT_NAME}::” is used.

  • VERSION (desc) – Version of the package. This sets the VERSION and SOVERSION properties of the target to the full version and major version, respectively. Currently, only semantic versioning (https://semver.org) is supported. Defaults to the value of ${PROJECT_VERSION} or “0.1.0” if PROJECT_VERSION is also emtpy.

_generate_package_config(__gpc_output_file, __gpc_pkg_name[, ...])

Generates a package config file for the provided package. This file will also attempt to find dependencies for the package.

Parameters:
  • self (CMakePackageManager) – CMakePackageManager object

  • __gpc_output_file (str) – Identifying name of target to install.

  • __gpc_pkg_name (str) – Name of the package this Config file is for.

  • *args

    List of targets to include in this package. Only provide targets that are created by this project.

_generate_target_config(__gtc_tgt_obj, __gtc_target_name, __gtc_namespace, __gtc_config_file, __gtc_install_dest)

Generate a target config file for the given target at the provided location.

Parameters:
  • self (CMakePackageManager) – CMakePackageManager object

  • __gtc_target_name (str) – Identifying name of target to install.

  • __gtc_namespace (str) – Namespace for the target.

  • __gtc_config_file (path) – Path to the config file.

  • __gtc_install_dest (path) – Path to the installation destination.

  • __gtc_tgt_obj (BuildTarget)

Attributes

dependencies
Type:

cpp_map[desc, Dependency]

Search paths for find_package. Default paths are used if this is empty.

search_paths
Type:

List[path]

Search paths for find_package. Default paths are used if this is empty.

library_prefix
Type:

path

Prefix for libraries. Will default to lib if no language is specified otherwise the value will be obtained from GNUInstallDirs.

binary_prefix
Type:

path

Prefix for executables. Will default to bin if no language is specified otherwise the value will be otbtained from GNUInstallDirs.

cmaize.package_managers/cmake/cmake_package_manager._register_package_manager_cmake()

Registers a CMakePackageManager instance. This should only be called at the end of the file defining the PackageManager class.