diff options
author | Tom Stellard <tstellar@redhat.com> | 2023-03-10 17:22:14 -0800 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2023-03-10 17:22:33 -0800 |
commit | 0807986303f5d498cee32d42c242940d00617ad9 (patch) | |
tree | 03d9c9486e933f02c720bbfb50f1ed107c5b55d4 /third-party | |
parent | 7c3c981442b11153ac1a2be678db727ff715253b (diff) | |
download | llvm-0807986303f5d498cee32d42c242940d00617ad9.zip llvm-0807986303f5d498cee32d42c242940d00617ad9.tar.gz llvm-0807986303f5d498cee32d42c242940d00617ad9.tar.bz2 |
Add install targets for gtest
Stand-alone builds need an installed version of gtest in order to run
the unittests.
Reviewed By: mgorny, kwk
Differential Revision: https://reviews.llvm.org/D137890
Diffstat (limited to 'third-party')
-rw-r--r-- | third-party/unittest/CMakeLists.txt | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/third-party/unittest/CMakeLists.txt b/third-party/unittest/CMakeLists.txt index 302e9e0..74a523b 100644 --- a/third-party/unittest/CMakeLists.txt +++ b/third-party/unittest/CMakeLists.txt @@ -40,7 +40,13 @@ endif() # Do not build unittest libraries automatically, they will be pulled in # by unittests if these are built. + +set(BUILDTREE_ONLY BUILDTREE_ONLY) set(EXCLUDE_FROM_ALL ON) +if (LLVM_INSTALL_GTEST) + set(EXCLUDE_FROM_ALL OFF) + set(BUILDTREE_ONLY "") +endif () add_llvm_library(llvm_gtest googletest/src/gtest-all.cc @@ -53,7 +59,7 @@ add_llvm_library(llvm_gtest Support # Depends on llvm::raw_ostream # This is a library meant only for the build tree. - BUILDTREE_ONLY + ${BUILDTREE_ONLY} ) # The googletest and googlemock sources don't presently use the 'override' @@ -69,12 +75,22 @@ if (NOT LLVM_ENABLE_THREADS) endif () target_include_directories(llvm_gtest - PUBLIC googletest/include googlemock/include + PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/googletest/include> + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/googlemock/include> + $<INSTALL_INTERFACE:include/llvm-gtest/> + $<INSTALL_INTERFACE:include/llvm-gmock/> PRIVATE googletest googlemock ) add_subdirectory(UnitTestMain) +if (LLVM_INSTALL_GTEST) + install(TARGETS llvm_gtest llvm_gtest_main LLVMTestingSupport LLVMTestingAnnotations + ARCHIVE DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT llvm_gtest) + install(DIRECTORY googletest/include/gtest/ DESTINATION include/llvm-gtest/gtest/ COMPONENT llvm_gtest) + install(DIRECTORY googlemock/include/gmock/ DESTINATION include/llvm-gmock/gmock/ COMPONENT llvm_gtest) +endif() + # When LLVM_LINK_LLVM_DYLIB is enabled, libLLVM.so is added to the interface # link libraries for gtest and gtest_main. This means that any target, like # unittests for example, that links against gtest will be forced to link |