Used to get some description information of the current project, that is, the configuration information defined in the xmake.lua project description file,
for example: target, option, etc.
::: tip API
project.target(name: <string>)
:::
| Parameter | Description |
|---|---|
| name | Required. Target name |
| Type | Description |
|---|---|
| target | Returns the target object, or nil if it doesn't exist |
Get and access the specified project target configuration, for example:
local target = project.target("test")
if target then
-- Get the target name
print(target:name())
-- Get the target directory, available after version 2.1.9
print(target:targetdir())
-- Get the target file name
print(target:targetfile())
-- Get the target type, which is: binary, static, shared
print(target:targetkind())
-- Get the target source file
local sourcefiles = target:sourcefiles()
-- Get a list of target installation header files
local srcheaders, dstheaders = target:headerfiles()
-- Get target dependencies
print(target:get("deps"))
end
::: tip API
project.targets()
:::
No parameters required for this function.
| Type | Description |
|---|---|
| table | Returns a table containing all target objects, with target names as keys and target objects as values |
Returns all compilation targets for the current project, for example:
for targetname, target in pairs(project.targets()) do
print(target:targetfile())
end
::: tip API
project.option(name: <string>)
:::
| Parameter | Description |
|---|---|
| name | Required. Option name |
| Type | Description |
|---|---|
| option | Returns the option object, or nil if it doesn't exist |
Get and access the option objects specified in the project, for example:
local option = project.option("test")
if option:enabled() then
option:enable(false)
end
::: tip API
project.options()
:::
No parameters required for this function.
| Type | Description |
|---|---|
| table | Returns a table containing all option objects, with option names as keys and option objects as values |
Returns all compilation targets for the current project, for example:
for optionname, option in pairs(project.options()) do
print(option:enabled())
end
::: tip API
project.name()
:::
No parameters required for this function.
| Type | Description |
|---|---|
| string | Returns the project name |
That is, get the project name configuration of set_project.
print(project.name())
::: tip API
project.version()
:::
No parameters required for this function.
| Type | Description |
|---|---|
| string | Returns the project version number |
That is, get set_version project version configuration.
print(project.version())