[llvm] [cmake] Set EXCLUDE_FROM_ALL on gtest and TestingSupport

Exclude building googletest and LLVMTestingSupport libraries from
the `all` target.  If unittests are being built, these libraries will
be built as a dependency anyway.  If they are not being built, building
them makes little sense as they are not installed or used otherwise.

This will also make standalone builds of other projects easier, as it
makes it possible to include these directories without having to cover
them with additional conditions to prevent them from being built
unconditionally.

Differential Revision: https://reviews.llvm.org/D137035
This commit is contained in:
Michał Górny 2022-10-30 07:37:15 +01:00
parent 194ab73a41
commit a6eb76f57c
2 changed files with 8 additions and 0 deletions

View File

@ -1,3 +1,7 @@
# Do not build unittest libraries automatically, they will be pulled in
# by unittests if these are built.
set(EXCLUDE_FROM_ALL ON)
add_llvm_library(LLVMTestingSupport add_llvm_library(LLVMTestingSupport
Annotations.cpp Annotations.cpp
Error.cpp Error.cpp

View File

@ -38,6 +38,10 @@ if (HAVE_LIBPTHREAD)
list(APPEND LIBS pthread) list(APPEND LIBS pthread)
endif() endif()
# Do not build unittest libraries automatically, they will be pulled in
# by unittests if these are built.
set(EXCLUDE_FROM_ALL ON)
add_llvm_library(llvm_gtest add_llvm_library(llvm_gtest
googletest/src/gtest-all.cc googletest/src/gtest-all.cc
googlemock/src/gmock-all.cc googlemock/src/gmock-all.cc