cmake: configure_package_config_file can now take a dict
This commit is contained in:
parent
c42a3fd2fb
commit
fcca265035
|
@ -262,6 +262,7 @@ the `configuration` parameter.
|
|||
* `input`: the template file where that will be treated for variable substitutions contained in `configuration`.
|
||||
* `install_dir`: optional installation directory, it defaults to `$(libdir)/cmake/$(name)`.
|
||||
* `configuration`: a `configuration_data` object that will be used for variable substitution in the template file.
|
||||
*Since 0.62.0* it can take a dictionary instead.
|
||||
|
||||
|
||||
Example:
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
## cmake.configure_package_config_file can now take a dict
|
||||
|
||||
The `configuration` kwarg of the `configure_package_config_file()` function
|
||||
from the `cmake` module can now take a dict object, just like the regular
|
||||
`configure_file()` function.
|
|
@ -53,7 +53,7 @@ if T.TYPE_CHECKING:
|
|||
|
||||
class ConfigurePackageConfigFile(TypedDict):
|
||||
|
||||
configuration: build.ConfigurationData
|
||||
configuration: T.Union[build.ConfigurationData, dict]
|
||||
input: T.Union[str, mesonlib.File]
|
||||
install_dir: T.Optional[str]
|
||||
name: str
|
||||
|
@ -347,7 +347,7 @@ class CmakeModule(ExtensionModule):
|
|||
@noPosargs
|
||||
@typed_kwargs(
|
||||
'cmake.configure_package_config_file',
|
||||
KwargInfo('configuration', build.ConfigurationData, required=True),
|
||||
KwargInfo('configuration', (build.ConfigurationData, dict), required=True),
|
||||
KwargInfo('input',
|
||||
(str, mesonlib.File, ContainerTypeInfo(list, mesonlib.File)), required=True,
|
||||
validator=lambda x: 'requires exactly one file' if isinstance(x, list) and len(x) != 1 else None,
|
||||
|
@ -372,6 +372,9 @@ class CmakeModule(ExtensionModule):
|
|||
install_dir = os.path.join(state.environment.coredata.get_option(mesonlib.OptionKey('libdir')), 'cmake', name)
|
||||
|
||||
conf = kwargs['configuration']
|
||||
if isinstance(conf, dict):
|
||||
FeatureNew.single_use('cmake.configure_package_config_file dict as configuration', '0.62.0', state.subproject, location=state.current_node)
|
||||
conf = build.ConfigurationData(conf)
|
||||
|
||||
prefix = state.environment.coredata.get_option(mesonlib.OptionKey('prefix'))
|
||||
abs_install_dir = install_dir
|
||||
|
|
|
@ -4,11 +4,9 @@ project(
|
|||
|
||||
cmake = import('cmake')
|
||||
|
||||
cmake_conf = configuration_data()
|
||||
cmake_conf.set_quoted('foo', 'bar')
|
||||
cmake.configure_package_config_file(
|
||||
name : 'foolib',
|
||||
input : 'foolib.cmake.in',
|
||||
install_dir : get_option('libdir') / 'cmake',
|
||||
configuration : cmake_conf,
|
||||
configuration : {'foo': '"bar"'},
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue