Skip to content

Commit 9b041fe

Browse files
committed
refactor(taskfiles)!: Improve CMAKE_SETTINGS_DIR behaviour in utils:cmake by requiring explicit definition and checking it with a precondition.
1 parent 7ba9bdc commit 9b041fe

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

exports/taskfiles/utils/cmake.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ tasks:
9494
#
9595
# @param {string} BUILD_DIR Directory containing the completed build to use.
9696
# @param {string} INSTALL_PREFIX Path prefix of where the project should be installed.
97-
# @param {string} NAME CMake project name (used in directory names and the CMake settings file).
9897
# @param {string} [CMAKE_SETTINGS_DIR] If set, the directory where the project's CMake settings
9998
# file should be stored.
10099
# @param {string[]} [EXTRA_ARGS] Any additional arguments to pass to the install command.
100+
# @param {string} [NAME] CMake project name (used in directory names and the CMake settings file).
101101
install:
102102
internal: true
103103
label: "{{.TASK}}:{{.BUILD_DIR}}-{{.INSTALL_PREFIX}}-{{.EXTRA_ARGS}}"
@@ -107,7 +107,15 @@ tasks:
107107
EXTRA_ARGS:
108108
ref: "default (list) .EXTRA_ARGS"
109109
requires:
110-
vars: ["BUILD_DIR", "INSTALL_PREFIX", "NAME"]
110+
vars: ["BUILD_DIR", "INSTALL_PREFIX"]
111+
preconditions:
112+
- sh: >-
113+
{{if .CMAKE_SETTINGS_DIR}}
114+
{{not (empty .NAME)}}
115+
{{end}}
116+
msg: |-
117+
NAME must be set if CMAKE_SETTINGS_DIR is set.
118+
CMAKE_SETTINGS_DIR: {{.CMAKE_SETTINGS_DIR}}
111119
cmds:
112120
- >-
113121
cmake
@@ -162,7 +170,7 @@ tasks:
162170
CMAKE_JOBS: >-
163171
{{default "" .CMAKE_JOBS}}
164172
CMAKE_SETTINGS_DIR: >-
165-
{{default (printf "%s/cmake-settings" .WORK_DIR) .CMAKE_SETTINGS_DIR}}
173+
{{default "" .CMAKE_SETTINGS_DIR}}
166174
CMAKE_TARGETS:
167175
ref: "default (list) .CMAKE_TARGETS"
168176

0 commit comments

Comments
 (0)