-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Revamp CmakeBuilder #8753
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
Revamp CmakeBuilder #8753
Conversation
3b7bba4 to
719dc4b
Compare
|
@segiddins any other questions I can answer or feedback I should address? |
|
Just following up - @segiddins anything else you would like to see changed? Would love to push this forward if possible. |
deivid-rodriguez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any existing gem using CMake extensions, or is current support so limited that nobody is using the feature?
Unfortunately I know nothing about CMake, but I did my best to try review this.
|
Thanks for the feedback!
That is a good question - I don't know of any. What I am trying to accomplish is release a new version of the ruby-opencv gem. The coding is complete but the building the extension requires CMake. That is because OpenCV only has a C++ api now (the C API was removed). Its a complex build that requires something like CMake (and in fact OpenCV does use CMake). Plus I would like to make it a lot easier to wrap C++ projects for use in Ruby - thus the work on Rice (https://github.com/ruby-rice/rice) and CMake itself. My workaround for now is the Rice gem can install a RubyGem hook which I use to install the patch above. |
I have some basic CMake knowledge, happy to help if needed. |
|
Thanks again @deivid-rodriguez for the feedback. I think I have addressed all the issues you brought up. I also added a new test checking for presets. I have updated the patch based on the changes. @simi Feedback or testing always welcome. Also do you know of any gems that use CMake to build extensions? |
|
@deivid-rodriguez anything else you would like me to address? |
|
Hi @deivid-rodriguez just following up on this PR. Thanks again for the review! |
|
Sorry, I haven't yet get to this, but I should be giving it a final look and reviewing it soon 👍. |
|
No worries - thanks for the update! |
deivid-rodriguez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to merge and let you and others try it and report/fix issues. Just one small final comment about the lib_dir parameter.
@simi Would you like to have a look, too?
|
Thanks for updating! Can you rebase and resolve the merge conflict? |
|
Also is it intentional that commit author is https://github.com/cfisoi rather the user you are commenting from and owner of your fork? |
|
Fixed the merge conflict. And good catch on the commit author - that was from my work github account. Fixed to use my personal one. |
…ically: * Correctly pass command line arguments to CMake * Call CMake twice - once to configure a project and a second time to build (which is the standard way to use CMake). This fixes the previously incorrect assumption that CMake generates a Make file. * Update the tests to specify a CMake minimum version of 3.26 (which is already two years old). 3.26 is a bit arbritary but it aligns with Rice, and updates from the ancient 3.5 version being used (which CMake generates a warning message saying stop using it!) * Update the CMake call to use CMAKE_RUNTIME_OUTPUT_DIRECTORY and CMAKE_LIBRARY_OUTPUT_DIRECTORY to tell CMake to copy compiled binaries to the a Gem's lib directory. Note the updated builder took inspiration from the Cargo Builder, meaning you first create an instance of CmakeBuilder versus just calling class methods.
deivid-rodriguez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defering to @simi now, looks good from my side!
|
Any chance this can get merged? Thanks! |
|
I was worried that was the case :( Well thank you for all your help! |
|
@cfis 👋 This PR looks good to me. I'm wondering does this change work with your CMake project? |
|
@hsbt - Yes, I need it compile my new version of opencv bindings for Ruby. See https://github.com/cfis/opencv-ruby/tree/main/ext. In the short term, the opencv-ruby bindings will require the Rice gem. The Rice gem implements this same change via a RubyGem plugin. See https://github.com/ruby-rice/rice/blob/master/lib/rubygems_plugin.rb. But I would much rather have this in Ruby gems. Note I have also spent a fair bit of time updating Ruby support in CMake. See https://gitlab.kitware.com/users/cfis/activity Thanks for looking at this. |
|
Thanks! |
I had trouble mostly with this part, since it will break later bundler integration and parallelism contract. Relying on cmake output seems brittle to me and the detection of |
|
Hi Simi thank you for the feedback. I am more than happy to make this better. I have some questions:
I do think this MR is a big step up from what is currently in RubyGems which is broken (not passing command line variables is a show stopper). |
Fix the issues described in #8752. Specifically:
Note the updated builder took inspiration from the Cargo Builder, meaning you first create an instance of CmakeBuilder versus just calling class methods.
Closes #8752.
Make sure the following tasks are checked