Use correct gtest/gmock flags

The test Makefile.am was using -lgmock -lgmock_main directly, which
cause link issues on compiling test.
Fix this by using the flags specified by gtest package.

Tested: Verify the CI passes build.

Change-Id: Id51134d7e2696e18f7439f15f8d899edba51856e
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/configure.ac b/configure.ac
index b95dc93..59cf5ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,11 +22,12 @@
     AC_MSG_ERROR(["Requires sdbusplus package."]))
 PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging],,\
     AC_MSG_ERROR(["Requires phosphor-logging package."]))
+AX_PTHREAD([], [AC_MSG_ERROR(["pthread required and not found"])])
 
-# gtest
 # Check/set gtest specific functions.
-AX_PTHREAD([GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"],[GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=0"])
-AC_SUBST(GTEST_CPPFLAGS)
+PKG_CHECK_MODULES([GTEST], [gtest], [], [AC_MSG_NOTICE([gtest not found, tests will not build])])
+PKG_CHECK_MODULES([GMOCK], [gmock], [], [AC_MSG_NOTICE([gmock not found, tests will not build])])
+PKG_CHECK_MODULES([GTEST_MAIN], [gtest_main], [], [AC_MSG_NOTICE([gtest_main not found, tests will not build])])
 
 # Test cases require SDK so only build if we're told to (and SDK is available)
 AC_ARG_ENABLE([oe-sdk],