Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ option(CLANG_INCLUDE_TESTS
"Generate build targets for the Clang unit tests."
${LLVM_INCLUDE_TESTS})

option(CLANG_UNITTEST_SINGLE_BINARY
"Combine most Clang unit tests into a single binary."
ON)

option(CLANG_ENABLE_HLSL "Include HLSL build products" Off)
# While HLSL support is experimental this should stay hidden.
mark_as_advanced(CLANG_ENABLE_HLSL)
Expand Down
39 changes: 23 additions & 16 deletions clang/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ define_property(GLOBAL PROPERTY CLANG_UNITTEST_LINK_LIBS ${doc_opts})
# Adds unittests to the combined AllClangUnitTests binary. The unittest binary
# is defined after adding all unittest subdirectories.
function(add_clang_unittest test_name)
if (NOT CLANG_UNITTEST_SINGLE_BINARY)
add_distinct_clang_unittest(${ARGV})
return()
endif()

cmake_parse_arguments(ARG
""
""
Expand Down Expand Up @@ -110,22 +115,24 @@ if (CLANG_ENABLE_CIR)
add_subdirectory(CIR)
endif()

# If we're doing a single merged clang unit test binary, add that target after
# all the previous subdirectories have been processed.
get_property(SRCS GLOBAL PROPERTY CLANG_UNITTEST_SRCS)
get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_UNITTEST_CLANG_LIBS)
get_property(LINK_LIBS GLOBAL PROPERTY CLANG_UNITTEST_LINK_LIBS)
get_property(LLVM_COMPONENTS GLOBAL PROPERTY CLANG_UNITTEST_LLVM_COMPONENTS)
add_distinct_clang_unittest(AllClangUnitTests
${SRCS}
AllClangUnitTests.cpp
CLANG_LIBS
${CLANG_LIBS}
LINK_LIBS
${LINK_LIBS}
LLVM_COMPONENTS
${LLVM_COMPONENTS}
)
if (CLANG_UNITTEST_SINGLE_BINARY)
# If we're doing a single merged clang unit test binary, add that target after
# all the previous subdirectories have been processed.
get_property(SRCS GLOBAL PROPERTY CLANG_UNITTEST_SRCS)
get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_UNITTEST_CLANG_LIBS)
get_property(LINK_LIBS GLOBAL PROPERTY CLANG_UNITTEST_LINK_LIBS)
get_property(LLVM_COMPONENTS GLOBAL PROPERTY CLANG_UNITTEST_LLVM_COMPONENTS)
add_distinct_clang_unittest(AllClangUnitTests
${SRCS}
AllClangUnitTests.cpp
CLANG_LIBS
${CLANG_LIBS}
LINK_LIBS
${LINK_LIBS}
LLVM_COMPONENTS
${LLVM_COMPONENTS}
)
endif()

# The Tooling library has some internal headers. Make those work. If we like
# the merged clang unit test binary, we can update the include paths and make
Expand Down
1 change: 1 addition & 0 deletions clang/unittests/Frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ add_clang_unittest(FrontendTests
clangSerialization
clangTooling
LLVM_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
Support
TargetParser
)