@@ -477,40 +477,25 @@ endif()
477
477
478
478
set (BAZEL_CONFIG)
479
479
480
- option (WITH_CLARABEL "Build with support for Clarabel" ON )
481
- if (NOT WITH_CLARABEL)
482
- string (APPEND BAZEL_CONFIG " --@drake//tools/flags:with_clarabel=False" )
483
- endif ()
484
-
485
- option (WITH_CLP "Build with support for CLP" ON )
486
- if (NOT WITH_CLP)
487
- string (APPEND BAZEL_CONFIG " --@drake//tools/flags:with_clp=False" )
488
- endif ()
489
-
490
- option (WITH_CSDP "Build with support for CSDP" ON )
491
- if (NOT WITH_CSDP)
492
- string (APPEND BAZEL_CONFIG " --@drake//tools/flags:with_csdp=False" )
493
- endif ()
494
-
495
- option (WITH_IPOPT "Build with support for Ipopt" ON )
496
- if (NOT WITH_IPOPT)
497
- string (APPEND BAZEL_CONFIG " --@drake//tools/flags:with_ipopt=False" )
498
- endif ()
499
-
500
- option (WITH_NLOPT "Build with support for NLopt" ON )
501
- if (NOT WITH_NLOPT)
502
- string (APPEND BAZEL_CONFIG " --@drake//tools/flags:with_nlopt=False" )
503
- endif ()
504
-
505
- option (WITH_OSQP "Build with support for OSQP" ON )
506
- if (NOT WITH_OSQP)
507
- string (APPEND BAZEL_CONFIG " --@drake//tools/flags:with_osqp=False" )
508
- endif ()
480
+ # Defines common options for open-source solver dependencies.
481
+ # By default, these are all ON.
482
+ # Passes the corresponding options to Bazel.
483
+ function (open_solver_option SOLVER)
484
+ string (TOUPPER "WITH_${SOLVER} " OPTION_NAME)
485
+ string (TOLOWER "with_${SOLVER} " OPTION_BAZEL_ARG)
486
+ option ("${OPTION_NAME} " "Build with support for ${SOLVER} " ON )
487
+ if (NOT ${OPTION_NAME} )
488
+ string (APPEND BAZEL_CONFIG " --@drake//tools/flags:${OPTION_BAZEL_ARG} =False" )
489
+ endif ()
490
+ endfunction ()
509
491
510
- option (WITH_SCS "Build with support for SCS" ON )
511
- if (NOT WITH_SCS)
512
- string (APPEND BAZEL_CONFIG " --@drake//tools/flags:with_scs=False" )
513
- endif ()
492
+ open_solver_option("Clarabel" )
493
+ open_solver_option("CLP" )
494
+ open_solver_option("CSDP" )
495
+ open_solver_option("Ipopt" )
496
+ open_solver_option("NLopt" )
497
+ open_solver_option("OSQP" )
498
+ open_solver_option("SCS" )
514
499
515
500
option (WITH_GUROBI "Build with support for Gurobi" OFF )
516
501
if (WITH_GUROBI)
0 commit comments