Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
bfcc47fc
Unverified
Commit
bfcc47fc
authored
Jan 03, 2019
by
Gennadiy Civil
Committed by
GitHub
Jan 03, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2026 from justin6case/example_makefile_improvements
Example/sample makefile improvements
parents
1bcbd587
b93a13ec
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
13 deletions
+35
-13
Makefile
googlemock/make/Makefile
+23
-7
Makefile
googletest/make/Makefile
+12
-6
No files found.
googlemock/make/Makefile
View file @
bfcc47fc
...
@@ -19,6 +19,9 @@
...
@@ -19,6 +19,9 @@
# a copy of Google Test at a different location.
# a copy of Google Test at a different location.
GTEST_DIR
=
../../googletest
GTEST_DIR
=
../../googletest
# Points to the location of the Google Test libraries
GTEST_LIB_DIR
=
.
# Points to the root of Google Mock, relative to where this file is.
# Points to the root of Google Mock, relative to where this file is.
# Remember to tweak this if you move this file.
# Remember to tweak this if you move this file.
GMOCK_DIR
=
..
GMOCK_DIR
=
..
...
@@ -33,7 +36,10 @@ USER_DIR = ../test
...
@@ -33,7 +36,10 @@ USER_DIR = ../test
CPPFLAGS
+=
-isystem
$(GTEST_DIR)
/include
-isystem
$(GMOCK_DIR)
/include
CPPFLAGS
+=
-isystem
$(GTEST_DIR)
/include
-isystem
$(GMOCK_DIR)
/include
# Flags passed to the C++ compiler.
# Flags passed to the C++ compiler.
CXXFLAGS
+=
-g
-Wall
-Wextra
-pthread
CXXFLAGS
+=
-g
-Wall
-Wextra
-pthread
-std
=
c++11
# Google Test libraries
GTEST_LIBS
=
libgtest.a libgtest_main.a libgmock.a libgmock_main.a
# All tests produced by this Makefile. Remember to add new tests you
# All tests produced by this Makefile. Remember to add new tests you
# created to the list.
# created to the list.
...
@@ -53,10 +59,10 @@ GMOCK_HEADERS = $(GMOCK_DIR)/include/gmock/*.h \
...
@@ -53,10 +59,10 @@ GMOCK_HEADERS = $(GMOCK_DIR)/include/gmock/*.h \
# House-keeping build targets.
# House-keeping build targets.
all
:
$(TESTS)
all
:
$(
GTEST_LIBS) $(
TESTS)
clean
:
clean
:
rm
-f
$(
TESTS)
gmock.a gmock_main.a
*
.o
rm
-f
$(
GTEST_LIBS)
$(TESTS)
*
.o
# Builds gmock.a and gmock_main.a. These libraries contain both
# Builds gmock.a and gmock_main.a. These libraries contain both
# Google Mock and Google Test. A test should link with either gmock.a
# Google Mock and Google Test. A test should link with either gmock.a
...
@@ -78,6 +84,10 @@ gtest-all.o : $(GTEST_SRCS_)
...
@@ -78,6 +84,10 @@ gtest-all.o : $(GTEST_SRCS_)
$(CXX)
$(CPPFLAGS)
-I
$(GTEST_DIR)
-I
$(GMOCK_DIR)
$(CXXFLAGS)
\
$(CXX)
$(CPPFLAGS)
-I
$(GTEST_DIR)
-I
$(GMOCK_DIR)
$(CXXFLAGS)
\
-c
$(GTEST_DIR)
/src/gtest-all.cc
-c
$(GTEST_DIR)
/src/gtest-all.cc
gtest_main.o
:
$(GTEST_SRCS_)
$(CXX)
$(CPPFLAGS)
-I
$(GTEST_DIR)
-I
$(GMOCK_DIR)
$(CXXFLAGS)
\
-c
$(GTEST_DIR)
/src/gtest_main.cc
gmock-all.o
:
$(GMOCK_SRCS_)
gmock-all.o
:
$(GMOCK_SRCS_)
$(CXX)
$(CPPFLAGS)
-I
$(GTEST_DIR)
-I
$(GMOCK_DIR)
$(CXXFLAGS)
\
$(CXX)
$(CPPFLAGS)
-I
$(GTEST_DIR)
-I
$(GMOCK_DIR)
$(CXXFLAGS)
\
-c
$(GMOCK_DIR)
/src/gmock-all.cc
-c
$(GMOCK_DIR)
/src/gmock-all.cc
...
@@ -86,10 +96,16 @@ gmock_main.o : $(GMOCK_SRCS_)
...
@@ -86,10 +96,16 @@ gmock_main.o : $(GMOCK_SRCS_)
$(CXX)
$(CPPFLAGS)
-I
$(GTEST_DIR)
-I
$(GMOCK_DIR)
$(CXXFLAGS)
\
$(CXX)
$(CPPFLAGS)
-I
$(GTEST_DIR)
-I
$(GMOCK_DIR)
$(CXXFLAGS)
\
-c
$(GMOCK_DIR)
/src/gmock_main.cc
-c
$(GMOCK_DIR)
/src/gmock_main.cc
gmock.a
:
gmock-all.o gtest-all.o
libgtest.a
:
gtest-all.o
$(AR)
$(ARFLAGS)
$@
$^
libgtest_main.a
:
gtest_main.o
$(AR)
$(ARFLAGS)
$@
$^
libgmock.a
:
gmock-all.o
$(AR)
$(ARFLAGS)
$@
$^
$(AR)
$(ARFLAGS)
$@
$^
gmock_main.a
:
gmock-all.o gtest-all.o
gmock_main.o
libgmock_main.a
:
gmock_main.o
$(AR)
$(ARFLAGS)
$@
$^
$(AR)
$(ARFLAGS)
$@
$^
# Builds a sample test.
# Builds a sample test.
...
@@ -97,5 +113,5 @@ gmock_main.a : gmock-all.o gtest-all.o gmock_main.o
...
@@ -97,5 +113,5 @@ gmock_main.a : gmock-all.o gtest-all.o gmock_main.o
gmock_test.o
:
$(USER_DIR)/gmock_test.cc $(GMOCK_HEADERS)
gmock_test.o
:
$(USER_DIR)/gmock_test.cc $(GMOCK_HEADERS)
$(CXX)
$(CPPFLAGS)
$(CXXFLAGS)
-c
$(USER_DIR)
/gmock_test.cc
$(CXX)
$(CPPFLAGS)
$(CXXFLAGS)
-c
$(USER_DIR)
/gmock_test.cc
gmock_test
:
gmock_test.o
gmock_main.a
gmock_test
:
gmock_test.o
$(GTEST_LIBS)
$(CXX)
$(CPPFLAGS)
$(CXXFLAGS)
-lpthread
$^
-o
$@
$(CXX)
$(CPPFLAGS)
$(CXXFLAGS)
-
L
$(GTEST_LIB_DIR)
-lgmock
-
lpthread
$^
-o
$@
googletest/make/Makefile
View file @
bfcc47fc
...
@@ -16,6 +16,9 @@
...
@@ -16,6 +16,9 @@
# Remember to tweak this if you move this file.
# Remember to tweak this if you move this file.
GTEST_DIR
=
..
GTEST_DIR
=
..
# Points to the location of the Google Test libraries
GTEST_LIB_DIR
=
.
# Where to find user code.
# Where to find user code.
USER_DIR
=
../samples
USER_DIR
=
../samples
...
@@ -27,6 +30,9 @@ CPPFLAGS += -isystem $(GTEST_DIR)/include
...
@@ -27,6 +30,9 @@ CPPFLAGS += -isystem $(GTEST_DIR)/include
# Flags passed to the C++ compiler.
# Flags passed to the C++ compiler.
CXXFLAGS
+=
-g
-Wall
-Wextra
-pthread
-std
=
c++11
CXXFLAGS
+=
-g
-Wall
-Wextra
-pthread
-std
=
c++11
# Google Test libraries
GTEST_LIBS
=
libgtest.a libgtest_main.a
# All tests produced by this Makefile. Remember to add new tests you
# All tests produced by this Makefile. Remember to add new tests you
# created to the list.
# created to the list.
TESTS
=
sample1_unittest
TESTS
=
sample1_unittest
...
@@ -38,10 +44,10 @@ GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
...
@@ -38,10 +44,10 @@ GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
# House-keeping build targets.
# House-keeping build targets.
all
:
$(TESTS)
all
:
$(
GTEST_LIBS) $(
TESTS)
clean
:
clean
:
rm
-f
$(
TESTS)
gtest.a gtest_main.a
*
.o
rm
-f
$(
GTEST_LIBS)
$(TESTS)
*
.o
# Builds gtest.a and gtest_main.a.
# Builds gtest.a and gtest_main.a.
...
@@ -61,10 +67,10 @@ gtest_main.o : $(GTEST_SRCS_)
...
@@ -61,10 +67,10 @@ gtest_main.o : $(GTEST_SRCS_)
$(CXX)
$(CPPFLAGS)
-I
$(GTEST_DIR)
$(CXXFLAGS)
-c
\
$(CXX)
$(CPPFLAGS)
-I
$(GTEST_DIR)
$(CXXFLAGS)
-c
\
$(GTEST_DIR)
/src/gtest_main.cc
$(GTEST_DIR)
/src/gtest_main.cc
gtest.a
:
gtest-all.o
lib
gtest.a
:
gtest-all.o
$(AR)
$(ARFLAGS)
$@
$^
$(AR)
$(ARFLAGS)
$@
$^
gtest_main.a
:
gtest-all.o gtest_main.o
lib
gtest_main.a
:
gtest-all.o gtest_main.o
$(AR)
$(ARFLAGS)
$@
$^
$(AR)
$(ARFLAGS)
$@
$^
# Builds a sample test. A test should link with either gtest.a or
# Builds a sample test. A test should link with either gtest.a or
...
@@ -78,5 +84,5 @@ sample1_unittest.o : $(USER_DIR)/sample1_unittest.cc \
...
@@ -78,5 +84,5 @@ sample1_unittest.o : $(USER_DIR)/sample1_unittest.cc \
$(USER_DIR)/sample1.h $(GTEST_HEADERS)
$(USER_DIR)/sample1.h $(GTEST_HEADERS)
$(CXX)
$(CPPFLAGS)
$(CXXFLAGS)
-c
$(USER_DIR)
/sample1_unittest.cc
$(CXX)
$(CPPFLAGS)
$(CXXFLAGS)
-c
$(USER_DIR)
/sample1_unittest.cc
sample1_unittest
:
sample1.o sample1_unittest.o
gtest_main.a
sample1_unittest
:
sample1.o sample1_unittest.o
$(GTEST_LIBS)
$(CXX)
$(CPPFLAGS)
$(CXXFLAGS)
-lpthread
$^
-o
$@
$(CXX)
$(CPPFLAGS)
$(CXXFLAGS)
-
L
$(GTEST_LIB_DIR)
-lgtest_main
-
lpthread
$^
-o
$@
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment