OLD | NEW |
1 # A sample Makefile for building both Google Mock and Google Test and | 1 # A sample Makefile for building both Google Mock and Google Test and |
2 # using them in user tests. This file is self-contained, so you don't | 2 # using them in user tests. This file is self-contained, so you don't |
3 # need to use the Makefile in Google Test's source tree. Please tweak | 3 # need to use the Makefile in Google Test's source tree. Please tweak |
4 # it to suit your environment and project. You may want to move it to | 4 # it to suit your environment and project. You may want to move it to |
5 # your project's root directory. | 5 # your project's root directory. |
6 # | 6 # |
7 # SYNOPSIS: | 7 # SYNOPSIS: |
8 # | 8 # |
9 # make [all] - makes everything. | 9 # make [all] - makes everything. |
10 # make TARGET - makes the given target. | 10 # make TARGET - makes the given target. |
11 # make clean - removes all files generated by make. | 11 # make clean - removes all files generated by make. |
12 | 12 |
13 # Please tweak the following variable definitions as needed by your | 13 # Please tweak the following variable definitions as needed by your |
14 # project, except GMOCK_HEADERS and GTEST_HEADERS, which you can use | 14 # project, except GMOCK_HEADERS and GTEST_HEADERS, which you can use |
15 # in your own targets but shouldn't modify. | 15 # in your own targets but shouldn't modify. |
16 | 16 |
17 # Points to the root of Google Test, relative to where this file is. | 17 # Points to the root of Google Test, relative to where this file is. |
18 # Remember to tweak this if you move this file, or if you want to use | 18 # Remember to tweak this if you move this file, or if you want to use |
19 # a copy of Google Test at a different location. | 19 # a copy of Google Test at a different location. |
20 GTEST_DIR = ../gtest | 20 GTEST_DIR = ../gtest |
21 | 21 |
22 # Points to the root of Google Mock, relative to where this file is. | 22 # Points to the root of Google Mock, relative to where this file is. |
23 # Remember to tweak this if you move this file. | 23 # Remember to tweak this if you move this file. |
24 GMOCK_DIR = .. | 24 GMOCK_DIR = .. |
25 | 25 |
26 # Where to find user code. | 26 # Where to find user code. |
27 USER_DIR = ../test | 27 USER_DIR = ../test |
28 | 28 |
29 # Flags passed to the preprocessor. | 29 # Flags passed to the preprocessor. |
30 CPPFLAGS += -I$(GMOCK_DIR) -I$(GMOCK_DIR)/include \ | 30 CPPFLAGS += -I$(GTEST_DIR)/include -I$(GMOCK_DIR)/include |
31 -I$(GTEST_DIR) -I$(GTEST_DIR)/include | |
32 | 31 |
33 # Flags passed to the C++ compiler. | 32 # Flags passed to the C++ compiler. |
34 CXXFLAGS += -g -Wall -Wextra | 33 CXXFLAGS += -g -Wall -Wextra |
35 | 34 |
36 # All tests produced by this Makefile. Remember to add new tests you | 35 # All tests produced by this Makefile. Remember to add new tests you |
37 # created to the list. | 36 # created to the list. |
38 TESTS = gmock_link_test gmock_test | 37 TESTS = gmock_test |
39 | 38 |
40 # All Google Test headers. Usually you shouldn't change this | 39 # All Google Test headers. Usually you shouldn't change this |
41 # definition. | 40 # definition. |
42 GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \ | 41 GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \ |
43 $(GTEST_DIR)/include/gtest/internal/*.h | 42 $(GTEST_DIR)/include/gtest/internal/*.h |
44 | 43 |
45 # All Google Mock headers. Note that all Google Test headers are | 44 # All Google Mock headers. Note that all Google Test headers are |
46 # included here too, as they are #included by Google Mock headers. | 45 # included here too, as they are #included by Google Mock headers. |
47 # Usually you shouldn't change this definition. | 46 # Usually you shouldn't change this definition. |
48 GMOCK_HEADERS = $(GMOCK_DIR)/include/gmock/*.h \ | 47 GMOCK_HEADERS = $(GMOCK_DIR)/include/gmock/*.h \ |
(...skipping 17 matching lines...) Expand all Loading... |
66 # trailing _. | 65 # trailing _. |
67 GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS) | 66 GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS) |
68 GMOCK_SRCS_ = $(GMOCK_DIR)/src/*.cc $(GMOCK_HEADERS) | 67 GMOCK_SRCS_ = $(GMOCK_DIR)/src/*.cc $(GMOCK_HEADERS) |
69 | 68 |
70 # For simplicity and to avoid depending on implementation details of | 69 # For simplicity and to avoid depending on implementation details of |
71 # Google Mock and Google Test, the dependencies specified below are | 70 # Google Mock and Google Test, the dependencies specified below are |
72 # conservative and not optimized. This is fine as Google Mock and | 71 # conservative and not optimized. This is fine as Google Mock and |
73 # Google Test compile fast and for ordinary users their source rarely | 72 # Google Test compile fast and for ordinary users their source rarely |
74 # changes. | 73 # changes. |
75 gtest-all.o : $(GTEST_SRCS_) | 74 gtest-all.o : $(GTEST_SRCS_) |
76 » $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_DIR)/src/gtest-all.cc | 75 » $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CXXFLAGS) \ |
| 76 -c $(GTEST_DIR)/src/gtest-all.cc |
77 | 77 |
78 gmock-all.o : $(GMOCK_SRCS_) | 78 gmock-all.o : $(GMOCK_SRCS_) |
79 » $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GMOCK_DIR)/src/gmock-all.cc | 79 » $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CXXFLAGS) \ |
| 80 -c $(GMOCK_DIR)/src/gmock-all.cc |
80 | 81 |
81 gmock_main.o : $(GMOCK_SRCS_) | 82 gmock_main.o : $(GMOCK_SRCS_) |
82 » $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GMOCK_DIR)/src/gmock_main.cc | 83 » $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CXXFLAGS) \ |
| 84 -c $(GMOCK_DIR)/src/gmock_main.cc |
83 | 85 |
84 gmock.a : gmock-all.o gtest-all.o | 86 gmock.a : gmock-all.o gtest-all.o |
85 $(AR) $(ARFLAGS) $@ $^ | 87 $(AR) $(ARFLAGS) $@ $^ |
86 | 88 |
87 gmock_main.a : gmock-all.o gtest-all.o gmock_main.o | 89 gmock_main.a : gmock-all.o gtest-all.o gmock_main.o |
88 $(AR) $(ARFLAGS) $@ $^ | 90 $(AR) $(ARFLAGS) $@ $^ |
89 | 91 |
90 # Builds a sample test. | 92 # Builds a sample test. |
91 | 93 |
92 gmock_link_test.o : $(USER_DIR)/gmock_link_test.cc \ | |
93 $(USER_DIR)/gmock_link_test.h $(GMOCK_HEADERS) | |
94 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/gmock_link_test.cc | |
95 | |
96 gmock_link2_test.o : $(USER_DIR)/gmock_link2_test.cc \ | |
97 $(USER_DIR)/gmock_link_test.h $(GMOCK_HEADERS) | |
98 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/gmock_link2_test.cc | |
99 | |
100 gmock_link_test : gmock_link_test.o gmock_link2_test.o gmock_main.a | |
101 $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@ | |
102 | |
103 # Builds another sample test. | |
104 | |
105 gmock_test.o : $(USER_DIR)/gmock_test.cc $(GMOCK_HEADERS) | 94 gmock_test.o : $(USER_DIR)/gmock_test.cc $(GMOCK_HEADERS) |
106 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/gmock_test.cc | 95 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/gmock_test.cc |
107 | 96 |
108 gmock_test : gmock_test.o gmock_main.a | 97 gmock_test : gmock_test.o gmock_main.a |
109 » $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@ | 98 » $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ |
OLD | NEW |