Skip to content

Commit 9335950

Browse files
committed
cmake: fix configure when using -DBUILD_TESTING=OFF
1 parent 1ccab56 commit 9335950

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ CMAKE_DEPENDENT_OPTION(BUILD_re2 "Build the re2 dependency Library" OFF
196196
message(STATUS "Build re2: ${BUILD_re2}")
197197

198198
if(BUILD_TESTING)
199+
set(OR_TOOLS_BUILD_TESTING ON)
199200
CMAKE_DEPENDENT_OPTION(BUILD_googletest "Build googletest" OFF
200201
"NOT BUILD_DEPS" ON)
201202
CMAKE_DEPENDENT_OPTION(BUILD_benchmark "Build benchmark" OFF
@@ -215,6 +216,7 @@ if(BUILD_TESTING)
215216
"NOT BUILD_DEPS" ON)
216217
endif()
217218
else()
219+
set(OR_TOOLS_BUILD_TESTING OFF)
218220
set(BUILD_googletest OFF)
219221
set(BUILD_protobuf_matchers OFF)
220222
set(BUILD_benchmark OFF)

cmake/dependencies/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ if(BUILD_absl)
120120
set(ABSL_USE_SYSTEM_INCLUDES ON)
121121
# We want Abseil to declare what C++ standard it was compiled with.
122122
set(ABSL_PROPAGATE_CXX_STD ON)
123-
set(ABSL_BUILD_TEST_HELPERS ON)
123+
if(OR_TOOLS_BUILD_TESTING)
124+
set(ABSL_BUILD_TEST_HELPERS ON)
125+
else()
126+
set(ABSL_BUILD_TEST_HELPERS OFF)
127+
endif()
124128
set(ABSL_USE_EXTERNAL_GOOGLETEST ON)
125129
set(ABSL_FIND_GOOGLETEST OFF)
126130
# We want Abseil to keep the INSTALL rules enabled, even though it is a

ortools/math_opt/solvers/CMakeLists.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ if(USE_SCIP)
8989
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_status_tests>"
9090
)
9191
# This test fail on windows and takes too long so we disable it.
92-
set_tests_properties(cxx_math_opt_solvers_gscip_solver_test
93-
PROPERTIES DISABLED TRUE)
92+
if(TARGET cxx_math_opt_solvers_gscip_solver_test)
93+
set_tests_properties(cxx_math_opt_solvers_gscip_solver_test
94+
PROPERTIES DISABLED TRUE)
95+
endif()
9496
endif()
9597

9698
if(USE_GLOP)
@@ -148,8 +150,10 @@ ortools_cxx_test(
148150
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_status_tests>"
149151
)
150152
# This test takes too long so we disable it.
151-
set_tests_properties(cxx_math_opt_solvers_cp_sat_solver_test
152-
PROPERTIES DISABLED TRUE)
153+
if(TARGET cxx_math_opt_solvers_cp_sat_solver_test)
154+
set_tests_properties(cxx_math_opt_solvers_cp_sat_solver_test
155+
PROPERTIES DISABLED TRUE)
156+
endif()
153157

154158
ortools_cxx_test(
155159
NAME
@@ -248,8 +252,10 @@ if(USE_HIGHS)
248252
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_status_tests>"
249253
)
250254
# This test fail on windows and takes too long so we disable it.
251-
set_tests_properties(cxx_math_opt_solvers_highs_solver_test
252-
PROPERTIES DISABLED TRUE)
255+
if(TARGET cxx_math_opt_solvers_highs_solver_test)
256+
set_tests_properties(cxx_math_opt_solvers_highs_solver_test
257+
PROPERTIES DISABLED TRUE)
258+
endif()
253259
endif()
254260

255261
if(USE_XPRESS)

0 commit comments

Comments
 (0)