declare_dependency()
This function returns a dep object that
behaves like the return value of dependency() but is
internal to the current build. One use case for this is in
subprojects. This allows a subproject to easily specify how it should
be used. This makes it interchangeable with the same dependency that
is provided externally by the system. Another common use case is to
declare project targets as dependencies so they may be used as
dependencies of other build targets.
Signature
# This function returns a dep object that
dep declare_dependency(
compile_args : array[str] # Compile arguments to use
d_import_dirs : array[inc | str] # the directories to add to the string search path (i
d_module_versions : str | int | array[str | int] # The [D version identifiers](https://dlang
dependencies : array[dep] # Other dependencies needed to use this dependency
extra_files : array[str | file] # extra files to add to targets
include_directories : array[inc | str] # the directories to add to header search path,
link_args : array[str] # Link arguments to use
link_whole : array[lib] # Libraries to link fully, same as executable().
link_with : array[lib] # Libraries to link against
objects : array[extracted_obj] # an array of object files, to be linked directly into the targets that use the
sources : array[str | file | custom_tgt | custom_idx | generated_list] # sources to add to targets
variables : dict[str] | array[str] # a dictionary of arbitrary strings,
version : str # the version of this dependency,
)
Arguments
The function declare_dependency()
accepts the following keyword arguments:
| Name | Type | Description | Tags |
|---|---|---|---|
compile_args |
array[str] |
Compile arguments to use. |
|
d_import_dirs |
array[inc | str] |
the directories to add to the string search path (i.e. |
(since 0.62.0) |
d_module_versions |
str | int | array[str | int] |
The D version identifiers to add during the compilation of D source files. |
(since 0.62.0) |
dependencies |
array[dep] |
Other dependencies needed to use this dependency. |
|
extra_files |
array[str | file] |
extra files to add to targets. mostly used for IDE integration. |
(since 1.2.0) |
include_directories |
array[inc | str] |
the directories to add to header search path,
must be |
|
link_args |
array[str] |
Link arguments to use. |
|
link_whole |
array[lib] |
Libraries to link fully, same as |
(since 0.46.0) |
link_with |
array[lib] |
Libraries to link against. |
|
objects |
array[extracted_obj] |
an array of object files, to be linked directly into the targets that use the dependency. |
(since 1.1.0) |
sources |
array[str | file | custom_tgt | custom_idx | generated_list] |
sources to add to targets (or generated header files that should be built before sources including them are built) |
|
variables |
dict[str] | array[str] |
a dictionary of arbitrary strings,
this is meant to be used
in subprojects where special variables would be provided via cmake or
pkg-config. since 0.56.0 it can also be an array of |
(since 0.54.0) |
version |
str |
the version of this dependency,
such as |
|
The results of the search are