Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake options for solver opt-out #22547

Open
jwnimmer-tri opened this issue Jan 28, 2025 · 2 comments
Open

CMake options for solver opt-out #22547

jwnimmer-tri opened this issue Jan 28, 2025 · 2 comments
Assignees
Labels
component: build system Bazel, CMake, dependencies, memory checkers, linters priority: medium type: feature request

Comments

@jwnimmer-tri
Copy link
Collaborator

jwnimmer-tri commented Jan 28, 2025

Is your feature request related to a problem? Please describe.

#22393 added flags for downstream Bazel users to opt-out of our open-source solvers (e.g., Clarabel). However, the need to opt-out applies equally well to downstream CMake users who are building and installing Drake from source.

Describe the solution you'd like

Offer CMake options to opt-out of the same solvers as the Bazel flags. (This should be as simple as tweaking CMake's generated bazelrc file to set the bazel flag when needed.

The options for open-source solvers should have the same truth sense as our options for commercial solvers, just with the opposite default, i.e.,

option(WITH_CLARBEL "Build with support for Clarabel" ON)

Update the documentation at https://drake.mit.edu/from_source.html to explain the new options.

Update drake-external-examples/ drake_cmake_installed (edit: drake_cmake_external) to set one of the new options, as a way of documenting it & testing that they work.

Describe alternatives you've considered

Users could make a magical user.bazelrc file to set the Bazel flag during a CMake build, but that's very awkward.

Additional context

N/A

@nicolecheetham
Copy link
Contributor

@jwnimmer-tri This issue mentions a simple tweak is needed in cmake's generated bazelrc file. I wanted to confirm if the desired change is build:{solver_name} --@drake//tools/flags:with_{solver_name}=True for each open source solver after line 41 in drake/cmake/bazel.rc.in.

I also wanted to check for testing the options with drake_cmake_external, I would create the specific option(s) then pass them into ExternalProject_Add(drake_external_examples) via CMAKE_ARGS. Then, I would build locally to check if it build properly.

On another note, is there any additional bazel documentaion or resources to better understand the workings of bazel.rc files? I just found https://bazel.build/run/bazelrc while looking over 22393.

@jwnimmer-tri
Copy link
Collaborator Author

Best guess, the drake/CMakeLists.txt snippet would be along these lines, with no changes to bazel.rc.in:

option(WITH_CLARABEL "Build with support for Clarabel" ON)

if(NOT WITH_CLARABEL)
  string(APPEND BAZEL_CONFIG " --@drake//tools/flags:with_clarabel=False")
endif()

I also wanted to check for testing the options with drake_cmake_external, ....

I don't know. Kitware are the CMake exports, hopefully you can find the answer in-house.

... documentaion or resources to better understand the workings of bazel.rc files?

The link you have is the best one about the files themselves. I think it's pretty thorough.

In terms of what flags to what, that's a question of whatever the bazel command line offers (rcfiles just tack things onto the command line) so https://bazel.build/reference/command-line-reference and and https://bazel.build/reference/be/general#config_setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: build system Bazel, CMake, dependencies, memory checkers, linters priority: medium type: feature request
Development

No branches or pull requests

3 participants