diff --git a/CMakeLists.txt b/CMakeLists.txt index e81a07ea4bc8..d90551233185 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -477,8 +477,28 @@ endif() set(BAZEL_CONFIG) -option(WITH_GUROBI "Build with support for Gurobi" OFF) +# Defines common options for open-source solver dependencies. +# By default, these are all ON. +# Passes the corresponding options to Bazel. +function(open_solver_option SOLVER) + string(TOUPPER "WITH_${SOLVER}" OPTION_NAME) + string(TOLOWER "with_${SOLVER}" OPTION_BAZEL_ARG) + option("${OPTION_NAME}" "Build with support for ${SOLVER}" ON) + if(NOT ${OPTION_NAME}) + string(APPEND BAZEL_CONFIG " --@drake//tools/flags:${OPTION_BAZEL_ARG}=False") + endif() + set(BAZEL_CONFIG ${BAZEL_CONFIG} PARENT_SCOPE) +endfunction() + +open_solver_option("Clarabel") +open_solver_option("CLP") +open_solver_option("CSDP") +open_solver_option("Ipopt") +open_solver_option("NLopt") +open_solver_option("OSQP") +open_solver_option("SCS") +option(WITH_GUROBI "Build with support for Gurobi" OFF) if(WITH_GUROBI) find_package(Gurobi 10.0 EXACT MODULE REQUIRED) @@ -491,13 +511,11 @@ if(WITH_GUROBI) endif() option(WITH_MOSEK "Build with support for MOSEK" OFF) - if(WITH_MOSEK) string(APPEND BAZEL_CONFIG " --config=mosek") endif() option(WITH_OPENMP "Build with support for OpenMP" OFF) - if(WITH_OPENMP) string(APPEND BAZEL_CONFIG " --config=omp") endif() diff --git a/bindings/pydrake/solvers/BUILD.bazel b/bindings/pydrake/solvers/BUILD.bazel index 02d3e23914ca..0ba0e0f35d7f 100644 --- a/bindings/pydrake/solvers/BUILD.bazel +++ b/bindings/pydrake/solvers/BUILD.bazel @@ -129,7 +129,7 @@ drake_py_unittest( name = "csdp_solver_test", args = select({ "//tools/workspace/csdp_internal:enabled": [], - "//conditions:default": ["TestCsdptSolver.unavailable"], + "//conditions:default": ["TestCsdpSolver.unavailable"], }), deps = [ ":solvers", diff --git a/doc/_pages/from_source.md b/doc/_pages/from_source.md index 00692b0e04b7..315daee8ab30 100644 --- a/doc/_pages/from_source.md +++ b/doc/_pages/from_source.md @@ -99,6 +99,14 @@ Adjusting open-source dependencies: * WITH_USER_ZLIB (default ON). When ON, uses `find_package(ZLIB)` to locate a user-provided `ZLIB::ZLIB` library instead of building from source. Caveat: On macOS, for now this hardcodes `-lz` instead of calling `find_package`. +* WITH_CLARABEL (default ON). When ON, enables the `ClarabelSolver` + in the build. +* WITH_CLP (default ON). When ON, enables the `ClpSolver` in the build. +* WITH_CSDP (default ON). When ON, enables the `CsdpSolver` in the build. +* WITH_IPOPT (default ON). When ON, enables the `IpoptSolver` in the build. +* WITH_NLOPT (default ON). When ON, enables the `NloptSolver` in the build. +* WITH_OSQP (default ON). When ON, enables the `OsqpSolver` in the build. +* WITH_SCS (default ON). When ON, enables the `ScsSolver` in the build. Adjusting closed-source (commercial) software dependencies: