Commit b77e5c76 by Gennadiy Civil

Manual docs tweaks still in preparation for including docs with code pushes

parent a743249a
...@@ -174,9 +174,9 @@ We list the most frequently used macros below. For a complete list, see file ...@@ -174,9 +174,9 @@ We list the most frequently used macros below. For a complete list, see file
### Multi-threaded Tests ### Multi-threaded Tests
Google Test is thread-safe where the pthread library is available. After Google Test is thread-safe where the pthread library is available. After
`#include "gtest/gtest.h"`, you can check the `GTEST_IS_THREADSAFE` macro to see `#include "gtest/gtest.h"`, you can check the
whether this is the case (yes if the macro is `#defined` to 1, no if it's `GTEST_IS_THREADSAFE` macro to see whether this is the case (yes if the macro is
undefined.). `#defined` to 1, no if it's undefined.).
If Google Test doesn't correctly detect whether pthread is available in your If Google Test doesn't correctly detect whether pthread is available in your
environment, you can force it with environment, you can force it with
......
## Using GoogleTest from various build systems ## ## Using GoogleTest from various build systems
GoogleTest comes with pkg-config files that can be used to determine all GoogleTest comes with pkg-config files that can be used to determine all
necessary flags for compiling and linking to GoogleTest (and GoogleMock). necessary flags for compiling and linking to GoogleTest (and GoogleMock).
Pkg-config is a standardised plain-text format containing Pkg-config is a standardised plain-text format containing
* the includedir (-I) path * the includedir (-I) path
* necessary macro (-D) definitions * necessary macro (-D) definitions
* further required flags (-pthread) * further required flags (-pthread)
* the library (-L) path * the library (-L) path
* the library (-l) to link to * the library (-l) to link to
All current build systems support pkg-config in one way or another. For All current build systems support pkg-config in one way or another. For all
all examples here we assume you want to compile the sample examples here we assume you want to compile the sample
`samples/sample3_unittest.cc`. `samples/sample3_unittest.cc`.
### CMake
### CMake ###
Using `pkg-config` in CMake is fairly easy: Using `pkg-config` in CMake is fairly easy:
``` cmake ```cmake
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0048 NEW) cmake_policy(SET CMP0048 NEW)
...@@ -43,11 +42,10 @@ that all libraries have been compiled with threading enabled. In addition, ...@@ -43,11 +42,10 @@ that all libraries have been compiled with threading enabled. In addition,
GoogleTest might also require `-pthread` in the compiling step, and as such GoogleTest might also require `-pthread` in the compiling step, and as such
splitting the pkg-config `Cflags` variable into include dirs and macros for splitting the pkg-config `Cflags` variable into include dirs and macros for
`target_compile_definitions()` might still miss this). The same recommendation `target_compile_definitions()` might still miss this). The same recommendation
goes for using `_LDFLAGS` over the more commonplace `_LIBRARIES`, which goes for using `_LDFLAGS` over the more commonplace `_LIBRARIES`, which happens
happens to discard `-L` flags and `-pthread`. to discard `-L` flags and `-pthread`.
### Autotools ### ### Autotools
Finding GoogleTest in Autoconf and using it from Automake is also fairly easy: Finding GoogleTest in Autoconf and using it from Automake is also fairly easy:
...@@ -77,8 +75,7 @@ testapp_CXXFLAGS = $(GTEST_CFLAGS) ...@@ -77,8 +75,7 @@ testapp_CXXFLAGS = $(GTEST_CFLAGS)
testapp_LDADD = $(GTEST_LIBS) testapp_LDADD = $(GTEST_LIBS)
``` ```
### Meson
### Meson ###
Meson natively uses pkgconfig to query dependencies: Meson natively uses pkgconfig to query dependencies:
...@@ -96,13 +93,12 @@ testapp = executable( ...@@ -96,13 +93,12 @@ testapp = executable(
test('first_and_only_test', testapp) test('first_and_only_test', testapp)
``` ```
### Plain Makefiles
### Plain Makefiles ### Since `pkg-config` is a small Unix command-line utility, it can be used in
handwritten `Makefile`s too:
Since `pkg-config` is a small Unix command-line utility, it can be used ```Makefile
in handwritten `Makefile`s too:
``` Makefile
GTEST_CFLAGS = `pkg-config --cflags gtest_main` GTEST_CFLAGS = `pkg-config --cflags gtest_main`
GTEST_LIBS = `pkg-config --libs gtest_main` GTEST_LIBS = `pkg-config --libs gtest_main`
...@@ -120,12 +116,11 @@ testapp.o: samples/sample3_unittest.cc ...@@ -120,12 +116,11 @@ testapp.o: samples/sample3_unittest.cc
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -c -o $@ $(GTEST_CFLAGS) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -c -o $@ $(GTEST_CFLAGS)
``` ```
### Help! pkg-config can't find GoogleTest!
### Help! pkg-config can't find GoogleTest! ###
Let's say you have a `CMakeLists.txt` along the lines of the one in this Let's say you have a `CMakeLists.txt` along the lines of the one in this
tutorial and you try to run `cmake`. It is very possible that you get a tutorial and you try to run `cmake`. It is very possible that you get a failure
failure along the lines of: along the lines of:
``` ```
-- Checking for one of the modules 'gtest_main' -- Checking for one of the modules 'gtest_main'
...@@ -135,9 +130,9 @@ CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:640 (message): ...@@ -135,9 +130,9 @@ CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:640 (message):
These failures are common if you installed GoogleTest yourself and have not These failures are common if you installed GoogleTest yourself and have not
sourced it from a distro or other package manager. If so, you need to tell sourced it from a distro or other package manager. If so, you need to tell
pkg-config where it can find the `.pc` files containing the information. pkg-config where it can find the `.pc` files containing the information. Say you
Say you installed GoogleTest to `/usr/local`, then it might be that the installed GoogleTest to `/usr/local`, then it might be that the `.pc` files are
`.pc` files are installed under `/usr/local/lib64/pkgconfig`. If you set installed under `/usr/local/lib64/pkgconfig`. If you set
``` ```
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment