cmaize.project/cmaize_project
- class cmaize.project/cmaize_project.CMaizeProject
The
CMaizeProject
provides a workspace to collect information about a project, using that information to build and package the project.This object will not create a CMake project if one does not already exist.
Usage:
A
CMaizeProject
object will be automatically created for the current when CMaize is included in aCMakeLists.txt
file if aproject()
call has already been made. This project should not be created manually in most cases.To retrieve an existing project object, call:
cpp_get_global(result_object CMAIZE_PROJECT_<project_name>)
Additional Constructors
- CTOR(_ctor_name[, ...])
Creates a
CMaizeProject
object. A CMake project of the same name must already be created through aproject()
call and must be the active project.- Parameters:
self (CMaizeProject*) – The constructed object.
_ctor_name (desc) – Name of the project. Must match the active project named in
PROJECT_NAME
.
- Keyword Arguments:
LANGUAGES (list[desc]) – Languages supported by the project. These languages are passed to the LANGUAGES keyword of the CMake
project()
call if the project does not exist yet.
- Raises:
ProjectNotFound – The active CMake project does not match the given project name.
- Returns:
self
will be set to the newly constructedCMaizeProject
object.- Return type:
Methods
- add_language(_al_language)
Add a language to the project. Duplicate languages will be removed.
- Parameters:
self (CMaizeProject) – CMaizeProject object.
_al_language (desc) – Language to be added.
- set_config_option(_sco_name, _sco_value)
Sets the value of the specified configuration option
This method is a convience function for retrieving the PackageSpecification associated with self and then setting the value of the specified configuration option.
- Parameters:
self (CMaizeProject) – The current
CMaizeProject
object.name (desc) – The key for the configuration option.
value (str) – The value to set the configuration option to.
_sco_name (desc)
_sco_value (str)
- get_config_option(_gco_value, _gco_name)
Gets the value of a configuration option.
This method is a convenience function for retrieving the PackageSpecification associated with self and then getting the value of the specificed configuration option.
- Parameters:
self (CMaizeProject) – The current
CMaizeProject
object.value (str) – The variable which will hold the option’s value
name (desc) – The configuration option whose value has been requested.
_gco_value (str)
_gco_name (desc)
- Raises:
KeyError – If
name
is not a configuration option which has been added viaset_config_option
. Strong throw guarantee.
- has_config_option(_hco_result, _hco_name)
Determines if a configuration option was added to self.
This method is a convenience function for getting the internal PackageSpecification and seeinf if the user set a specified key. If the user set
name
,result
will be set to true; otherwise,result
will be false.- Parameters:
self (CMaizeProject) –
CMaizeProject
object.result (bool*) – The identifier to assign the result to.
name (desc) – The name of the configuration option
_hco_result (bool*)
_hco_name (desc)
- add_package_manager(_apm_pm)
Add a package manager to the project. Duplicate package manager types will not be added.
- Parameters:
self (CMaizeProject) – CMaizeProject object.
_apm_pm (Package manager) – Package manager object to be added.
- add_target(_at_target_name, _at_target[, ...])
Add a target to the project. Duplicate objects will be removed.
- Parameters:
_at_target_name (desc) – Identifying name for the target. This can match name of either the CMake target or CMaizeTarget object, but is required to do match them.
_at_target (CMaizeTarget) – CMaizeTarget object to be added.
**kwargs –
Additional keyword arguments may be necessary.
- Keyword Arguments:
INSTALLED (bool) – Flag to indicate that the target being added is already installed on the system.
NAME (desc or target) – Identifying name for the target. This can match name of either the CMake target or CMaizeTarget object, but is required to do match them. This keyword argument is required.
- check_package_manager(_cpm_found, _cpm_pm_type)
Checks if a package manager with the same type is already added to this project.
- Parameters:
self (CMaizeProject) – CMaizeProject object.
_cpm_found (bool*) – Return variable for if the package manager was found.
_cpm_tgt (Package manager) – Package manager to search for.
_cpm_pm_type (str)
- Returns:
Package manager found (TRUE) or not (FALSE).
- Return type:
bool
- check_target(_ct_found, _ct_target_name[, ...])
Checks if a target with the same name is already added to this project.
- Parameters:
_ct_found (bool*) – Return variable for if the target was found.
_ct_target_name (desc) – Identifying name for the target. This can match name of either the CMake target or CMaizeTarget object, but is required to do match them.
**kwargs –
Additional keyword arguments may be necessary.
- Keyword Arguments:
INSTALLED (bool) – Flag to indicate that the installed targets should be checked.
ALL (bool) – Flag to indicate that both the build and installed targets should be checked.
NAME (desc or target) – Identifying name for a target contained in the current Cmaize project. This keyword argument is required.
- Returns:
CMaizeTarget found (TRUE) or not (FALSE).
- Return type:
bool
- get_package_manager(_gpm_result, _gpm_pm_type)
Get a package manager of the requested type stored in the project.
- Parameters:
_gpm_result (PackageManager*) – Return variable for the package manager object.
_gpm_pm_type (desc) – Type of package manager to retrieve. See
CMAIZE_SUPPORTED_PACKAGE_MANAGERS
for the list of supported package manager types.
- Returns:
Requested package manager object, or an empty string (“”) if no package manager with the matching type was found.
- Return type:
- get_target(_gt_result, _gt_target_name[, ...])
Get a CMaizeTarget with the requested identifying name stored in the project.
- Parameters:
_gt_result (CMaizeTarget*) – Return variable for the CMaizeTarget object.
_gt_target_name (desc) – Identifying name of the target to retrieve. This should match the name provided during the
CMaizeProject(add_target
call.**kwargs –
Additional keyword arguments may be necessary.
- Keyword Arguments:
INSTALLED (bool) – Flag to indicate that the installed targets should be searched.
NAME (desc or target) – Identifying name for a target contained in the current Cmaize project. This keyword argument is required.
- Returns:
Requested target object, or an empty string (“”) if no target with the matching type was found.
- Return type:
- _get_target(__gt_result[, ...])
Get a CMaizeTarget with the requested identifying name stored in the project.
This internal implementation exists so a required keyword argument is not part of the public interface, as well as to handle both
desc
andtarget
types. Both types are effectively strings representing target names in this algorithm and can be treated equivalently, but cannot be typecast to each other by CMakePPLang. The CMakePPLang type checking is bypassed through the aforementioned required keyword argument for the target name, essentially combining the two types.- Parameters:
__gt_result (CMaizeTarget*) – Return variable for the resulting target.
NAME (desc or target) – Required keyword argument. See description below.
**kwargs –
Additional keyword arguments may be necessary.
- Keyword Arguments:
INSTALLED (bool) – Flag to indicate that the installed targets should be searched.
NAME (desc or target) – Identifying name for a target contained in the current Cmaize project. This keyword argument is required.
- Returns:
Requested target object, or an empty string (“”) if no target with the matching type was found.
- Return type:
Attributes
- name
- Type:
desc
Name of the project.
- specification
- Type:
Details about the project.
- languages
- Type:
list[desc]
Languages used in the project. Defaults to an empty list.
- package_managers
- Type:
list[PackageManager]
Package managers used by the project.
- build_targets
- Type:
list[BuildTarget]
Targets that will be built as part of the project.
- installed_targets
- Type:
list[InstalledTarget]
Targets the project uses that are already installed on the system.