![]() |
|
|||
File indexing completed on 2025-08-06 08:19:53
0001 # A sample Makefile for building both Google Mock and Google Test and 0002 # using them in user tests. This file is self-contained, so you don't 0003 # need to use the Makefile in Google Test's source tree. Please tweak 0004 # it to suit your environment and project. You may want to move it to 0005 # your project's root directory. 0006 # 0007 # SYNOPSIS: 0008 # 0009 # make [all] - makes everything. 0010 # make TARGET - makes the given target. 0011 # make clean - removes all files generated by make. 0012 0013 # Please tweak the following variable definitions as needed by your 0014 # project, except GMOCK_HEADERS and GTEST_HEADERS, which you can use 0015 # in your own targets but shouldn't modify. 0016 0017 # Points to the root of Google Test, relative to where this file is. 0018 # Remember to tweak this if you move this file, or if you want to use 0019 # a copy of Google Test at a different location. 0020 GTEST_DIR = ../../googletest 0021 0022 # Points to the root of Google Mock, relative to where this file is. 0023 # Remember to tweak this if you move this file. 0024 GMOCK_DIR = .. 0025 0026 # Where to find user code. 0027 USER_DIR = ../test 0028 0029 # Flags passed to the preprocessor. 0030 # Set Google Test and Google Mock's header directories as system 0031 # directories, such that the compiler doesn't generate warnings in 0032 # these headers. 0033 CPPFLAGS += -isystem $(GTEST_DIR)/include -isystem $(GMOCK_DIR)/include 0034 0035 # Flags passed to the C++ compiler. 0036 CXXFLAGS += -g -Wall -Wextra -pthread 0037 0038 # All tests produced by this Makefile. Remember to add new tests you 0039 # created to the list. 0040 TESTS = gmock_test 0041 0042 # All Google Test headers. Usually you shouldn't change this 0043 # definition. 0044 GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \ 0045 $(GTEST_DIR)/include/gtest/internal/*.h 0046 0047 # All Google Mock headers. Note that all Google Test headers are 0048 # included here too, as they are #included by Google Mock headers. 0049 # Usually you shouldn't change this definition. 0050 GMOCK_HEADERS = $(GMOCK_DIR)/include/gmock/*.h \ 0051 $(GMOCK_DIR)/include/gmock/internal/*.h \ 0052 $(GTEST_HEADERS) 0053 0054 # House-keeping build targets. 0055 0056 all : $(TESTS) 0057 0058 clean : 0059 rm -f $(TESTS) gmock.a gmock_main.a *.o 0060 0061 # Builds gmock.a and gmock_main.a. These libraries contain both 0062 # Google Mock and Google Test. A test should link with either gmock.a 0063 # or gmock_main.a, depending on whether it defines its own main() 0064 # function. It's fine if your test only uses features from Google 0065 # Test (and not Google Mock). 0066 0067 # Usually you shouldn't tweak such internal variables, indicated by a 0068 # trailing _. 0069 GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS) 0070 GMOCK_SRCS_ = $(GMOCK_DIR)/src/*.cc $(GMOCK_HEADERS) 0071 0072 # For simplicity and to avoid depending on implementation details of 0073 # Google Mock and Google Test, the dependencies specified below are 0074 # conservative and not optimized. This is fine as Google Mock and 0075 # Google Test compile fast and for ordinary users their source rarely 0076 # changes. 0077 gtest-all.o : $(GTEST_SRCS_) 0078 $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CXXFLAGS) \ 0079 -c $(GTEST_DIR)/src/gtest-all.cc 0080 0081 gmock-all.o : $(GMOCK_SRCS_) 0082 $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CXXFLAGS) \ 0083 -c $(GMOCK_DIR)/src/gmock-all.cc 0084 0085 gmock_main.o : $(GMOCK_SRCS_) 0086 $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CXXFLAGS) \ 0087 -c $(GMOCK_DIR)/src/gmock_main.cc 0088 0089 gmock.a : gmock-all.o gtest-all.o 0090 $(AR) $(ARFLAGS) $@ $^ 0091 0092 gmock_main.a : gmock-all.o gtest-all.o gmock_main.o 0093 $(AR) $(ARFLAGS) $@ $^ 0094 0095 # Builds a sample test. 0096 0097 gmock_test.o : $(USER_DIR)/gmock_test.cc $(GMOCK_HEADERS) 0098 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/gmock_test.cc 0099 0100 gmock_test : gmock_test.o gmock_main.a 0101 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |