cmaize.project/package_specification
- class cmaize.project/package_specification.PackageSpecification
The
PackageSpecificationclass is envisioned as holding all of the details about how to build a package (“package” being a catchall for a dependency or the project that the CMaize build system is being written for). This includes things like where the source code lives, the version to build, and specific options for configuring and compiling.PackageSpecificationinstances will ultimately be used to request packages from thePackageManager.Additional Constructors
- CTOR()
Default constructor for PackageSpecification object with only autopopulated options available.
- Parameters:
self (PackageSpecification) – PackageSpecification object constructed.
- Returns:
selfwill be set to the newly constructedPackageSpecificationobject.- Return type:
Methods
- hash(return_hash, hash_type)
Hash the object using the provided hashing algorithm string.
Supported hashing algorithms are specified by the CMake
string(<HASH>function defined here.- Parameters:
self (PackageSpecification) –
PackageSpecificationobject to hash.return_hash (str) – Hashed
PackageSpecificationhash_type (str) – Hash algorithm to use
- Returns:
Hashed
PackageSpecificationobject- Return type:
str
- set_version()
Overload to
set_version()method to catch when the package version string is blank.Note
This override is required because of a bug in CMakePPLang. Currently, CMakePPLang cannot differentiate between
PackageSpecification(set_version "${ps_obj}")andPackageSpecification(set_version "${ps_obj}" ""). Sometimes thePROJECT_VERSIONvariable used in__initializeto determine a default package version is blank, so this ensures we do not get an error about not including the version argument forcpp_member(set_version PackageSpecification str)calls.- Parameters:
self (PackageSpecification) –
PackageSpecificationobject.
- set_config_option(_sco_name, _sco_value)
Registers a configuration option with self.
This method is a convenience function for getting the internal map of configuration options and updating it with the user supplied option and value.
- Parameters:
self (PackageSpecification) –
PackageSpecificationobject.name (desc) – The name of the configuration option
value (str) – The value for the option.
_sco_name (desc)
_sco_value (str)
- get_config_option(_gco_value, _gco_name)
Retrieves a configuration option from self.
This method is a convenience function for getting the value of a configuration option from the internal map of configuration options.
- Parameters:
self (PackageSpecification) –
PackageSpecificationobject.value (str) – The value of the requested option.
name (desc) – The name of the configuration option
_gco_value (str)
_gco_name (desc)
- Raises:
KeyError – If
nameis 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 map of configuration options and if the user set a specified key. If the user set
name,resultwill be set to true; otherwise,resultwill be false.- Parameters:
self (PackageSpecification) –
PackageSpecificationobject.result (bool*) – The identifier to assign the result to.
name (desc) – The name of the configuration option
_hco_result (bool*)
_hco_name (desc)
- set_version(package_version)
Set the package version variable and splits the version into major, minor, patch, and tweak components.
- Parameters:
self (PackageSpecification) –
PackageSpecificationobject.package_version (str) – Full package version string.
- __initialize()
Initialize package attributes with default values.
- Parameters:
self (PackageSpecification) –
PackageSpecificationobject to initialize.
Attributes
- name
- Type:
str
Name of package as a string.
- version
- Type:
str
Version of package as a string.
- major_version
- Type:
str
First version number component of the
versionattribute.
- minor_version
- Type:
str
Second version number component of the
versionattribute.
- patch_version
- Type:
str
Third version number component of the
versionattribute.
- tweak_version
- Type:
str
Fourth version number component of the
versionattribute.
- build_type
- Type:
str
Specifies the build type.
For the possible values provided by CMake and how to add custom build types, see CMAKE_BUILD_TYPE.
Note
Currently, only single-configuration generators are supported since the
build_typeis based onCMAKE_BUILD_TYPE. This could be expanded to multi-configuration generators later, although the build type will need to be determined at build time instead of configure time. See CMAKE_CONFIGURATION_TYPES and CMake Build Configurations for more information on the details of making this switch.
- configure_options
- Type:
cpp_map
The options in this map control which variant of a package is requested. They are package-specific options and are usually along the lines of “ENABLE_XXX” and the like. More traditional CMake options like “BUILD_SHARED_LIBS” should be part of the toolchain.
This is initialized to an empty map for users to fill.
- compile_options
- Type:
cpp_map
Package compile options.
This is initialized to an empty map for users to fill.