kou commented on code in PR #47566:
URL: https://github.com/apache/arrow/pull/47566#discussion_r2350463572


##########
docs/source/cpp/build_system.rst:
##########
@@ -144,6 +145,85 @@ For example, to use the ``ArrowCompute`` package:
 .. seealso::
    A Docker-based :doc:`minimal build example <examples/cmake_minimal_build>`.
 
+Meson
+=====
+
+Basic usage
+-----------
+
+This minimal ``meson.build`` file compiles a ``my_example.cc`` source file
+into an executable linked with the Arrow C++ shared library:
+
+.. code-block:: meson
+
+    project('my-example-project', 'cpp')
+
+    arrow_dep = dependency('arrow')
+
+    executable(
+        'my_example',
+        sources: ['my_example.cc'],
+        dependencies: [arrow_dep],
+    )
+
+To setup and compile, run the following commands from your project root:
+
+.. code-block:: shell
+
+   meson setup builddir
+   meson compile -C builddir
+
+Using Meson's wrap system
+-------------------------
+
+By default, a call to ``dependency('arrow')`` will search for Arrow
+on your system, using a variety of heuristics built into Meson (typically
+using pkg-config, but potentially also using CMake and other logic). If you
+are working on a system where Arrow is not available, you can use Meson's
+wrap system to automatically fetch a copy and build Arrow as a subproject.
+
+To do so, run the following from the root of your project:
+
+.. code-block:: shell
+
+   mkdir -p subprojects
+   meson wrap install arrow-cpp
+   meson wrap install gflags # can skip if you have a system install of gflags
+
+No changes to your ``meson.build`` configuration are required.
+
+Linking Against Optional Dependencies
+-------------------------------------
+
+By default, the Arrow project builds and distributes a single core library.
+However, Arrow can build and distribute many optional libraries, which can
+still be linked via Meson.
+
+As an example, let's look at the compute library, which is distributed via
+pkg-config as ``arrow-compute``. Meson will first search for this library
+on the system, and when it is not found it will fall back to building a
+local copy of Arrow. However, the local copy must be instructed to enable
+to compile the optional compute library.
+
+To do this, we are going to modify the aforementioned configuration to
+add a ``default_options`` argument to the ``dependency`` call, which instructs
+Meson to build the compute library while compiling a local copy of Arrow:
+
+.. code-block:: meson
+
+    project('my-example-project', 'cpp')
+
+    arrow_compute_dep = dependency(
+        'arrow-compute',
+        default_options: ['compute=enabled'],
+    )
+
+    executable(
+        'my_example',
+        sources: ['my_example.cc'],
+        dependencies: [arrow_compute_dep],
+    )

Review Comment:
   ```suggestion
      project('my-example-project', 'cpp')
   
      arrow_compute_dep = dependency(
          'arrow-compute',
          default_options: ['compute=enabled'],
      )
   
      executable(
          'my_example',
          sources: ['my_example.cc'],
          dependencies: [arrow_compute_dep],
      )
   ```



##########
docs/source/cpp/build_system.rst:
##########
@@ -144,6 +145,85 @@ For example, to use the ``ArrowCompute`` package:
 .. seealso::
    A Docker-based :doc:`minimal build example <examples/cmake_minimal_build>`.
 
+Meson
+=====
+
+Basic usage
+-----------
+
+This minimal ``meson.build`` file compiles a ``my_example.cc`` source file
+into an executable linked with the Arrow C++ shared library:
+
+.. code-block:: meson
+
+    project('my-example-project', 'cpp')
+
+    arrow_dep = dependency('arrow')
+
+    executable(
+        'my_example',
+        sources: ['my_example.cc'],
+        dependencies: [arrow_dep],
+    )

Review Comment:
   ```suggestion
      project('my-example-project', 'cpp')
   
      arrow_dep = dependency('arrow')
   
      executable(
          'my_example',
          sources: ['my_example.cc'],
          dependencies: [arrow_dep],
      )
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to