Skip to content

Commit 03bd118

Browse files
authored
[doc] prefer 'cmake -B' and 'cmake --build' everywhere (dmlc#10717)
1 parent 24d225c commit 03bd118

File tree

5 files changed

+37
-66
lines changed

5 files changed

+37
-66
lines changed

demo/rmm_plugin/README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ run CMake with option ``-DPLUGIN_RMM=ON`` (``-DUSE_CUDA=ON`` also required):
1818

1919
.. code-block:: sh
2020
21-
cmake .. -DUSE_CUDA=ON -DUSE_NCCL=ON -DPLUGIN_RMM=ON
22-
make -j$(nproc)
21+
cmake -B build -S . -DUSE_CUDA=ON -DUSE_NCCL=ON -DPLUGIN_RMM=ON
22+
cmake --build build -j$(nproc)
2323
2424
CMake will attempt to locate the RMM library in your build environment. You may choose to build
2525
RMM from the source, or install it using the Conda package manager. If CMake cannot find RMM, you
@@ -28,9 +28,9 @@ should specify the location of RMM with the CMake prefix:
2828
.. code-block:: sh
2929
3030
# If using Conda:
31-
cmake .. -DUSE_CUDA=ON -DUSE_NCCL=ON -DPLUGIN_RMM=ON -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
31+
cmake -B build -S . -DUSE_CUDA=ON -DUSE_NCCL=ON -DPLUGIN_RMM=ON -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
3232
# If using RMM installed with a custom location
33-
cmake .. -DUSE_CUDA=ON -DUSE_NCCL=ON -DPLUGIN_RMM=ON -DCMAKE_PREFIX_PATH=/path/to/rmm
33+
cmake -B build -S . -DUSE_CUDA=ON -DUSE_NCCL=ON -DPLUGIN_RMM=ON -DCMAKE_PREFIX_PATH=/path/to/rmm
3434
3535
********************************
3636
Informing XGBoost about RMM pool

doc/build.rst

Lines changed: 23 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ After obtaining the source code, one builds XGBoost by running CMake:
6868
.. code-block:: bash
6969
7070
cd xgboost
71-
mkdir build
72-
cd build
73-
cmake ..
74-
make -j$(nproc)
71+
cmake -B build -S .
72+
cmake --build build -j$(nproc)
7573
7674
Building on MacOS
7775
=================
@@ -94,12 +92,10 @@ following from the root of the XGBoost directory:
9492

9593
.. code-block:: bash
9694
97-
mkdir build
98-
cd build
99-
cmake .. -G"Visual Studio 14 2015 Win64"
100-
# for VS15: cmake .. -G"Visual Studio 15 2017" -A x64
101-
# for VS16: cmake .. -G"Visual Studio 16 2019" -A x64
102-
cmake --build . --config Release
95+
cmake -B build -S . -G"Visual Studio 14 2015 Win64"
96+
# for VS15: cmake -B build -S . -G"Visual Studio 15 2017" -A x64
97+
# for VS16: cmake -B build -S . -G"Visual Studio 16 2019" -A x64
98+
cmake --build build --config Release
10399
104100
This specifies an out of source build using the Visual Studio 64 bit generator. (Change the ``-G`` option appropriately if you have a different version of Visual Studio installed.)
105101

@@ -127,10 +123,8 @@ From the command line on Linux starting from the XGBoost directory:
127123

128124
.. code-block:: bash
129125
130-
mkdir build
131-
cd build
132-
cmake .. -DUSE_CUDA=ON
133-
make -j4
126+
cmake -B build -S . -DUSE_CUDA=ON
127+
cmake --build build -j4
134128
135129
.. note:: Specifying compute capability
136130

@@ -142,28 +136,24 @@ From the command line on Linux starting from the XGBoost directory:
142136

143137
.. code-block:: bash
144138
145-
mkdir build
146-
cd build
147-
cmake .. -DUSE_CUDA=ON -DUSE_NCCL=ON -DNCCL_ROOT=/path/to/nccl2
148-
make -j4
139+
cmake -B build -S . -DUSE_CUDA=ON -DUSE_NCCL=ON -DNCCL_ROOT=/path/to/nccl2
140+
cmake --build build -j4
149141
150142
Some additional flags are available for NCCL, ``BUILD_WITH_SHARED_NCCL`` enables building XGBoost with NCCL as a shared library, while ``USE_DLOPEN_NCCL`` enables XGBoost to load NCCL at runtime using ``dlopen``.
151143

152144
On Windows, run CMake as follows:
153145

154146
.. code-block:: bash
155147
156-
mkdir build
157-
cd build
158-
cmake .. -G"Visual Studio 17 2022" -A x64 -DUSE_CUDA=ON
148+
cmake -B build -S . -G"Visual Studio 17 2022" -A x64 -DUSE_CUDA=ON
159149
160150
(Change the ``-G`` option appropriately if you have a different version of Visual Studio installed.)
161151

162152
The above cmake configuration run will create an ``xgboost.sln`` solution file in the build directory. Build this solution in Release mode, either from Visual studio or from command line:
163153

164154
.. code-block:: bash
165155
166-
cmake --build . --target xgboost --config Release
156+
cmake --buildbuild. --target xgboost --config Release
167157
168158
To speed up compilation, run multiple jobs in parallel by appending option ``-- /MP``.
169159

@@ -250,14 +240,11 @@ There are several ways to build and install the package from source:
250240

251241
.. code-block:: bash
252242
253-
# Under xgboost source directory
254-
mkdir build
255-
cd build
256243
# Build shared library libxgboost.so
257-
cmake .. -GNinja
258-
ninja
244+
cmake -B build -S . -GNinja
245+
cmake --build build
259246
# Install as editable installation
260-
cd ../python-package
247+
cd ./python-package
261248
pip install -e .
262249
263250
4. Use ``libxgboost.so`` on system path.
@@ -336,11 +323,8 @@ above snippet can be replaced by:
336323

337324
.. code-block:: bash
338325
339-
mkdir build
340-
cd build
341-
cmake .. -DR_LIB=ON
342-
make -j$(nproc)
343-
make install
326+
cmake -B build -S . -DR_LIB=ON
327+
cmake --build build --target install -j$(nproc)
344328
345329
346330
Installing the development version with Visual Studio (Windows)
@@ -368,10 +352,8 @@ Open the Command Prompt and navigate to the XGBoost directory, and then run the
368352
.. code-block:: bash
369353
370354
cd C:\path\to\xgboost
371-
mkdir build
372-
cd build
373-
cmake .. -G"Visual Studio 16 2019" -A x64 -DR_LIB=ON -DR_VERSION=4.0.0
374-
cmake --build . --target install --config Release
355+
cmake -B build -S . -G"Visual Studio 16 2019" -A x64 -DR_LIB=ON -DR_VERSION=4.0.0
356+
cmake --build build --target install --config Release
375357
376358
377359
.. _r_gpu_support:
@@ -385,10 +367,8 @@ On Linux, starting from the XGBoost directory type:
385367

386368
.. code-block:: bash
387369
388-
mkdir build
389-
cd build
390-
cmake .. -DUSE_CUDA=ON -DR_LIB=ON
391-
make install -j$(nproc)
370+
cmake -B build -S . -DUSE_CUDA=ON -DR_LIB=ON
371+
cmake --build build --target install -j$(nproc)
392372
393373
When default target is used, an R package shared library would be built in the ``build`` area.
394374
The ``install`` target, in addition, assembles the package files with this shared library under ``build/R-package`` and runs ``R CMD INSTALL``.
@@ -413,10 +393,8 @@ Open the Command Prompt and navigate to the XGBoost directory, and then run the
413393
.. code-block:: bash
414394
415395
cd C:\path\to\xgboost
416-
mkdir build
417-
cd build
418-
cmake .. -G"Visual Studio 16 2019" -A x64 -DUSE_CUDA=ON -DR_LIB=ON -DR_VERSION=4.0.0
419-
cmake --build . --target install --config Release
396+
cmake -B build -S . -G"Visual Studio 16 2019" -A x64 -DUSE_CUDA=ON -DR_LIB=ON -DR_VERSION=4.0.0
397+
cmake --build build --target install --config Release
420398
421399
If CMake can't find your R during the configuration step, you might provide the location of R to CMake like this: ``-DLIBR_HOME="C:\Program Files\R\R-4.0.0"``.
422400

doc/contrib/unit_tests.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,9 @@ To build and run C++ unit tests enable tests while running CMake:
130130

131131
.. code-block:: bash
132132
133-
mkdir build
134-
cd build
135-
cmake -GNinja -DGOOGLE_TEST=ON -DUSE_DMLC_GTEST=ON -DUSE_CUDA=ON -DUSE_NCCL=ON ..
136-
ninja
133+
cmake -B build -S . -GNinja -DGOOGLE_TEST=ON -DUSE_DMLC_GTEST=ON -DUSE_CUDA=ON -DUSE_NCCL=ON
134+
cmake --build build
135+
cd ./build
137136
./testxgboost
138137
139138
Flags like ``USE_CUDA``, ``USE_DMLC_GTEST`` are optional. For more info about how to build

doc/tutorials/c_api_tutorial.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@ Run the following commands on your terminal. The below commands will install the
2626
# clone the XGBoost repository & its submodules
2727
git clone --recursive https://github.com/dmlc/xgboost
2828
cd xgboost
29-
mkdir build
30-
cd build
3129
# Activate the Conda environment, into which we'll install XGBoost
3230
conda activate [env_name]
3331
# Build the compiled version of XGBoost inside the build folder
34-
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
32+
cmake -B build -S . -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
3533
# install XGBoost in your conda environment (usually under [your home directory]/miniconda3)
36-
make install
34+
cmake --build build --target install
3735
3836
*********************************************************************
3937
Configure CMakeList.txt file of your application to link with XGBoost
@@ -55,14 +53,12 @@ To ensure that CMake can locate the XGBoost library, supply ``-DCMAKE_PREFIX_PAT
5553

5654
.. code-block:: bash
5755
58-
# Navigate to the build directory for your application
59-
cd build
6056
# Activate the Conda environment where we previously installed XGBoost
6157
conda activate [env_name]
6258
# Invoke CMake with CMAKE_PREFIX_PATH
63-
cmake .. -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
59+
cmake -B build -S . -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
6460
# Build your application
65-
make
61+
cmake --build build
6662
6763
************************
6864
Useful Tips To Remember

plugin/sycl/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ See also [Intel® oneAPI Programming Guide](https://www.intel.com/content/www/us
3333
From the ``xgboost`` directory, run:
3434

3535
```bash
36-
$ mkdir build
37-
$ cd build
38-
$ cmake .. -DPLUGIN_SYCL=ON
39-
$ make -j
40-
```
36+
$ cmake -B build -S . -DPLUGIN_SYCL=ON
37+
$ cmake --build build -j
38+
```

0 commit comments

Comments
 (0)