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

[build] CMake options for solver opt-out #22626

Merged
merged 6 commits into from
Feb 24, 2025

Conversation

tyler-yankee
Copy link
Contributor

@tyler-yankee tyler-yankee commented Feb 13, 2025

Addresses #22547 by:

  • adding options to the top-level CMakeLists.txt for each of the open-source solvers, with default ON, which adjust the corresponding existing bazel flags
  • adding documentation on https://drake.mit.edu/from_source.html

Also, fixes a typo in a solver test case.


This change is Reviewable

Copy link
Contributor Author

@tyler-yankee tyler-yankee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #370 on drake-ci for the test for this feature.

Reviewable status: needs platform reviewer assigned, needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @tyler-yankee)

Copy link
Contributor Author

@tyler-yankee tyler-yankee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwnimmer-tri for feature review, please!

Reviewable status: needs platform reviewer assigned, needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @tyler-yankee)

@tyler-yankee
Copy link
Contributor Author

Sorry, that's +@jwnimmer-tri.

Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please assign someone from Kitware to feature-review this.

(For build fixes and especially CMake changes, generally that's the procedure we want to follow, to keep things moving and conserve my time commitment. I'm always happy to take a first high level look to make sure it's aimed in the right direction, but iterating on the code to make it clear, correct, and sufficiently tested is something y'all can move forward without me.)

Reviewed 2 of 3 files at r1, all commit messages.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @tyler-yankee)


CMakeLists.txt line 480 at r1 (raw file):

set(BAZEL_CONFIG)

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

BTW Is there a way to do this with less copy-paste?

For some of the other more nuanced flag handling in other cases, writing them out longhand is probably a benefit for clarity. But here, there is no complexity so probably using a helper function would be an improvement for readability and maintainability?

I'm imagining a helper that takes as an argument the single preferred name like "Clarabel" and from that automatically computes the CMake scream case "WITH_CLARABEL" and the rcfile snake case "with_clarabel".

@tyler-yankee
Copy link
Contributor Author

CMakeLists.txt line 480 at r1 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

BTW Is there a way to do this with less copy-paste?

For some of the other more nuanced flag handling in other cases, writing them out longhand is probably a benefit for clarity. But here, there is no complexity so probably using a helper function would be an improvement for readability and maintainability?

I'm imagining a helper that takes as an argument the single preferred name like "Clarabel" and from that automatically computes the CMake scream case "WITH_CLARABEL" and the rcfile snake case "with_clarabel".

My instinct was to use a helper function, but I decided against it for consistency with how the code was written for the closed-source solver options. I agree that there's less complexity here so I'll go ahead and re-write it for clarity.

Copy link
Contributor Author

@tyler-yankee tyler-yankee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, thanks @jwnimmer-tri!

+@BetsyMcPhail, would you like feature review this?

Reviewable status: 1 unresolved discussion, LGTM missing from assignees jwnimmer-tri(platform),BetsyMcPhail, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @tyler-yankee)

Copy link
Contributor

@BetsyMcPhail BetsyMcPhail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 3 files at r1, 1 of 1 files at r4, all commit messages.
Reviewable status: 2 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @tyler-yankee)


CMakeLists.txt line 485 at r4 (raw file):

function(open_solver_option SOLVER)
  string(TOUPPER "WITH_${SOLVER}" OPTION_NAME)
  string(TOLOWER "with_${SOLVER}" OPTION_BAZEL_ARG)

Nit This could be moved inside of the if where it is used.

Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: platform, assuming the DEE CI test is passing.

Reviewed 1 of 1 files at r2, 1 of 1 files at r3, 1 of 1 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: 2 unresolved discussions, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @tyler-yankee)


CMakeLists.txt line 487 at r4 (raw file):

  string(TOLOWER "with_${SOLVER}" OPTION_BAZEL_ARG)
  option("${OPTION_NAME}" "Build with support for ${SOLVER}" ON)
  if(NOT ${OPTION_NAME})

nit I would actually recommend setting to True or False always, not just setting False when OFF. Having only one-sided setting here means that if the Bazel default changes, then this code will be wrong.

(Of course having Bazel and CMake end up with different defaults would not be ideal, but it at least the build would be correct per each one's individual documentation.)

That also provides more effective CI coverage of the TOLOWER spelling check, since now the spelling is being run even in normal Drake CI in the main flow.

It does bloat the bazel rcfile somewhat, but I think that's a fair tradeoff. The extra verbosity might even be a win for debugability for users.

@tyler-yankee
Copy link
Contributor Author

CMakeLists.txt line 487 at r4 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

nit I would actually recommend setting to True or False always, not just setting False when OFF. Having only one-sided setting here means that if the Bazel default changes, then this code will be wrong.

(Of course having Bazel and CMake end up with different defaults would not be ideal, but it at least the build would be correct per each one's individual documentation.)

That also provides more effective CI coverage of the TOLOWER spelling check, since now the spelling is being run even in normal Drake CI in the main flow.

It does bloat the bazel rcfile somewhat, but I think that's a fair tradeoff. The extra verbosity might even be a win for debugability for users.

Fair enough. These changes should be all set pending CI checks on the DEE side.

Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r6, all commit messages.
Reviewable status: commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @tyler-yankee)

@jwnimmer-tri jwnimmer-tri added the release notes: feature This pull request contains a new feature label Feb 24, 2025
@jwnimmer-tri jwnimmer-tri merged commit 0d15b8c into RobotLocomotion:master Feb 24, 2025
9 of 10 checks passed
@jwnimmer-tri jwnimmer-tri added the status: squashing now https://drake.mit.edu/reviewable.html#curated-commits label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: feature This pull request contains a new feature status: squashing now https://drake.mit.edu/reviewable.html#curated-commits
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants