Makefile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. # Please tweak the following variable definitions as needed by your
  11. # project, except GTEST_HEADERS, which you can use in your own targets
  12. # but shouldn't modify.
  13. # Points to the root of Google Test, relative to where this file is.
  14. # Remember to tweak this if you move this file.
  15. GTEST_DIR = ..
  16. # Flags passed to the preprocessor.
  17. # Set Google Test's header directory as a system directory, such that
  18. # the compiler doesn't generate warnings in Google Test headers.
  19. CPPFLAGS += -isystem $(GTEST_DIR)/include
  20. # Flags passed to the C++ compiler.
  21. CXXFLAGS += -g -Wall -Wextra -pthread -fPIC
  22. # All Google Test headers. Usually you shouldn't change this
  23. # definition.
  24. GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
  25. $(GTEST_DIR)/include/gtest/internal/*.h
  26. # House-keeping build targets.
  27. all : libgtest.a libgtest_main.a
  28. clean :
  29. rm -f libgtest.a libgtest_main.a *.o
  30. # Builds libgtest.a and libgtest_main.a.
  31. # Usually you shouldn't tweak such internal variables, indicated by a
  32. # trailing _.
  33. GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
  34. # For simplicity and to avoid depending on Google Test's
  35. # implementation details, the dependencies specified below are
  36. # conservative and not optimized. This is fine as Google Test
  37. # compiles fast and for ordinary users its source rarely changes.
  38. gtest-all.o : $(GTEST_SRCS_)
  39. $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
  40. $(GTEST_DIR)/src/gtest-all.cc
  41. gtest_main.o : $(GTEST_SRCS_)
  42. $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
  43. $(GTEST_DIR)/src/gtest_main.cc
  44. libgtest.a : gtest-all.o
  45. $(AR) $(ARFLAGS) $@ $^
  46. libgtest_main.a : gtest-all.o gtest_main.o
  47. $(AR) $(ARFLAGS) $@ $^