| 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 = ../gtest |
| 18 | |
| 19 | #Points to the root of Dasher's source code |
| 20 | DASHER_CORE_DIR = ../../Src/DasherCore |
| 21 | |
| 22 | TEST_PLATFORM_DIR = ../../Src/TestPlatform |
| 23 | |
| 24 | |
| 25 | # Where to find user code. |
| 26 | USER_DIR = . |
| 27 | |
| 28 | # Where to find dasher object files |
| 29 | DASHER_SANDBOX_DIR = ../../dasher-sandbox/Src |
| 30 | |
| 31 | DASHER_DIR = ../../Src |
| 32 | |
| 33 | # Flags passed to the preprocessor. |
| 34 | CPPFLAGS += -I$(GTEST_DIR)/include -I$(DASHER_DIR)/DasherCore |
| 35 | |
| 36 | # Flags passed to the C++ compiler. |
| 37 | CXXFLAGS += -g |
| 38 | |
| 39 | # All tests produced by this Makefile. Remember to add new tests you |
| 40 | # created to the list. |
| 41 | TESTS = EventTest |
| 42 | |
| 43 | # All Google Test headers. Usually you shouldn't change this |
| 44 | # definition. |
| 45 | GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \ |
| 46 | $(GTEST_DIR)/include/gtest/internal/*.h |
| 47 | |
| 48 | # House-keeping build targets. |
| 49 | |
| 50 | all : $(TESTS) |
| 51 | |
| 52 | install : |
| 53 | |
| 54 | uninstall : |
| 55 | |
| 56 | clean : |
| 57 | rm -f $(TESTS) gtest.a gtest_main.a *.o |
| 58 | |
| 59 | # Builds gtest.a and gtest_main.a. |
| 60 | |
| 61 | # Usually you shouldn't tweak such internal variables, indicated by a |
| 62 | # trailing _. |
| 63 | GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS) |
| 64 | |
| 65 | # For simplicity and to avoid depending on Google Test's |
| 66 | # implementation details, the dependencies specified below are |
| 67 | # conservative and not optimized. This is fine as Google Test |
| 68 | # compiles fast and for ordinary users its source rarely changes. |
| 69 | gtest-all.o : $(GTEST_SRCS_) |
| 70 | $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ |
| 71 | $(GTEST_DIR)/src/gtest-all.cc |
| 72 | |
| 73 | gtest_main.o : $(GTEST_SRCS_) |
| 74 | $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ |
| 75 | $(GTEST_DIR)/src/gtest_main.cc |
| 76 | |
| 77 | gtest.a : gtest-all.o |
| 78 | $(AR) $(ARFLAGS) $@ $^ |
| 79 | |
| 80 | gtest_main.a : gtest-all.o gtest_main.o |
| 81 | $(AR) $(ARFLAGS) $@ $^ |
| 82 | |
| 83 | |
| 84 | # Builds a sample test. A test should link with either gtest.a or |
| 85 | # gtest_main.a, depending on whether it defines its own main() |
| 86 | # function. |
| 87 | |
| 88 | #sample1.o : $(USER_DIR)/sample1.cc $(USER_DIR)/sample1.h $(GTEST_HEADERS) |
| 89 | # $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/sample1.cc |
| 90 | |
| 91 | #sample1_unittest.o : $(USER_DIR)/sample1_unittest.cc \ |
| 92 | # $(USER_DIR)/sample1.h $(GTEST_HEADERS) |
| 93 | # $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/sample1_unittest.cc |
| 94 | |
| 95 | #sample1_unittest : sample1.o sample1_unittest.o gtest_main.a |
| 96 | # $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ |
| 97 | |
| 98 | WordGenTest.o : $(USER_DIR)/WordGenTest.cpp |
| 99 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/WordGenTest.cpp |
| 100 | |
| 101 | WordGenTest : WordGenTest.o \ |
| 102 | gtest_main.a $(DASHER_CORE_DIR)/libdashercore.a \ |
| 103 | $(DASHER_CORE_DIR)/libdasherprefs.a \ |
| 104 | $(DASHER_CORE_DIR)/LanguageModelling/libdasherlm.a |
| 105 | $(CXX) $(CPPFLAGS) -lexpat $(CXXFLAGS) -lpthread $^ -o $@ |
| 106 | |
| 107 | EventTest.o : $(USER_DIR)/EventTest.cpp |
| 108 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/EventTest.cpp |
| 109 | |
| 110 | EventTest : EventTest.o \ |
| 111 | gtest_main.a $(DASHER_CORE_DIR)/libdashercore.a \ |
| 112 | $(DASHER_CORE_DIR)/libdasherprefs.a \ |
| 113 | $(DASHER_CORE_DIR)/LanguageModelling/libdasherlm.a |
| 114 | $(CXX) $(CPPFLAGS) -lexpat $(CXXFLAGS) -lpthread $^ -o $@ |
| 115 | |
| 116 |