forked from OpenDDS/OpenDDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gtest_setup.txt
98 lines (72 loc) · 3.28 KB
/
gtest_setup.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Setting up Google Test
Many of the newer OpenDDS unit tests rely on Google Test, which can be set up
using Git submodules or by specifying an external location (system-wide or user-
defined).
Note: Any test executables which depend upon Gtest can use the googletest.mpb
MPC base project (in $DDS_ROOT/MPC/config) to pull in the required libraries.
## Using a Git Submodule
1. Your OpenDDS git repo needs to have submodules enabled and
the directory $DDS_ROOT/tests/googletest should not be empty.
If it is empty, run "git submodule init" followed by "git submodule update"
see https://git-scm.com/book/en/v2/Git-Tools-Submodules
2. Build the Gtest library.
Create the following directories:
a. $DDS_ROOT/tests/googletest/build
b. $DDS_ROOT/tests/googletest/build/install
Change into the build directory just created and run cmake using
$DDS_ROOT/tests/googletest as the source directory, and using
$DDS_ROOT/tests/googletest/build/install as an install prefix:
~~~
cd tests/googletest/build
cmake -DCMAKE_INSTALL_PREFIX=./install ..
~~~
Note: if using Visual C++ and your OpenDDS build is not static,
enable gtest_force_shared_crt or BUILD_SHARED_LIBS. In addition,
a couple other flags are probably necessary to select the proper
build environment and disable TR1-Deprecation warnings:
~~~
cd tests\googletest\build
cmake -DCMAKE_INSTALL_PREFIX=.\install ^
-Dgtest_force_shared_crt=ON ^
-DCMAKE_CXX_FLAGS=/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 ^
-G "Visual Studio 15 2017 Win64" ..
~~~
Then build and install the Gtest library using cmake from the build
directory:
~~~
cmake --build . --target install
~~~
3. Configure and build OpenDDS as usual.
## Using an External Location
1. Clone the Google Test repo into some directory (doesn't really matter where
as the install target will be the _actual_ library directory).
~~~
git clone https://github.com/google/googletest.git
~~~
2. Follow the steps in "Using a Git Submodule" with the following differences:
a. The install location can be anywhere you desire, or it can be completely
omitted (in which case the default system location will be used).
b. An elevated terminal/cmd shell will probably be required if the install
prefix is omitted.
c. When invoking the OpenDDS configure script, if the default system location
is _not_ used, then the gtest switch can be used to inform the configure
script where the gtest libraries are located. Otherwise, the configure script
should detect the default location.
~~~
./configure --gtest=/path/the/gtest/install/dir
~~~
d. Alternatively, the Gtest root can be overridden by setting the GTEST_ROOT
environment variable before regenerating the build files with MWC.pl.
For example (within the DDS_ROOT directory):
Windows:
~~~
set GTEST_ROOT=c:\path\to\gtest\root
mwc.pl -type vs2017 DDS.mwc
msbuild /m DDS_TAOv2_all.sln
~~~
Unix:
~~~
export GTEST_ROOT=/path/to/gtest/root
mwc.pl -type gnuace DDS.mwc
make
~~~