This is an archive of the discontinued LLVM Phabricator instance.

Add install targets for gtest
ClosedPublic

Authored by tstellar on Nov 12 2022, 3:30 AM.

Details

Summary

Stand-alone builds need an installed version of gtest in order to run
the unittests.

Diff Detail

Event Timeline

tstellar created this revision.Nov 12 2022, 3:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 12 2022, 3:30 AM
tstellar requested review of this revision.Nov 12 2022, 3:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 12 2022, 3:30 AM
kwk added a subscriber: kwk.Nov 14 2022, 6:23 AM

I'll try to test this today. I suppose the main idea would be to enable LLVM_INSTALL_GTEST, then stop unpacking third-party directory when building other packages, correct? Perhaps it would make sense to update the checks like the one in clang while doing that:

if( CLANG_INCLUDE_TESTS )
  if(EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest/googletest/include/gtest/gtest.h)
    add_subdirectory(unittests)
    ...

Plus there's the matter of LLVMTestingSupport library.

I'll try to test this today. I suppose the main idea would be to enable LLVM_INSTALL_GTEST, then stop unpacking third-party directory when building other packages, correct? Perhaps it would make sense to update the checks like the one in clang while doing that:

if( CLANG_INCLUDE_TESTS )
  if(EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest/googletest/include/gtest/gtest.h)
    add_subdirectory(unittests)
    ...

I submitted the clang patch here: D138472

mgorny added inline comments.Nov 22 2022, 5:15 AM
third-party/unittest/CMakeLists.txt
81

Any reason you think this should be installed separately rather than included in the usual LLVM export list? I think the latter would make it more consistent to use in in-tree vs standalone builds (as you wouldn't have to find_package it).

tstellar added inline comments.Nov 22 2022, 8:43 AM
third-party/unittest/CMakeLists.txt
81

The problem with having it in the main export list is that it then it would have to be present on disk for users to be able to load LLVMConfig.cmake.

81

I was just trying to make the patch more self-contained, so it wouldn't risk breaking other build configurations, but I can add it into the main export list if you think that's better.

mgorny added inline comments.Nov 22 2022, 9:08 AM
third-party/unittest/CMakeLists.txt
81

I suppose you're thinking of packaging it separate from llvm-devel then? If not, then I think it'd be better to keep it simple and include it in main exports. After all, most users simply won't enable the option to install it, so shouldn't be affected.

kwk accepted this revision.Jan 25 2023, 8:50 AM

Works for me.

This revision is now accepted and ready to land.Jan 25 2023, 8:50 AM
tstellar updated this revision to Diff 501039.Feb 27 2023, 11:34 PM
tstellar marked an inline comment as not done.

Add exports to LLVMExports.cmake instead of a separate file.

tstellar marked an inline comment as done.Feb 28 2023, 11:08 AM
tstellar added inline comments.
third-party/unittest/CMakeLists.txt
81

v

mgorny accepted this revision.Mar 10 2023, 11:15 AM

I think it's good.

llvm/lib/Testing/Annotations/CMakeLists.txt
4 ↗(On Diff #501039)

Missing indent?

This revision was landed with ongoing or failed builds.Mar 10 2023, 5:29 PM
This revision was automatically updated to reflect the committed changes.

First observation: third-party/unittest/UnitTestMain/CMakeLists.txt still has BUILDTREE_ONLY which makes it impossible to use this with LLVM_DISTRIBUTION_COMPONENTS. Could you adjust that as well?