[LLVMdev] [PATCH] utils/unittest: Consistency of gtest and gtest_main libs.

Daniel Dunbar daniel at zuster.org
Thu Dec 15 15:38:28 PST 2011


Hi Johannes,

Applied a variation of this here:
  http://llvm.org/viewvc/llvm-project?view=rev&revision=146706

Thanks!
 - Daniel

On Tue, Dec 13, 2011 at 8:42 AM, Johannes Obermayr
<johannesobermayr at gmx.de> wrote:
> $(llvm-config --libs | tr " " "\n" | grep gtest) returns:
> -lgtest_main
> -lgtest
>
> instead of non-valid:
> -lLLVMgtest_main
> -lLLVMgtest
>
> It also fixes:
> $(ld): cannot find -lLLVMgtest
> $(ld): cannot find -lLLVMgtest_main
> ---
>  unittests/Makefile.unittest                 |    2 +-
>  utils/llvm-build/llvmbuild/componentinfo.py |    4 ++--
>  utils/llvm-build/llvmbuild/main.py          |    5 ++++-
>  utils/unittest/UnitTestMain/Makefile        |    2 +-
>  utils/unittest/googletest/Makefile          |    2 +-
>  5 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/unittests/Makefile.unittest b/unittests/Makefile.unittest
> index 580ad7d..bd32aed 100644
> --- a/unittests/Makefile.unittest
> +++ b/unittests/Makefile.unittest
> @@ -34,7 +34,7 @@ ifneq ($(HAVE_PTHREAD), 1)
>   CPP.Flags += -DGTEST_HAS_PTHREAD=0
>  endif
>
> -TESTLIBS = -lGoogleTest -lUnitTestMain
> +TESTLIBS = -lgtest -lgtest_main
>
>  ifeq ($(ENABLE_SHARED), 1)
>   ifneq (,$(RPATH))
> diff --git a/utils/llvm-build/llvmbuild/componentinfo.py b/utils/llvm-build/llvmbuild/componentinfo.py
> index 230ae21..3aa1e86 100644
> --- a/utils/llvm-build/llvmbuild/componentinfo.py
> +++ b/utils/llvm-build/llvmbuild/componentinfo.py
> @@ -159,8 +159,8 @@ class LibraryComponentInfo(ComponentInfo):
>         # object, or something.
>         if basename in ('gtest', 'gtest_main'):
>             return basename
> -
> -        return 'LLVM%s' % basename
> +        else:
> +            return 'LLVM%s' % basename
>
>     def get_llvmconfig_component_name(self):
>         return self.get_library_name().lower()
> diff --git a/utils/llvm-build/llvmbuild/main.py b/utils/llvm-build/llvmbuild/main.py
> index 2d7db04..a81d8ce 100644
> --- a/utils/llvm-build/llvmbuild/main.py
> +++ b/utils/llvm-build/llvmbuild/main.py
> @@ -393,7 +393,10 @@ subdirectories = %s
>             else:
>                 # If we had a project level component, we could derive the
>                 # library prefix.
> -                library_name_as_cstr = '"libLLVM%s.a"' % library_name
> +                if library_name in ('gtest', 'gtest_main'):
> +                    library_name_as_cstr = '"lib%s.a"' % library_name
> +                else:
> +                    library_name_as_cstr = '"libLLVM%s.a"' % library_name
>             print >>f, '  { "%s", %s, { %s } },' % (
>                 name, library_name_as_cstr,
>                 ', '.join('"%s"' % dep
> diff --git a/utils/unittest/UnitTestMain/Makefile b/utils/unittest/UnitTestMain/Makefile
> index 3082779..7bcb724 100644
> --- a/utils/unittest/UnitTestMain/Makefile
> +++ b/utils/unittest/UnitTestMain/Makefile
> @@ -11,7 +11,7 @@ LEVEL = ../../..
>
>  include $(LEVEL)/Makefile.config
>
> -LIBRARYNAME = UnitTestMain
> +LIBRARYNAME = gtest_main
>  BUILD_ARCHIVE = 1
>  REQUIRES_RTTI = 1
>
> diff --git a/utils/unittest/googletest/Makefile b/utils/unittest/googletest/Makefile
> index 21b29ff..22c8f36 100644
> --- a/utils/unittest/googletest/Makefile
> +++ b/utils/unittest/googletest/Makefile
> @@ -11,7 +11,7 @@ LEVEL := ../../..
>
>  include $(LEVEL)/Makefile.config
>
> -LIBRARYNAME = GoogleTest
> +LIBRARYNAME = gtest
>  BUILD_ARCHIVE = 1
>  REQUIRES_RTTI = 1
>
> --
> 1.7.7
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list