| 1 |
# A sample Makefile for building Google Test and using it in user |
| 2 |
# tests. Please tweak it to suit your environment and project. You |
| 3 |
# may want to move it to your project's root directory. |
| 4 |
# |
| 5 |
# SYNOPSIS: |
| 6 |
# |
| 7 |
# make [all] - makes everything. |
| 8 |
# make TARGET - makes the given target. |
| 9 |
# make clean - removes all files generated by make. |
| 10 |
|
| 11 |
# Please tweak the following variable definitions as needed by your |
| 12 |
# project, except GTEST_HEADERS, which you can use in your own targets |
| 13 |
# but shouldn't modify. |
| 14 |
|
| 15 |
# Points to the root of Google Test, relative to where this file is. |
| 16 |
# Remember to tweak this if you move this file. |
| 17 |
GTEST_DIR = .. |
| 18 |
|
| 19 |
# Flags passed to the preprocessor. |
| 20 |
# Set Google Test's header directory as a system directory, such that |
| 21 |
# the compiler doesn't generate warnings in Google Test headers. |
| 22 |
CPPFLAGS += -isystem $(GTEST_DIR)/include |
| 23 |
|
| 24 |
# Flags passed to the C++ compiler. |
| 25 |
CXXFLAGS += -g -Wall -Wextra -pthread -fPIC |
| 26 |
|
| 27 |
# All Google Test headers. Usually you shouldn't change this |
| 28 |
# definition. |
| 29 |
GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \ |
| 30 |
$(GTEST_DIR)/include/gtest/internal/*.h |
| 31 |
|
| 32 |
# House-keeping build targets. |
| 33 |
|
| 34 |
all : libgtest.a libgtest_main.a |
| 35 |
|
| 36 |
clean : |
| 37 |
rm -f libgtest.a libgtest_main.a *.o |
| 38 |
|
| 39 |
# Builds libgtest.a and libgtest_main.a. |
| 40 |
|
| 41 |
# Usually you shouldn't tweak such internal variables, indicated by a |
| 42 |
# trailing _. |
| 43 |
GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS) |
| 44 |
|
| 45 |
# For simplicity and to avoid depending on Google Test's |
| 46 |
# implementation details, the dependencies specified below are |
| 47 |
# conservative and not optimized. This is fine as Google Test |
| 48 |
# compiles fast and for ordinary users its source rarely changes. |
| 49 |
gtest-all.o : $(GTEST_SRCS_) |
| 50 |
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ |
| 51 |
$(GTEST_DIR)/src/gtest-all.cc |
| 52 |
|
| 53 |
gtest_main.o : $(GTEST_SRCS_) |
| 54 |
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ |
| 55 |
$(GTEST_DIR)/src/gtest_main.cc |
| 56 |
|
| 57 |
libgtest.a : gtest-all.o |
| 58 |
$(AR) $(ARFLAGS) $@ $^ |
| 59 |
|
| 60 |
libgtest_main.a : gtest-all.o gtest_main.o |
| 61 |
$(AR) $(ARFLAGS) $@ $^ |