Skip to content

Commit ecf2fd4

Browse files
committed
1 parent d56f93a commit ecf2fd4

5 files changed

Lines changed: 169 additions & 87 deletions

File tree

‎4.x/packaging/cmake/index.html‎

Lines changed: 85 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,6 +3018,17 @@
30183018
</span>
30193019
</a>
30203020

3021+
</li>
3022+
3023+
<li class="md-nav__item">
3024+
<a href="#findruby-imported-targets" class="md-nav__link">
3025+
<span class="md-ellipsis">
3026+
3027+
FindRuby Imported Targets
3028+
3029+
</span>
3030+
</a>
3031+
30213032
</li>
30223033

30233034
<li class="md-nav__item">
@@ -3034,6 +3045,28 @@
30343045
</ul>
30353046
</nav>
30363047

3048+
</li>
3049+
3050+
<li class="md-nav__item">
3051+
<a href="#rice-cmake-target" class="md-nav__link">
3052+
<span class="md-ellipsis">
3053+
3054+
Rice CMake Target
3055+
3056+
</span>
3057+
</a>
3058+
3059+
</li>
3060+
3061+
<li class="md-nav__item">
3062+
<a href="#complete-example" class="md-nav__link">
3063+
<span class="md-ellipsis">
3064+
3065+
Complete Example
3066+
3067+
</span>
3068+
</a>
3069+
30373070
</li>
30383071

30393072
</ul>
@@ -3362,7 +3395,7 @@ <h1 id="cmake">CMake<a class="headerlink" href="#cmake" title="Permanent link">&
33623395
<li>Parallelizes builds resulting in <em>much</em> faster compilation times compared to <code>make</code></li>
33633396
</ul>
33643397
<h2 id="cmakepresetsjson">CMakePresets.json<a class="headerlink" href="#cmakepresetsjson" title="Permanent link">&para;</a></h2>
3365-
<p>Rice includes a <code>CMakePresets.json</code> file (in the <code>test</code> directory) that provides pre-configured build settings for various platforms and compilers. Using presets is highly recommended as they encode the correct compiler flags for each platform.</p>
3398+
<p>Rice includes a <code>CMakePresets.json</code> file that provides pre-configured build settings for various platforms and compilers. Using presets is highly recommended as they encode the correct compiler flags for each platform.</p>
33663399
<p>The available presets include:</p>
33673400
<ul>
33683401
<li><code>linux-debug</code> / <code>linux-release</code> - Linux with GCC</li>
@@ -3416,7 +3449,7 @@ <h2 id="example">Example<a class="headerlink" href="#example" title="Permanent l
34163449
<a id="__codelineno-3-21" name="__codelineno-3-21" href="#__codelineno-3-21"></a><span class="w"> </span><span class="s2">&quot;MyExtension.cpp&quot;</span><span class="p">)</span>
34173450
<a id="__codelineno-3-22" name="__codelineno-3-22" href="#__codelineno-3-22"></a>
34183451
<a id="__codelineno-3-23" name="__codelineno-3-23" href="#__codelineno-3-23"></a><span class="c"># Link to Ruby using the modern imported target</span>
3419-
<a id="__codelineno-3-24" name="__codelineno-3-24" href="#__codelineno-3-24"></a><span class="nb">target_link_libraries</span><span class="p">(</span><span class="s">MyExtension</span><span class="w"> </span><span class="s">PRIVATE</span><span class="w"> </span><span class="s">Ruby::Ruby</span><span class="p">)</span>
3452+
<a id="__codelineno-3-24" name="__codelineno-3-24" href="#__codelineno-3-24"></a><span class="nb">target_link_libraries</span><span class="p">(</span><span class="s">MyExtension</span><span class="w"> </span><span class="s">PRIVATE</span><span class="w"> </span><span class="s">Ruby::Module</span><span class="p">)</span>
34203453
<a id="__codelineno-3-25" name="__codelineno-3-25" href="#__codelineno-3-25"></a>
34213454
<a id="__codelineno-3-26" name="__codelineno-3-26" href="#__codelineno-3-26"></a><span class="c"># Add in Rice headers</span>
34223455
<a id="__codelineno-3-27" name="__codelineno-3-27" href="#__codelineno-3-27"></a><span class="nb">target_include_directories</span><span class="p">(</span><span class="s">MyExtension</span><span class="w"> </span><span class="s">PRIVATE</span><span class="w"> </span><span class="s">&lt;path-to-rice-headers&gt;</span><span class="p">)</span>
@@ -3426,7 +3459,7 @@ <h2 id="example">Example<a class="headerlink" href="#example" title="Permanent l
34263459
<a id="__codelineno-3-31" name="__codelineno-3-31" href="#__codelineno-3-31"></a><span class="nb">target_link_libraries</span><span class="p">(</span><span class="s">MyExtension</span><span class="w"> </span><span class="s">PRIVATE</span><span class="w"> </span><span class="s">&lt;library-name&gt;</span><span class="p">)</span>
34273460
</code></pre></div>
34283461
<p>Currently you will need to manually specify where the Rice <a href="../packaging/#header-files">header files</a> are located.</p>
3429-
<p>Note that using the <code>Ruby::Ruby</code> imported target (available in CMake 3.18+) is preferred over manually specifying include directories and libraries, as it automatically sets up all necessary include paths and link libraries.</p>
3462+
<p>Note that using the <code>Ruby::Module</code> imported target is preferred over manually specifying include directories and libraries, as it automatically sets up all necessary include paths and compiler settings for building Ruby extensions.</p>
34303463
<h2 id="compiler-settings">Compiler Settings<a class="headerlink" href="#compiler-settings" title="Permanent link">&para;</a></h2>
34313464
<p>See <a href="../packaging/#compiler-settings">compiler settings</a> for details about compiler settings.</p>
34323465
<h2 id="findruby">FindRuby<a class="headerlink" href="#findruby" title="Permanent link">&para;</a></h2>
@@ -3455,6 +3488,36 @@ <h3 id="macos-with-homebrew">macOS with Homebrew<a class="headerlink" href="#mac
34553488
<a id="__codelineno-6-2" name="__codelineno-6-2" href="#__codelineno-6-2"></a><span class="nb">find_package</span><span class="p">(</span><span class="s">Ruby</span><span class="w"> </span><span class="s">REQUIRED</span><span class="p">)</span>
34563489
</code></pre></div>
34573490
<p>Rice's <code>FindRuby.cmake</code> is also useful for older versions of CMake that lack good Ruby support.</p>
3491+
<h3 id="findruby-imported-targets">FindRuby Imported Targets<a class="headerlink" href="#findruby-imported-targets" title="Permanent link">&para;</a></h3>
3492+
<p>Rice's <code>FindRuby.cmake</code> provides modern CMake imported targets:</p>
3493+
<table>
3494+
<thead>
3495+
<tr>
3496+
<th>Target</th>
3497+
<th>Description</th>
3498+
</tr>
3499+
</thead>
3500+
<tbody>
3501+
<tr>
3502+
<td><code>Ruby::Interpreter</code></td>
3503+
<td>Ruby interpreter executable</td>
3504+
</tr>
3505+
<tr>
3506+
<td><code>Ruby::Module</code></td>
3507+
<td>For building Ruby extension modules. Use this for gems with native extensions. On Unix, does not link to libruby (symbols resolved at load time). Includes hidden visibility settings.</td>
3508+
</tr>
3509+
<tr>
3510+
<td><code>Ruby::Ruby</code></td>
3511+
<td>For embedding Ruby in C/C++ applications. Links to libruby.</td>
3512+
</tr>
3513+
</tbody>
3514+
</table>
3515+
<p>Embedding Ruby (including Rice's C++ test runner) requires a shared Ruby library to be available.
3516+
Extension-only modules should link <code>Ruby::Module</code> and can build on macOS/Linux without a shared
3517+
libruby.</p>
3518+
<p>For building Ruby extensions, use <code>Ruby::Module</code>:</p>
3519+
<div class="highlight"><pre><span></span><code><a id="__codelineno-7-1" name="__codelineno-7-1" href="#__codelineno-7-1"></a><span class="nb">target_link_libraries</span><span class="p">(</span><span class="s">MyExtension</span><span class="w"> </span><span class="s">PRIVATE</span><span class="w"> </span><span class="s">Ruby::Module</span><span class="p">)</span>
3520+
</code></pre></div>
34583521
<h3 id="findruby-variables">FindRuby Variables<a class="headerlink" href="#findruby-variables" title="Permanent link">&para;</a></h3>
34593522
<p>The following CMake variables are set by FindRuby:</p>
34603523
<table>
@@ -3523,6 +3586,25 @@ <h3 id="findruby-variables">FindRuby Variables<a class="headerlink" href="#findr
35233586
</tr>
35243587
</tbody>
35253588
</table>
3589+
<h2 id="rice-cmake-target">Rice CMake Target<a class="headerlink" href="#rice-cmake-target" title="Permanent link">&para;</a></h2>
3590+
<p>Rice provides the <code>Rice::Rice</code> imported target for including Rice headers:</p>
3591+
<div class="highlight"><pre><span></span><code><a id="__codelineno-8-1" name="__codelineno-8-1" href="#__codelineno-8-1"></a><span class="nb">target_link_libraries</span><span class="p">(</span><span class="s">MyExtension</span><span class="w"> </span><span class="s">PRIVATE</span><span class="w"> </span><span class="s">Rice::Rice</span><span class="p">)</span>
3592+
</code></pre></div>
3593+
<p>This target:</p>
3594+
<ul>
3595+
<li>Adds Rice include directories</li>
3596+
<li>Requires C++17 or higher</li>
3597+
</ul>
3598+
<h2 id="complete-example">Complete Example<a class="headerlink" href="#complete-example" title="Permanent link">&para;</a></h2>
3599+
<p>For a complete, real-world example of using CMake with Rice, see <a href="https://github.com/ruby-rice/BitmapPlusPlus-ruby/blob/main/ext/CMakeLists.txt">BitmapPlusPlus-ruby</a>.</p>
3600+
<p>This example demonstrates:</p>
3601+
<ul>
3602+
<li>Fetching Rice via <code>FetchContent</code></li>
3603+
<li>Using <code>Ruby::Module</code> for extension modules</li>
3604+
<li>Using <code>Rice::Rice</code> for Rice headers</li>
3605+
<li>Setting the correct extension suffix</li>
3606+
<li>Configuring output directories</li>
3607+
</ul>
35263608

35273609

35283610

‎4.x/packaging/packaging/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3383,7 +3383,7 @@ <h2 id="header-files">Header Files<a class="headerlink" href="#header-files" tit
33833383
</code></pre></div>
33843384
<p>The second option is to simply copy them from <a href="https://github.com/ruby-rice/rice/tree/master/include/rice">github</a> and copy them into your repo. Remember the provided link points to the master branch - you should pick a specific release tag and use those instead.</p>
33853385
<h2 id="compiler-settings">Compiler Settings<a class="headerlink" href="#compiler-settings" title="Permanent link">&para;</a></h2>
3386-
<p>Rice extensions requires several compiler settings to be set. These are captured in the <a href="https://github.com/ruby-rice/rice/blob/master/test/CMakePresets.json">CMakePresets.json</a> file for all supported platforms.</p>
3386+
<p>Rice extensions requires several compiler settings to be set. These are captured in the <a href="https://github.com/ruby-rice/rice/blob/master/CMakePresets.json">CMakePresets.json</a> file for all supported platforms.</p>
33873387
<p>For Clang and GCC:</p>
33883388
<div class="highlight"><pre><span></span><code><a id="__codelineno-2-1" name="__codelineno-2-1" href="#__codelineno-2-1"></a>-std<span class="o">=</span>c++17<span class="w"> </span>-Wa,-mbig-obj<span class="w"> </span>-ftemplate-backtrace-limit<span class="o">=</span><span class="m">0</span>
33893389
</code></pre></div>

‎4.x/search/search_index.json‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)