Skip to content

Commit

Permalink
docs: Added -GNinja to cmake configuration commands (#10532)
Browse files Browse the repository at this point in the history
* docs: Added `-GNinja` to cmake configuration commands

docs: Also fixed the directory name for clang example

* docs: use -S option and `build-out` directory
  • Loading branch information
Takashi Matsuo committed Jan 10, 2023
1 parent 9196bdc commit d19290d
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions doc/contributor/howto-guide-setup-cmake-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ to the `cmake` configure step:

```shell
cd $HOME/google-cloud-cpp
cmake -H. -Bcmake-out/home -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build cmake-out/home
cmake -G Ninja -S . -B build-out/home \
-DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build-out/home
```

The first time you run this command it can take a significant time to download
Expand All @@ -71,23 +72,24 @@ much faster:

```shell
cd $HOME/another-google-cloud-cpp-clone
cmake -H. -Bcmake-out/home -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build cmake-out/home
cmake -G Ninja -S . -B build-out/home \
-DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build-out/home
```

## Running the unit tests

Once you have built `google-cloud-cpp` you can run the unit tests using:

```shell
env -C cmake-out/home ctest --output-on-failure -LE integration-test
env -C build-out/home ctest --output-on-failure -LE integration-test
```

If you also want to run the integration tests you need to setup multiple
[environment variables](/ci/etc/integration-tests-config.sh), and then run:

```shell
env -C cmake-out/home ctest --output-on-failure
env -C build-out/home ctest --output-on-failure
```

## Other Build Options
Expand All @@ -102,11 +104,12 @@ installed, you can change the compiler using:

```shell
CXX=clang++ CC=clang \
cmake -H. -Bcmake-out/home -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake -G Ninja -S . -B build-out/clang \
-DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake

# Then compile and test normally:
cmake --build cmake-out/clang
(cd cmake-out/clang && ctest --output-on-failure -LE integration-test)
cmake --build build-out/clang
(cd build-out/clang && ctest --output-on-failure -LE integration-test)
```

`vcpkg` uses the compiler as part of its binary cache inputs, that is, changing
Expand All @@ -120,11 +123,11 @@ By default, the system is compiled with optimizations on; if you want to compile
a debug version, use:

```shell
cmake -H. -Bcmake-out/manual -DCMAKE_BUILD_TYPE=Debug
cmake -G Ninja -S . -B build-out/manual -DCMAKE_BUILD_TYPE=Debug

# Then compile and test normally:
cmake --build cmake-out/manual
(cd cmake-out/manual && ctest --output-on-failure -LE integration-test)
cmake --build build-out/manual
(cd build-out/manual && ctest --output-on-failure -LE integration-test)
```

`google-cloud-cpp` supports the standard CMake
Expand Down

0 comments on commit d19290d

Please sign in to comment.