@@ -22,93 +22,105 @@ find_package(Threads REQUIRED)
22
22
set (CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE )
23
23
24
24
# libprotobuf force us to depends on ZLIB::ZLIB target
25
- if (NOT BUILD_ZLIB)
25
+ if (NOT BUILD_ZLIB AND NOT TARGET ZLIB::ZLIB )
26
26
find_package (ZLIB REQUIRED)
27
27
endif ()
28
28
29
- if (NOT BUILD_absl)
29
+ if (NOT BUILD_absl AND NOT TARGET absl::base )
30
30
find_package (absl REQUIRED)
31
31
endif ()
32
32
33
- if (NOT BUILD_Protobuf)
33
+ if (NOT BUILD_Protobuf AND NOT TARGET protobuf::libprotobuf )
34
34
find_package (Protobuf REQUIRED)
35
35
endif ()
36
36
37
- if (NOT BUILD_Eigen3)
37
+ if (NOT BUILD_Eigen3 AND NOT TARGET Eigen3::Eigen )
38
38
find_package (Eigen3 REQUIRED)
39
39
endif ()
40
40
41
41
if (NOT BUILD_re2 AND NOT TARGET re2::re2)
42
42
find_package (re2 REQUIRED)
43
43
endif ()
44
44
45
+ # Third Party Solvers
45
46
if (USE_COINOR)
46
- if (NOT BUILD_CoinUtils)
47
+ if (NOT BUILD_CoinUtils AND NOT TARGET Coin::CoinUtils )
47
48
find_package (CoinUtils REQUIRED)
48
49
endif ()
49
50
50
- if (NOT BUILD_Osi)
51
+ if (NOT BUILD_Osi AND NOT TARGET Coin::Osi )
51
52
find_package (Osi REQUIRED)
52
53
endif ()
53
54
54
- if (NOT BUILD_Clp)
55
+ if (NOT BUILD_Clp AND NOT TARGET Coin::ClpSolver )
55
56
find_package (Clp REQUIRED)
56
57
endif ()
57
58
58
- if (NOT BUILD_Cgl)
59
+ if (NOT BUILD_Cgl AND NOT TARGET Coin::Cgl )
59
60
find_package (Cgl REQUIRED)
60
61
endif ()
61
62
62
- if (NOT BUILD_Cbc)
63
+ if (NOT BUILD_Cbc AND NOT TARGET Coin::CbcSolver )
63
64
find_package (Cbc REQUIRED)
64
65
endif ()
65
66
endif ()
66
67
67
- if (USE_GLPK AND NOT BUILD_GLPK)
68
- find_package (GLPK REQUIRED)
68
+ if (USE_CPLEX)
69
+ if (NOT TARGET CPLEX::CPLEX)
70
+ find_package (CPLEX REQUIRED)
71
+ endif ()
69
72
endif ()
70
73
71
- if (USE_HIGHS AND NOT BUILD_HIGHS)
72
- find_package (HIGHS REQUIRED)
74
+ if (USE_GLPK)
75
+ if (NOT BUILD_GLPK AND NOT TARGET GLPK::GLPK)
76
+ find_package (GLPK REQUIRED)
77
+ endif ()
73
78
endif ()
74
79
75
- if (USE_PDLP AND NOT BUILD_PDLP)
76
- find_package (PDLP REQUIRED)
80
+ if (USE_HIGHS)
81
+ if (NOT BUILD_HIGHS AND NOT TARGET highs::highs)
82
+ find_package (HIGHS REQUIRED)
83
+ endif ()
77
84
endif ()
78
85
79
- if (USE_SCIP AND NOT BUILD_SCIP)
80
- find_package (SCIP REQUIRED)
86
+ if (USE_PDLP)
87
+ if (NOT BUILD_PDLP)
88
+ find_package (PDLP REQUIRED)
89
+ endif ()
81
90
endif ()
82
91
83
- # Check optional Dependencies
84
- if (USE_CPLEX)
85
- find_package (CPLEX REQUIRED)
92
+ if (USE_SCIP)
93
+ if (NOT BUILD_SCIP AND NOT TARGET SCIP::libscip)
94
+ find_package (SCIP REQUIRED)
95
+ endif ()
86
96
endif ()
87
97
88
98
# CXX Test
89
- if (BUILD_TESTING AND NOT BUILD_googletest)
90
- find_package (GTest REQUIRED)
91
- endif ()
99
+ if (BUILD_TESTING)
100
+ if (NOT BUILD_googletest AND NOT TARGET GTest::gtest_main)
101
+ find_package (GTest REQUIRED)
102
+ endif ()
92
103
93
- if (BUILD_TESTING AND NOT BUILD_benchmark )
94
- find_package (benchmark REQUIRED)
95
- endif ()
104
+ if (NOT BUILD_benchmark AND NOT TARGET benchmark::benchmark )
105
+ find_package (benchmark REQUIRED)
106
+ endif ()
96
107
97
- if (BUILD_TESTING AND NOT BUILD_fuzztest)
98
- find_package (fuzztest REQUIRED)
108
+ if (NOT BUILD_fuzztest AND NOT TARGET fuzztest::fuzztest)
109
+ find_package (fuzztest REQUIRED)
110
+ endif ()
99
111
endif ()
100
112
101
113
# Check language Dependencies
102
114
if (BUILD_PYTHON)
103
- if (NOT BUILD_pybind11)
115
+ if (NOT BUILD_pybind11 AND NOT TARGET pybind11::pybind11_headers )
104
116
find_package (pybind11 REQUIRED)
105
117
endif ()
106
118
107
- if (NOT BUILD_pybind11_abseil)
119
+ if (NOT BUILD_pybind11_abseil AND NOT TARGET pybind11_abseil::absl_casters )
108
120
find_package (pybind11_abseil REQUIRED)
109
121
endif ()
110
122
111
- if (NOT BUILD_pybind11_protobuf)
123
+ if (NOT BUILD_pybind11_protobuf AND NOT TARGET pybind11_native_proto_caster )
112
124
find_package (pybind11_protobuf REQUIRED)
113
125
endif ()
114
126
endif ()
0 commit comments