Skip to content

Improve CMake Support #8752

@cfis

Description

@cfis

I have been spending a lot of time over the last couple of years improving Ruby's C++ story. That includes updating Rice, (https://github.com/ruby-rice/rice) , which makes it much easier to create Ruby extensions for C++ libraries, and CMake (see https://gitlab.kitware.com/cmake/cmake/-/merge_requests/?sort=created_date&state=merged&author_username=cfis&first_page_size=20).

The C++ ecosystem has strongly adopted CMake. Unfortunately, RubyGem's CmakeBuilder is really not functional.

The first problem is that any arguments passed to gem are not forwarded to CMake. For example:

gem install <some_gem> -- --preset=linux-release

The argument --preset=linux-release is NOT passed to CMake. This is in contrast to other builders, like extconf.rb, which do receive command line arguments. Not being able to pass command line arguments is a severe limitation.

The second problem is that CMake really works in two steps:

  • Configure
  • Build

However, the current implementation of CmakeBuilder only runs the configure step. It assumes the configure step generates a Makefile which will then be built by Make. However, this is an invalid assumption!

CMake can be configured to use different backends, where Make is just one possibility. If CMake on the target machine is configured to use a generator besides Make then the extension will never be built because the build step is never invoked.

These days the defacto backend has become Ninja. One reason Ninja is much more popular is because it enables parallel builds which greatly speeds up compilation - particularly versus Make which builds in serial. For C++, which is a slow language to compile, this is a severe penalty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions