Skip to content

Commit d3879d2

Browse files
authored
Merge pull request #4779 from google/remove_glpk_deps
[bazel] Make sure @GLPK dependency is not pulled when --with_glpk=False
2 parents 8fa1c3b + b24f4ba commit d3879d2

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
@@ -430,6 +430,11 @@ cc_library(
430430
"glpk_solver.cc",
431431
"glpk_solver.h",
432432
],
433+
target_compatible_with =
434+
select({
435+
"//ortools/linear_solver:use_glpk": [],
436+
"//conditions:default": ["@platforms//:incompatible"],
437+
}),
433438
visibility = ["//visibility:public"],
434439
deps = [
435440
":glpk_cc_proto",
@@ -478,6 +483,11 @@ cc_library(
478483
cc_test(
479484
name = "glpk_solver_test",
480485
srcs = ["glpk_solver_test.cc"],
486+
target_compatible_with =
487+
select({
488+
"//ortools/linear_solver:use_glpk": [],
489+
"//conditions:default": ["@platforms//:incompatible"],
490+
}),
481491
deps = [
482492
":glpk_solver",
483493
"//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)