Skip to content

Commit a1f3bbd

Browse files
committed
fix some issues reported by github CI
1 parent bd17f0f commit a1f3bbd

File tree

3 files changed

+188
-6
lines changed

3 files changed

+188
-6
lines changed

cmake/use-fetch-content.cmake

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
cmake_minimum_required(VERSION 3.24)
2+
3+
include(FetchContent)
4+
5+
if(NOT BEMAN_EXEMPLAR_LOCKFILE)
6+
set(BEMAN_EXEMPLAR_LOCKFILE
7+
"lockfile.json"
8+
CACHE FILEPATH
9+
"Path to the dependency lockfile for the Beman Exemplar."
10+
)
11+
endif()
12+
13+
set(BemanExemplar_projectDir "${CMAKE_CURRENT_LIST_DIR}/..")
14+
message(TRACE "BemanExemplar_projectDir=\"${BemanExemplar_projectDir}\"")
15+
16+
message(TRACE "BEMAN_EXEMPLAR_LOCKFILE=\"${BEMAN_EXEMPLAR_LOCKFILE}\"")
17+
file(
18+
REAL_PATH
19+
"${BEMAN_EXEMPLAR_LOCKFILE}"
20+
BemanExemplar_lockfile
21+
BASE_DIRECTORY "${BemanExemplar_projectDir}"
22+
EXPAND_TILDE
23+
)
24+
message(DEBUG "Using lockfile: \"${BemanExemplar_lockfile}\"")
25+
26+
# Force CMake to reconfigure the project if the lockfile changes
27+
set_property(
28+
DIRECTORY "${BemanExemplar_projectDir}"
29+
APPEND
30+
PROPERTY CMAKE_CONFIGURE_DEPENDS "${BemanExemplar_lockfile}"
31+
)
32+
33+
# For more on the protocol for this function, see:
34+
# https://cmake.org/cmake/help/latest/command/cmake_language.html#provider-commands
35+
function(BemanExemplar_provideDependency method package_name)
36+
# Read the lockfile
37+
file(READ "${BemanExemplar_lockfile}" BemanExemplar_rootObj)
38+
39+
# Get the "dependencies" field and store it in BemanExemplar_dependenciesObj
40+
string(
41+
JSON
42+
BemanExemplar_dependenciesObj
43+
ERROR_VARIABLE BemanExemplar_error
44+
GET "${BemanExemplar_rootObj}"
45+
"dependencies"
46+
)
47+
if(BemanExemplar_error)
48+
message(FATAL_ERROR "${BemanExemplar_lockfile}: ${BemanExemplar_error}")
49+
endif()
50+
51+
# Get the length of the libraries array and store it in BemanExemplar_dependenciesObj
52+
string(
53+
JSON
54+
BemanExemplar_numDependencies
55+
ERROR_VARIABLE BemanExemplar_error
56+
LENGTH "${BemanExemplar_dependenciesObj}"
57+
)
58+
if(BemanExemplar_error)
59+
message(FATAL_ERROR "${BemanExemplar_lockfile}: ${BemanExemplar_error}")
60+
endif()
61+
62+
# Loop over each dependency object
63+
math(EXPR BemanExemplar_maxIndex "${BemanExemplar_numDependencies} - 1")
64+
foreach(BemanExemplar_index RANGE "${BemanExemplar_maxIndex}")
65+
set(BemanExemplar_errorPrefix
66+
"${BemanExemplar_lockfile}, dependency ${BemanExemplar_index}"
67+
)
68+
69+
# Get the dependency object at BemanExemplar_index
70+
# and store it in BemanExemplar_depObj
71+
string(
72+
JSON
73+
BemanExemplar_depObj
74+
ERROR_VARIABLE BemanExemplar_error
75+
GET "${BemanExemplar_dependenciesObj}"
76+
"${BemanExemplar_index}"
77+
)
78+
if(BemanExemplar_error)
79+
message(
80+
FATAL_ERROR
81+
"${BemanExemplar_errorPrefix}: ${BemanExemplar_error}"
82+
)
83+
endif()
84+
85+
# Get the "name" field and store it in BemanExemplar_name
86+
string(
87+
JSON
88+
BemanExemplar_name
89+
ERROR_VARIABLE BemanExemplar_error
90+
GET "${BemanExemplar_depObj}"
91+
"name"
92+
)
93+
if(BemanExemplar_error)
94+
message(
95+
FATAL_ERROR
96+
"${BemanExemplar_errorPrefix}: ${BemanExemplar_error}"
97+
)
98+
endif()
99+
100+
# Get the "package_name" field and store it in BemanExemplar_pkgName
101+
string(
102+
JSON
103+
BemanExemplar_pkgName
104+
ERROR_VARIABLE BemanExemplar_error
105+
GET "${BemanExemplar_depObj}"
106+
"package_name"
107+
)
108+
if(BemanExemplar_error)
109+
message(
110+
FATAL_ERROR
111+
"${BemanExemplar_errorPrefix}: ${BemanExemplar_error}"
112+
)
113+
endif()
114+
115+
# Get the "git_repository" field and store it in BemanExemplar_repo
116+
string(
117+
JSON
118+
BemanExemplar_repo
119+
ERROR_VARIABLE BemanExemplar_error
120+
GET "${BemanExemplar_depObj}"
121+
"git_repository"
122+
)
123+
if(BemanExemplar_error)
124+
message(
125+
FATAL_ERROR
126+
"${BemanExemplar_errorPrefix}: ${BemanExemplar_error}"
127+
)
128+
endif()
129+
130+
# Get the "git_tag" field and store it in BemanExemplar_tag
131+
string(
132+
JSON
133+
BemanExemplar_tag
134+
ERROR_VARIABLE BemanExemplar_error
135+
GET "${BemanExemplar_depObj}"
136+
"git_tag"
137+
)
138+
if(BemanExemplar_error)
139+
message(
140+
FATAL_ERROR
141+
"${BemanExemplar_errorPrefix}: ${BemanExemplar_error}"
142+
)
143+
endif()
144+
145+
if(method STREQUAL "FIND_PACKAGE")
146+
if(package_name STREQUAL BemanExemplar_pkgName)
147+
string(
148+
APPEND
149+
BemanExemplar_debug
150+
"Redirecting find_package calls for ${BemanExemplar_pkgName} "
151+
"to FetchContent logic fetching ${BemanExemplar_repo} at "
152+
"${BemanExemplar_tag} according to ${BemanExemplar_lockfile}."
153+
)
154+
message(DEBUG "${BemanExemplar_debug}")
155+
FetchContent_Declare(
156+
"${BemanExemplar_name}"
157+
GIT_REPOSITORY "${BemanExemplar_repo}"
158+
GIT_TAG "${BemanExemplar_tag}"
159+
EXCLUDE_FROM_ALL
160+
)
161+
set(INSTALL_GTEST OFF) # Disable GoogleTest installation
162+
FetchContent_MakeAvailable("${BemanExemplar_name}")
163+
164+
# Important! <PackageName>_FOUND tells CMake that `find_package` is
165+
# not needed for this package anymore
166+
set("${BemanExemplar_pkgName}_FOUND" TRUE PARENT_SCOPE)
167+
endif()
168+
endif()
169+
endforeach()
170+
endfunction()
171+
172+
cmake_language(
173+
SET_DEPENDENCY_PROVIDER BemanExemplar_provideDependency
174+
SUPPORTED_METHODS FIND_PACKAGE
175+
)

src/beman/execution/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
# cmake-format: on
55

6+
project(
7+
beman.execution
8+
DESCRIPTION "Beman implementation of asynchronous components"
9+
LANGUAGES CXX
10+
VERSION 0.0.1
11+
)
12+
613
include (GNUInstallDirs)
714

815
add_library(beman.execution STATIC)

tests/beman/execution/exec-bulk.test.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ auto test_bulk() {
1515
auto b0 = test_std::bulk(test_std::just(), 1, [](int) {});
1616

1717
static_assert(test_std::sender<decltype(b0)>);
18-
auto b0_env = test_std::get_env(b0);
18+
auto b0_env = test_std::get_env(b0);
1919
[[maybe_unused]] auto b0_completions = test_std::get_completion_signatures(b0, b0_env);
2020
static_assert(
2121
std::is_same_v<decltype(b0_completions),
@@ -28,7 +28,7 @@ auto test_bulk() {
2828
auto b1 = test_std::bulk(test_std::just(), 5, [&](int i) { counter += i; });
2929

3030
static_assert(test_std::sender<decltype(b1)>);
31-
auto b1_env = test_std::get_env(b0);
31+
auto b1_env = test_std::get_env(b0);
3232
[[maybe_unused]] auto b1_completions = test_std::get_completion_signatures(b1, b1_env);
3333
static_assert(
3434
std::is_same_v<decltype(b1_completions),
@@ -47,7 +47,7 @@ auto test_bulk() {
4747
results[index] = vec[index] * b[index];
4848
});
4949
static_assert(test_std::sender<decltype(b2)>);
50-
auto b2_env = test_std::get_env(b2);
50+
auto b2_env = test_std::get_env(b2);
5151
[[maybe_unused]] auto b2_completions = test_std::get_completion_signatures(b2, b2_env);
5252
static_assert(
5353
std::is_same_v<decltype(b2_completions),
@@ -65,8 +65,8 @@ auto test_bulk() {
6565
}
6666

6767
auto test_bulk_noexept() {
68-
auto b0 = test_std::bulk(test_std::just(), 1, [](int) noexcept {});
69-
auto b0_env = test_std::get_env(b0);
68+
auto b0 = test_std::bulk(test_std::just(), 1, [](int) noexcept {});
69+
auto b0_env = test_std::get_env(b0);
7070
[[maybe_unused]] auto b0_completions = test_std::get_completion_signatures(b0, b0_env);
7171
static_assert(std::is_same_v<decltype(b0_completions),
7272
beman::execution::completion_signatures<beman::execution::set_value_t()> >,
@@ -78,7 +78,7 @@ auto test_bulk_noexept() {
7878
auto b1 = test_std::bulk(test_std::just(), 5, [&](int i) noexcept { counter += i; });
7979

8080
static_assert(test_std::sender<decltype(b1)>);
81-
auto b1_env = test_std::get_env(b0);
81+
auto b1_env = test_std::get_env(b0);
8282
[[maybe_unused]] auto b1_completions = test_std::get_completion_signatures(b1, b1_env);
8383
static_assert(std::is_same_v<decltype(b1_completions),
8484
beman::execution::completion_signatures<beman::execution::set_value_t()> >,

0 commit comments

Comments
 (0)