brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.5 KiB · 54c781a Raw
133 lines · plain
1add_custom_target(ClangUnitTests)2set_target_properties(ClangUnitTests PROPERTIES FOLDER "Clang/Tests")3 4if(CLANG_BUILT_STANDALONE)5  # LLVMTesting* libraries are needed for some of the unittests.6  if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Annotations7      AND NOT TARGET LLVMTestingAnnotations)8    add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Annotations9      lib/Testing/Annotations)10  endif()11  if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support12      AND NOT TARGET LLVMTestingSupport)13    add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support14      lib/Testing/Support)15  endif()16endif()17 18# add_distinct_clang_unittest(test_name file1.cpp file2.cpp)19#20# Will compile the list of files together and link against the clang21# Produces a binary named 'basename(test_name)'.22function(add_distinct_clang_unittest test_name)23  cmake_parse_arguments(ARG24    ""25    ""26    "CLANG_LIBS;LINK_LIBS;LLVM_COMPONENTS"27    ${ARGN})28 29  if (NOT ${test_name} MATCHES "Tests$")30    message(FATAL_ERROR "Unit test name must end with 'Tests' for lit to find it.")31  endif()32 33  # LLVM_COMPONENTS is for LLVM_LINK_COMPONENTS deps, and must be before34  # add_unittest.35  list(APPEND LLVM_LINK_COMPONENTS ${ARG_LLVM_COMPONENTS})36 37  add_unittest(ClangUnitTests ${test_name} ${ARG_UNPARSED_ARGUMENTS})38 39  # Clang libs either come from the entire dylib, or individual libraries.40  if (CLANG_LINK_CLANG_DYLIB)41    list(APPEND ARG_LINK_LIBS clang-cpp)42  else()43    list(APPEND ARG_LINK_LIBS ${ARG_CLANG_LIBS})44  endif()45 46  # LINK_LIBS is for normal library dependencies.47  target_link_libraries(${test_name} PRIVATE ${ARG_LINK_LIBS})48endfunction()49 50set(doc_opts BRIEF_DOCS "<internal setting>" FULL_DOCS "<internal settings>")51define_property(GLOBAL PROPERTY CLANG_UNITTEST_SRCS ${doc_opts})52define_property(GLOBAL PROPERTY CLANG_UNITTEST_LLVM_COMPONENTS ${doc_opts})53define_property(GLOBAL PROPERTY CLANG_UNITTEST_CLANG_LIBS ${doc_opts})54define_property(GLOBAL PROPERTY CLANG_UNITTEST_LINK_LIBS ${doc_opts})55 56# add_clang_unittest(test_name file1.cpp file2.cpp)57#58# Adds unittests to the combined AllClangUnitTests binary. The unittest binary59# is defined after adding all unittest subdirectories.60function(add_clang_unittest test_name)61  cmake_parse_arguments(ARG62    ""63    ""64    "CLANG_LIBS;LINK_LIBS;LLVM_COMPONENTS"65    ${ARGN})66 67  file(RELATIVE_PATH src_prefix "${CMAKE_CURRENT_FUNCTION_LIST_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")68  set(srcs_prefixed)69  foreach(src ${ARG_UNPARSED_ARGUMENTS})70    set(srcs_prefixed ${srcs_prefixed} "${src_prefix}/${src}")71  endforeach()72  set_property(GLOBAL APPEND PROPERTY CLANG_UNITTEST_SRCS ${srcs_prefixed})73  set_property(GLOBAL APPEND PROPERTY CLANG_UNITTEST_CLANG_LIBS ${ARG_CLANG_LIBS})74  set_property(GLOBAL APPEND PROPERTY CLANG_UNITTEST_LINK_LIBS ${ARG_LINK_LIBS})75  set_property(GLOBAL APPEND PROPERTY CLANG_UNITTEST_LLVM_COMPONENTS ${ARG_LLVM_COMPONENTS})76endfunction()77 78add_subdirectory(Basic)79add_subdirectory(Lex)80add_subdirectory(Parse)81add_subdirectory(Driver)82if(CLANG_ENABLE_STATIC_ANALYZER)83  add_subdirectory(Analysis)84  add_subdirectory(StaticAnalyzer)85endif()86add_subdirectory(ASTMatchers)87add_subdirectory(AST)88add_subdirectory(CrossTU)89add_subdirectory(Tooling)90add_subdirectory(Format)91add_subdirectory(Frontend)92add_subdirectory(Rewrite)93add_subdirectory(Sema)94add_subdirectory(CodeGen)95if(HAVE_CLANG_REPL_SUPPORT)96  add_subdirectory(Interpreter)97endif()98# FIXME: libclang unit tests are disabled on Windows due99# to failures, mostly in libclang.VirtualFileOverlay_*.100if(NOT WIN32 AND CLANG_TOOL_LIBCLANG_BUILD) 101  add_subdirectory(libclang)102endif()103add_subdirectory(DirectoryWatcher)104add_subdirectory(Index)105add_subdirectory(InstallAPI)106add_subdirectory(Serialization)107add_subdirectory(Support)108if (CLANG_ENABLE_CIR)109  add_subdirectory(CIR)110endif()111 112# If we're doing a single merged clang unit test binary, add that target after113# all the previous subdirectories have been processed.114get_property(SRCS GLOBAL PROPERTY CLANG_UNITTEST_SRCS)115get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_UNITTEST_CLANG_LIBS)116get_property(LINK_LIBS GLOBAL PROPERTY CLANG_UNITTEST_LINK_LIBS)117get_property(LLVM_COMPONENTS GLOBAL PROPERTY CLANG_UNITTEST_LLVM_COMPONENTS)118add_distinct_clang_unittest(AllClangUnitTests119  ${SRCS}120  AllClangUnitTests.cpp121  CLANG_LIBS122  ${CLANG_LIBS}123  LINK_LIBS124  ${LINK_LIBS}125  LLVM_COMPONENTS126  ${LLVM_COMPONENTS}127)128 129# The Tooling library has some internal headers. Make those work. If we like130# the merged clang unit test binary, we can update the include paths and make131# this the default.132include_directories(Tooling)133