diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f34130af3..04366241a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,6 +196,7 @@ CMAKE_DEPENDENT_OPTION(BUILD_re2 "Build the re2 dependency Library" OFF message(STATUS "Build re2: ${BUILD_re2}") if(BUILD_TESTING) + set(OR_TOOLS_BUILD_TESTING ON) CMAKE_DEPENDENT_OPTION(BUILD_googletest "Build googletest" OFF "NOT BUILD_DEPS" ON) CMAKE_DEPENDENT_OPTION(BUILD_benchmark "Build benchmark" OFF @@ -215,6 +216,7 @@ if(BUILD_TESTING) "NOT BUILD_DEPS" ON) endif() else() + set(OR_TOOLS_BUILD_TESTING OFF) set(BUILD_googletest OFF) set(BUILD_protobuf_matchers OFF) set(BUILD_benchmark OFF) diff --git a/cmake/dependencies/CMakeLists.txt b/cmake/dependencies/CMakeLists.txt index 78404ec197..a045bdf805 100644 --- a/cmake/dependencies/CMakeLists.txt +++ b/cmake/dependencies/CMakeLists.txt @@ -120,7 +120,11 @@ if(BUILD_absl) set(ABSL_USE_SYSTEM_INCLUDES ON) # We want Abseil to declare what C++ standard it was compiled with. set(ABSL_PROPAGATE_CXX_STD ON) - set(ABSL_BUILD_TEST_HELPERS ON) + if(OR_TOOLS_BUILD_TESTING) + set(ABSL_BUILD_TEST_HELPERS ON) + else() + set(ABSL_BUILD_TEST_HELPERS OFF) + endif() set(ABSL_USE_EXTERNAL_GOOGLETEST ON) set(ABSL_FIND_GOOGLETEST OFF) # We want Abseil to keep the INSTALL rules enabled, even though it is a diff --git a/ortools/math_opt/solvers/CMakeLists.txt b/ortools/math_opt/solvers/CMakeLists.txt index 7bb72c8bbd..2cf42805d9 100644 --- a/ortools/math_opt/solvers/CMakeLists.txt +++ b/ortools/math_opt/solvers/CMakeLists.txt @@ -89,8 +89,10 @@ if(USE_SCIP) "$" ) # This test fail on windows and takes too long so we disable it. - set_tests_properties(cxx_math_opt_solvers_gscip_solver_test - PROPERTIES DISABLED TRUE) + if(TARGET cxx_math_opt_solvers_gscip_solver_test) + set_tests_properties(cxx_math_opt_solvers_gscip_solver_test + PROPERTIES DISABLED TRUE) + endif() endif() if(USE_GLOP) @@ -148,8 +150,10 @@ ortools_cxx_test( "$" ) # This test takes too long so we disable it. -set_tests_properties(cxx_math_opt_solvers_cp_sat_solver_test - PROPERTIES DISABLED TRUE) +if(TARGET cxx_math_opt_solvers_cp_sat_solver_test) + set_tests_properties(cxx_math_opt_solvers_cp_sat_solver_test + PROPERTIES DISABLED TRUE) +endif() ortools_cxx_test( NAME @@ -248,8 +252,10 @@ if(USE_HIGHS) "$" ) # This test fail on windows and takes too long so we disable it. - set_tests_properties(cxx_math_opt_solvers_highs_solver_test - PROPERTIES DISABLED TRUE) + if(TARGET cxx_math_opt_solvers_highs_solver_test) + set_tests_properties(cxx_math_opt_solvers_highs_solver_test + PROPERTIES DISABLED TRUE) + endif() endif() if(USE_XPRESS)