Skip to content

refactor(taskfiles): NAME should not be a required parameter in utils:cmake:install #50

@davidlion

Description

@davidlion

Bug

The CMake install task supports writing a settings file for the package being installed through the optional parameter CMAKE_SETTINGS_DIR. However, the task requires the NAME parameter despite it only being used if CMAKE_SETTINGS_DIR is set.

Relevant task:

# Runs the CMake install step for the given build directory. The caller must have previously
# called `build` on `BUILD_DIR` for this task to succeed. If `CMAKE_SETTINGS_DIR` is set, a
# settings file will be created in that directory, containing a `{{.NAME}}_ROOT` CMake variable
# that points to `INSTALL_PREFIX`.
#
# NOTE: We purposely omit `sources` and `generates` as we defer to `cmake` to decide whether it
# should perform any actions.
#
# @param {string} BUILD_DIR Directory containing the completed build to use.
# @param {string} INSTALL_PREFIX Path prefix of where the project should be installed.
# @param {string} NAME CMake project name (used in directory names and the CMake settings file).
# @param {string} [CMAKE_SETTINGS_DIR] If set, the directory where the project's CMake settings
# file should be stored.
# @param {string[]} [EXTRA_ARGS] Any additional arguments to pass to the install command.
install:
internal: true
label: "{{.TASK}}:{{.BUILD_DIR}}-{{.INSTALL_PREFIX}}-{{.EXTRA_ARGS}}"
vars:
CMAKE_SETTINGS_DIR: >-
{{default "" .CMAKE_SETTINGS_DIR}}
EXTRA_ARGS:
ref: "default (list) .EXTRA_ARGS"
requires:
vars: ["BUILD_DIR", "INSTALL_PREFIX", "NAME"]
cmds:
- >-
cmake
--install "{{.BUILD_DIR}}"
--prefix "{{.INSTALL_PREFIX}}"
{{- range .EXTRA_ARGS}}
"{{.}}"
{{- end}}
- >-
{{- if .CMAKE_SETTINGS_DIR}}
echo "set({{.NAME}}_ROOT
\"{{.INSTALL_PREFIX}}\"
CACHE PATH
\"Package root for {{.NAME}}.\"
)" >> "{{.CMAKE_SETTINGS_DIR}}/{{.NAME}}.cmake"
{{- end}}

Version

e300d1b

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions