Skip to content

Commit b787991

Browse files
authored
Merge branch 'main' into feature/improve-hfc-FIND_PACKAGE_ARGS-handling
2 parents f1635a8 + 7d0e6e5 commit b787991

File tree

31 files changed

+478
-105
lines changed

31 files changed

+478
-105
lines changed

.github/PULL_REQUEST_TEMPLATE/HFC-RELEASING.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
2-
name: [HFC] Release
3-
about: Checklist to make a release
2+
name: "[HFC] Release"
3+
about: "Checklist to make a release"
44
title: "[HFC][RELEASE] v0.0."
5-
labels: ''
6-
assignees: ''
7-
5+
labels: ""
6+
assignees: ""
87
---
98

109
# How to make a release ?

.github/workflows/ci.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
name: build
22

3-
# This workflow is triggered on pushes to the repository.
3+
# This workflow is triggered on PRs ony
44
on:
5-
push:
6-
branches:
7-
- main
8-
- develop
9-
pull_request:
5+
pull_request_target:
6+
7+
permissions:
8+
contents: read
109

1110
env:
1211
GHA_HFC_TOOLS_DIR_CACHE_KEY: 20241128
@@ -49,11 +48,15 @@ jobs:
4948
restore-keys: |
5049
${{ runner.os }}-hfc-project-cache-
5150
52-
- name: checkout
51+
# Checkout the project to the correct location
52+
# note: having two distinct paths here depending on wether or not we're looking at a PR or push to main
53+
#
54+
# This is necessary because we use the pull_request_target which requires a fully specified :ref: config
55+
- name: checkout pull request
5356
uses: actions/checkout@v4
54-
with:
55-
# Relative path under $GITHUB_WORKSPACE to place the repository
57+
with:
5658
path: './hfc_project'
59+
ref: ${{ github.event.pull_request.head.sha }}
5760

5861
- name: tipi builds project
5962
run: |

CONTRIBUTING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
How to contribute to Hermetic FetchContent
2+
==========================================
3+
4+
5+
### Did you find a bug?
6+
7+
- Please ensure the bug was not already reported by searching in the existing issues
8+
9+
- If you're unable to find an existing issue, please open a new issue. Be sure to include a *title and a clear description* and as much relevant information as possible. If you can, please provide us with a minimal sample to help us reproduce the issue.
10+
11+
12+
### Did you write a patch that fixes a bug?
13+
14+
- Please open a new Github pull request with the patch
15+
16+
- Ensure the PR description clearly describes the problem and solution
17+
18+
- Ensure that the test suite passes. We are fond of contributions that add tests ensuring no regression will happen in the future :heart:

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ You can run the HermeticFetchContent test suite this way:
146146
* `HFC_PROJECT_HFC_BASEDIR` to use a common "HFC base dir" (which will contain the dependency install trees)
147147
* `HERMETIC_FETCHCONTENT_TOOLS_DIR` if you have one, avoid rebuilding `goldilock` too frequently, by default a `${CMAKE_BINARY_DIR}/.hfc_tools/` directory will be created
148148

149+
## Contributing
150+
151+
Please refer to [Contributing](./CONTRIBUTING.md) for details.
152+
149153
## Authors
150154

151155
Authored with love, blood and tears in Zürich, Switzerland by team **[tipi.build](https://tipi.build)**.

cmake/modules/hfc_autotools_register_content_build.cmake

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,19 @@ function(hfc_autotools_register_content_build content_name)
118118

119119
endif()
120120

121-
if(HERMETIC_FETCHCONTENT_REMOVE_BUILD_DIR_AFTER_INSTALL)
121+
122+
if(HFC_V1_REMOVE_BUILD_DIR_AFTER_INSTALL)
122123
string(APPEND install_command " && ${CMAKE_COMMAND} -E rm -rf ${FN_ARG_PROJECT_BINARY_DIR} ")
123124
endif()
124125

125-
if(HERMETIC_FETCHCONTENT_REMOVE_SOURCE_DIR_AFTER_INSTALL)
126+
if(HFC_V1_REMOVE_SOURCE_DIR_AFTER_INSTALL)
126127
string(APPEND install_command " && ${CMAKE_COMMAND} -E rm -rf ${FN_ARG_PROJECT_SOURCE_DIR} ")
128+
129+
hfc_compute_subbuild_path(${content_name} subbuild_path
130+
SOURCE_DIR "${FN_ARG_PROJECT_SOURCE_DIR}"
131+
)
132+
133+
string(APPEND install_command " && ${CMAKE_COMMAND} -E rm -rf ${subbuild_path} ")
127134
endif()
128135

129136
#hfc_get_command_string_in_cleared_env("${build_command}" build_command)

cmake/modules/hfc_cmake_register_content_build.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function(hfc_cmake_register_content_build content_name)
100100

101101
endif()
102102

103-
if ("${FN_ARG_CUSTOM_INSTALL_TARGETS}" STREQUAL "")
103+
if (NOT FN_ARG_BUILD_TARGETS AND (NOT FN_ARG_CUSTOM_INSTALL_TARGETS))
104104
list(APPEND install_commands_list "${CMAKE_COMMAND} --install .")
105105
endif()
106106

@@ -142,11 +142,17 @@ function(hfc_cmake_register_content_build content_name)
142142

143143
endif()
144144

145-
if(HERMETIC_FETCHCONTENT_REMOVE_BUILD_DIR_AFTER_INSTALL)
145+
if(HFC_V1_REMOVE_BUILD_DIR_AFTER_INSTALL)
146146
string(APPEND install_command " && ${CMAKE_COMMAND} -E rm -rf ${FN_ARG_PROJECT_BINARY_DIR} ")
147147
endif()
148-
if(HERMETIC_FETCHCONTENT_REMOVE_SOURCE_DIR_AFTER_INSTALL)
148+
if(HFC_V1_REMOVE_SOURCE_DIR_AFTER_INSTALL)
149149
string(APPEND install_command " && ${CMAKE_COMMAND} -E rm -rf ${FN_ARG_PROJECT_SOURCE_DIR} ")
150+
151+
hfc_compute_subbuild_path(${content_name} subbuild_path
152+
SOURCE_DIR "${FN_ARG_PROJECT_SOURCE_DIR}"
153+
)
154+
155+
string(APPEND install_command " && ${CMAKE_COMMAND} -E rm -rf ${subbuild_path} ")
150156
endif()
151157

152158
if(DEFINED FN_ARG_PROJECT_SOURCE_SUBDIR)

cmake/modules/hfc_initialize.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ function(hfc_initialize HFC_ROOT_DIR)
307307

308308
# Note : We don't set the following defaults on purpose as unset it will be evaluated OFF
309309
# This allows also overriding with a pure scope variable and not CACHE
310-
# set(HERMETIC_FETCHCONTENT_REMOVE_BUILD_DIR_AFTER_INSTALL OFF CACHE BOOL "By default save space by removing build")
311-
# set(HERMETIC_FETCHCONTENT_REMOVE_SOURCE_DIR_AFTER_INSTALL OFF CACHE BOOL "By default save space by removing sources after install")
310+
# set(HFC_V1_REMOVE_BUILD_DIR_AFTER_INSTALL OFF CACHE BOOL "By default save space by removing build")
311+
# set(HFC_V1_REMOVE_SOURCE_DIR_AFTER_INSTALL OFF CACHE BOOL "By default save space by removing sources after install")
312312

313313
set_property(GLOBAL PROPERTY HERMETIC_FETCHCONTENT_INITIALIZED ON)
314314
set(HERMETIC_FETCHCONTENT_ROOT_DIR "${HFC_ROOT_DIR}" CACHE INTERNAL "Root directory of Hermetic_FetchContent")

cmake/modules/hfc_make_available_single.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ function(hfc_make_available_single content_name build_at_configure_time)
6868
HERMETIC_DISCOVER_TARGETS_FILE_PATTERN
6969

7070
HERMETIC_BUILD_AT_CONFIGURE_TIME
71+
72+
# Disambiguate parameter parsing with all supported
73+
# fetchcontent-details
74+
SBOM_LICENSE
75+
SBOM_SUPPLIER
7176
)
7277

7378
set(multi_value_params

cmake/modules/hfc_populate_project.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ function(hfc_populate_project_declare content_name)
9898
GIT_REPOSITORY
9999
GIT_TAG
100100
GIT_SUBMODULES
101+
GIT_SHALLOW
101102
SOURCE_DIR
102103
BUILD_IN_SOURCE_TREE
103104
SOURCE_SUBDIR
@@ -262,6 +263,10 @@ function(hfc_populate_project_declare content_name)
262263
list(APPEND populate_args "PATCH_COMMAND" "${FN_ARG_PATCH_COMMAND}")
263264
list(APPEND populate_args "UPDATE_DISCONNECTED" "1") # avoid issues with repeated builds, which would "repatch"
264265
endif()
266+
267+
if(FN_ARG_GIT_SHALLOW)
268+
list(APPEND populate_args "GIT_SHALLOW" ${FN_ARG_GIT_SHALLOW})
269+
endif()
265270

266271
# we used to fix issues that could occur if the sources are missing but the stamp file were still around
267272
# we now explictely trust the stamps file, this allow better debugging for developers

cmake/modules/hfc_sbom.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ cmake_policy(SET CMP0007 NEW)
189189
function(file)
190190
list(GET ARGN 0 file_OP)
191191
list(GET ARGN 1 param_2)
192-
list(SUBLIST ARGN 2 -1 remaining_args)
193192
194193
if((\"\${file_OP}\" STREQUAL \"APPEND\") AND (\"\${param_2}\" STREQUAL \"\${spdx_in_file_dest}\"))
194+
list(SUBLIST ARGN 2 -1 remaining_args)
195195
_file(APPEND \"\${spdx_in_file_tmp}\" \${remaining_args})
196196
elseif(\"\${file_OP}\" STREQUAL \"READ\")
197197
_file(\${ARGN})
@@ -220,7 +220,10 @@ message(STATUS \" - generating SBOM\")
220220
221221
set(SBOM_VERIFICATION_CODE \"\")
222222
configure_file(\"\${spdx_in_file_tmp}\" \"${output_destination_path}.\${tmp_suffix}\")
223-
file(COPY_FILE \"${output_destination_path}.\${tmp_suffix}\" \"${output_destination_path}\" ONLY_IF_DIFFERENT)
223+
file(TOUCH \"${output_destination_path}.lock\")
224+
file(LOCK \"${output_destination_path}.lock\")
225+
file(COPY_FILE \"${output_destination_path}.\${tmp_suffix}\" \"${output_destination_path}\" ONLY_IF_DIFFERENT)
226+
file(LOCK \"${output_destination_path}.lock\" RELEASE)
224227
225228
# clean up temp files
226229
message(STATUS \"Cleaning up temp files\")

0 commit comments

Comments
 (0)