Skip to content

Commit e8dc947

Browse files
committed
fix: add configurable tag for cuda build
1 parent c42d002 commit e8dc947

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

BUILD.bazel

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
12
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
2-
load("@bazel_skylib//lib:selects.bzl", "selects")
33
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
44
load("@rules_cuda//cuda:defs.bzl", "cuda_library", "requires_cuda")
55

@@ -10,12 +10,18 @@ copy_file(
1010
visibility = ["//visibility:public"],
1111
)
1212

13-
selects.config_setting_group(
14-
name = "cuda_enabled",
15-
match_all = [
16-
"@rules_cuda//cuda:is_valid_toolchain_found",
17-
"@rules_cuda//cuda:is_enabled",
18-
],
13+
bool_flag(
14+
name = "cupdlp_gpu",
15+
build_setting_default = False,
16+
)
17+
18+
config_setting(
19+
name = "cupdlp_gpu_enabled",
20+
flag_values = {
21+
"@rules_cuda//cuda:enable": "True",
22+
"@local_cuda//:valid_toolchain_found": "True",
23+
":cupdlp_gpu": "True",
24+
},
1925
)
2026

2127
cc_library(
@@ -76,7 +82,7 @@ cc_library(
7682
],
7783
}),
7884
defines = select({
79-
":cuda_enabled": ["CUPDLP_GPU"],
85+
":cupdlp_gpu_enabled": ["CUPDLP_GPU"],
8086
"//conditions:default": ["CUPDLP_CPU"],
8187
}),
8288
includes = [
@@ -96,7 +102,6 @@ cc_library(
96102
# "highs/simplex",
97103
# "highs/test_kkt",
98104
# "highs/util",
99-
"bazel-bin",
100105
],
101106
linkopts = select({
102107
"@rules_cc//cc/compiler:msvc-cl": ["-DEFAULTLIB:shell32.lib"],
@@ -107,7 +112,7 @@ cc_library(
107112
"//:config",
108113
"@zlib",
109114
] + select({
110-
":cuda_enabled": [":cupdlp"],
115+
":cupdlp_gpu_enabled": [":cupdlp"],
111116
"//conditions:default": [],
112117
}),
113118
)

highs/pdlp/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ cmake --build build --parallel
5656
##### Bazel
5757

5858
```bash
59-
# Will build with CUDA if a CUDA toolchain is detected
59+
# Will NOT build with CUDA, only CPU support
6060
bazel build //:highs
61-
# Ensure the target is built without CUDA
62-
bazel build //:highs --@rules_cuda//cuda:enable=False
61+
# Will build with CUDA if a CUDA toolchain is detected
62+
bazel build //:highs --//:cupdlp_gpu
6363
```

0 commit comments

Comments
 (0)