-
Notifications
You must be signed in to change notification settings - Fork 9
feat(taskfiles)!: Add cmake:install-deps-and-generate-settings to install all CMake-based dependencies and write their settings files.
#41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
f94b1d0
00633c2
422d25f
bafab28
92d388d
d744355
aae90ca
7b1717c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,19 +86,25 @@ tasks: | |
|
|
||
| # 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. We purposely omit `sources` and | ||
| # `generates` as we defer to `cmake` to decide whether it should perform any actions. | ||
| # `generates` as we defer to `cmake` to decide whether it should perform any actions. If | ||
| # `CMAKE_SETTINGS_DIR` exists a file containing the CMake project_ROOT variable will be written. | ||
| # | ||
| # @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 CMake settings). | ||
| # @param {string} [CMAKE_SETTINGS_DIR] If set, the directory to write the project's CMake settings | ||
| # file in. | ||
| # @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"] | ||
| vars: ["BUILD_DIR", "INSTALL_PREFIX", "NAME"] | ||
| cmds: | ||
|
Comment on lines
+105
to
111
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Requiring Adding
|
||
| - >- | ||
| cmake | ||
|
|
@@ -107,6 +113,14 @@ tasks: | |
| {{- range .EXTRA_ARGS}} | ||
| "{{.}}" | ||
| {{- end}} | ||
| - >- | ||
| {{- if .CMAKE_SETTINGS_DIR}} | ||
| echo "set({{.NAME}}_ROOT | ||
| \"{{.INSTALL_PREFIX}}\" | ||
| CACHE PATH | ||
| \"Path to {{.NAME}} settings.\" | ||
kirkrodrigues marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| )" >> "{{.CMAKE_SETTINGS_DIR}}/{{.NAME}}.cmake" | ||
| {{- end}} | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Downloads a CMake project tar file from `URL` and then generates, builds, and installs the | ||
| # project. We purposely omit `sources` and `generates` as we defer to `cmake` to decide whether it | ||
|
|
@@ -135,6 +149,8 @@ tasks: | |
| # @param {string[]} [TARGETS] A list of specific targets to build instead of the default target. | ||
| # | ||
| # CMake install parameters | ||
| # @param {string} [CMAKE_SETTINGS_DIR={{.WORK_DIR}}/cmake-settings] If set, the directory to write | ||
| # the project's CMake settings file in. | ||
davidlion marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # @param {string[]} [INSTALL_ARGS] Any additional arguments to pass to the CMake install command. | ||
| # @param {string} [INSTALL_PREFIX={{.WORK_DIR}}/{{.NAME}}-install] Path prefix of where the | ||
| # project should be installed. | ||
|
|
@@ -163,6 +179,8 @@ tasks: | |
| ref: "default (list) .TARGETS" | ||
|
|
||
| # CMake install parameters | ||
| CMAKE_SETTINGS_DIR: >- | ||
| {{default (printf "%s/cmake-settings" .WORK_DIR) .CMAKE_SETTINGS_DIR}} | ||
| INSTALL_ARGS: | ||
| ref: "default (list) .INSTALL_ARGS" | ||
| INSTALL_PREFIX: >- | ||
|
|
@@ -193,6 +211,43 @@ tasks: | |
| - task: "install" | ||
| vars: | ||
| BUILD_DIR: "{{.BUILD_DIR}}" | ||
| CMAKE_SETTINGS_DIR: "{{.CMAKE_SETTINGS_DIR}}" | ||
| EXTRA_ARGS: | ||
| ref: ".INSTALL_ARGS" | ||
| INSTALL_PREFIX: "{{.INSTALL_PREFIX}}" | ||
| NAME: "{{.NAME}}" | ||
|
|
||
| # Setup all CMake dependencies for a project by: | ||
| # 1. Create a directory to contain all CMake settings files (CMAKE_SETTINGS_DIR). | ||
| # 2. Install all dependencies by running DEP_TASK. | ||
| # 3. Include each dependency's settings file in a combined settings file (CMAKE_SETTINGS_FILE) | ||
| # for use inside a CMake project. | ||
| # | ||
| # @param {string} CMAKE_SETTINGS_DIR A directory path to write CMake settings files to. | ||
| # @param {string} DEP_TASK A task to run that will install all dependencies. | ||
| # - The task name must be qualified from the root of the project. | ||
| # - The task must not require any arguments (to use a task with arguments create a new task that | ||
| # calls the original with any arguments set). | ||
| # - Dependencies must write their settings file to CMAKE_SETTINGS_DIR to be included into the | ||
| # combined settings file (CMAKE_SETTINGS_FILE). | ||
| # @param {string} [CMAKE_SETTINGS_FILE] | ||
| # @param {string} [CMAKE_SETTINGS_FILE={{.CMAKE_SETTINGS_DIR}}/settings.cmake] The file to write | ||
| # that includes each dependency's settings file. | ||
davidlion marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| setup-deps: | ||
|
||
| internal: true | ||
| label: "{{.TASK}}:{{.CMAKE_SETTINGS_DIR}}-{{.DEP_TASK}}" | ||
| vars: | ||
| CMAKE_SETTINGS_FILE: >- | ||
| {{default (printf "%s/settings.cmake" .CMAKE_SETTINGS_DIR) .CMAKE_SETTINGS_FILE}} | ||
| requires: | ||
| vars: ["CMAKE_SETTINGS_DIR", "DEP_TASK"] | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| cmds: | ||
| - "rm -rf {{.CMAKE_SETTINGS_DIR}}" | ||
| - "mkdir -p {{.CMAKE_SETTINGS_DIR}}" | ||
| - task: "::{{.DEP_TASK}}" | ||
davidlion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - >- | ||
davidlion marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| for file in {{.CMAKE_SETTINGS_DIR}}/*.cmake; do | ||
| if [ "$file" != "{{.CMAKE_SETTINGS_FILE}}" ]; then | ||
davidlion marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| echo "include(\"$file\")" >> "{{.CMAKE_SETTINGS_FILE}}"; | ||
| fi | ||
| done | ||
Uh oh!
There was an error while loading. Please reload this page.