Skip to content

Commit b24f4ba

Browse files
committed
[bazel] Make sure @GLPK dependency is not pulled when --with_glpk=False
1 parent e64bb01 commit b24f4ba

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

ortools/glpk/BUILD.bazel

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ cc_library(
2020
name = "glpk_env_deleter",
2121
srcs = ["glpk_env_deleter.cc"],
2222
hdrs = ["glpk_env_deleter.h"],
23+
target_compatible_with =
24+
select({
25+
"//ortools/linear_solver:use_glpk": [],
26+
"//conditions:default": ["@platforms//:incompatible"],
27+
}),
2328
deps = [
2429
"//ortools/base",
2530
"@glpk",
@@ -30,6 +35,11 @@ cc_library(
3035
name = "glpk_formatters",
3136
srcs = ["glpk_formatters.cc"],
3237
hdrs = ["glpk_formatters.h"],
38+
target_compatible_with =
39+
select({
40+
"//ortools/linear_solver:use_glpk": [],
41+
"//conditions:default": ["@platforms//:incompatible"],
42+
}),
3343
deps = [
3444
"//ortools/base",
3545
"@abseil-cpp//absl/strings",
@@ -40,6 +50,11 @@ cc_library(
4050
cc_library(
4151
name = "glpk_computational_form",
4252
hdrs = ["glpk_computational_form.h"],
53+
target_compatible_with =
54+
select({
55+
"//ortools/linear_solver:use_glpk": [],
56+
"//conditions:default": ["@platforms//:incompatible"],
57+
}),
4358
deps = [
4459
"@glpk",
4560
],

ortools/math_opt/solvers/BUILD.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,11 @@ cc_library(
434434
"glpk_solver.cc",
435435
"glpk_solver.h",
436436
],
437+
target_compatible_with =
438+
select({
439+
"//ortools/linear_solver:use_glpk": [],
440+
"//conditions:default": ["@platforms//:incompatible"],
441+
}),
437442
visibility = ["//visibility:public"],
438443
deps = [
439444
":glpk_cc_proto",
@@ -482,6 +487,11 @@ cc_library(
482487
cc_test(
483488
name = "glpk_solver_test",
484489
srcs = ["glpk_solver_test.cc"],
490+
target_compatible_with =
491+
select({
492+
"//ortools/linear_solver:use_glpk": [],
493+
"//conditions:default": ["@platforms//:incompatible"],
494+
}),
485495
deps = [
486496
":glpk_solver",
487497
"//ortools/base:gmock_main",

ortools/math_opt/solvers/glpk/BUILD.bazel

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ cc_library(
2121
name = "rays",
2222
srcs = ["rays.cc"],
2323
hdrs = ["rays.h"],
24+
target_compatible_with =
25+
select({
26+
"//ortools/linear_solver:use_glpk": [],
27+
"//conditions:default": ["@platforms//:incompatible"],
28+
}),
2429
deps = [
2530
"//ortools/base:logging",
2631
"//ortools/base:status_macros",
@@ -38,6 +43,11 @@ cc_library(
3843
name = "glpk_sparse_vector",
3944
srcs = ["glpk_sparse_vector.cc"],
4045
hdrs = ["glpk_sparse_vector.h"],
46+
target_compatible_with =
47+
select({
48+
"//ortools/linear_solver:use_glpk": [],
49+
"//conditions:default": ["@platforms//:incompatible"],
50+
}),
4151
deps = [
4252
"//ortools/base:logging",
4353
"@abseil-cpp//absl/log:check",
@@ -47,6 +57,11 @@ cc_library(
4757
cc_test(
4858
name = "glpk_sparse_vector_test",
4959
srcs = ["glpk_sparse_vector_test.cc"],
60+
target_compatible_with =
61+
select({
62+
"//ortools/linear_solver:use_glpk": [],
63+
"//conditions:default": ["@platforms//:incompatible"],
64+
}),
5065
deps = [
5166
":glpk_sparse_vector",
5267
"//ortools/base:gmock_main",
@@ -57,11 +72,21 @@ cc_library(
5772
name = "gap",
5873
srcs = ["gap.cc"],
5974
hdrs = ["gap.h"],
75+
target_compatible_with =
76+
select({
77+
"//ortools/linear_solver:use_glpk": [],
78+
"//conditions:default": ["@platforms//:incompatible"],
79+
}),
6080
)
6181

6282
cc_test(
6383
name = "gap_test",
6484
srcs = ["gap_test.cc"],
85+
target_compatible_with =
86+
select({
87+
"//ortools/linear_solver:use_glpk": [],
88+
"//conditions:default": ["@platforms//:incompatible"],
89+
}),
6590
deps = [
6691
":gap",
6792
"//ortools/base:gmock_main",

0 commit comments

Comments
 (0)