aboutsummaryrefslogtreecommitdiffstats
path: root/test/CMakeLists.txt
blob: 7b8a8322a11fef767ed76d6ca5a4aa007d6941e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
macro(pythonize_bool var)
  if (${var})
    set(${var} True)
  else()
    set(${var} False)
  endif()
endmacro()

set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING
    "Configuration variant to use for LIT.")

# The tests shouldn't link to any ABI library when it has been linked into
# libc++ statically or via a linker script.
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY OR LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
  set(LIBCXX_CXX_ABI_LIBNAME "none")
endif()

# The tests shouldn't link to libunwind if we have a linker script which
# already does so.
if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
  set(LIBCXXABI_USE_LLVM_UNWINDER OFF)
endif()

pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
pythonize_bool(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
pythonize_bool(LIBCXX_ENABLE_FILESYSTEM)
pythonize_bool(LIBCXX_ENABLE_RTTI)
pythonize_bool(LIBCXX_ENABLE_SHARED)
pythonize_bool(LIBCXX_BUILD_32_BITS)
pythonize_bool(LIBCXX_GENERATE_COVERAGE)
pythonize_bool(LIBCXXABI_ENABLE_SHARED)
pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
pythonize_bool(LIBCXX_HAS_ATOMIC_LIB)
pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB)
pythonize_bool(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
pythonize_bool(LIBCXX_DEBUG_BUILD)

# By default, for non-standalone builds, libcxx and libcxxabi share a library
# directory.
if (NOT LIBCXX_CXX_ABI_LIBRARY_PATH)
  set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_LIBRARY_DIR}" CACHE PATH
      "The path to libc++abi library.")
endif()

set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
    "TargetInfo to use when setting up test environment.")
set(LIBCXX_EXECUTOR "None" CACHE STRING
    "Executor to use when running tests.")

set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")

configure_file(
  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
  @ONLY)

set(LIBCXX_TEST_DEPS "")

if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
  set(LIBCXX_TEST_DEPS cxx_experimental)
endif()

if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
  list(APPEND LIBCXX_TEST_DEPS cxx_external_threads)
endif()

if (LIBCXX_INCLUDE_TESTS)
  include(AddLLVM) # for add_lit_testsuite
  add_lit_testsuite(check-cxx
    "Running libcxx tests"
    ${CMAKE_CURRENT_BINARY_DIR}
    DEPENDS cxx ${LIBCXX_TEST_DEPS})

  add_custom_target(check-libcxx DEPENDS check-cxx)
endif()

if (LIBCXX_GENERATE_COVERAGE)
  include(CodeCoverage)
  set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage")
  set(capture_dirs
      "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_objects.dir/"
      "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/"
      "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/"
      "${CMAKE_CURRENT_BINARY_DIR}")
  set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src")
  setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}")
endif()


if (LIBCXX_CONFIGURE_IDE)
  # Create dummy targets for each of the tests in the test suite, this allows
  # IDE's such as CLion to correctly highlight the tests because it knows
  # roughly what include paths/compile flags/macro definitions are needed.
  include_directories(support)
  file(GLOB_RECURSE LIBCXX_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/*.pass.cpp)
  file(GLOB LIBCXX_TEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/support/*)
  file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
  add_executable(libcxx_test_objects EXCLUDE_FROM_ALL
          ${LIBCXX_TESTS} ${LIBCXX_TEST_HEADERS} ${LIBCXX_HEADERS})
  add_dependencies(libcxx_test_objects cxx)

  set(STATIC_ROOT ${LIBCXX_SOURCE_DIR}/test/std/experimental/filesystem/Inputs/static_test_env)
  add_definitions(-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="${STATIC_ROOT}")

  set(DYNAMIC_ROOT ${LIBCXX_BINARY_DIR}/test/filesystem/Output/dynamic_env)
  add_definitions(-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="${DYNAMIC_ROOT}")

  set(DYNAMIC_HELPER "python ${LIBCXX_SOURCE_DIR}/test/support/filesystem_dynamic_test_helper.py ")
  add_definitions(-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="${DYNAMIC_HELPER}")

  split_list(LIBCXX_COMPILE_FLAGS)
  split_list(LIBCXX_LINK_FLAGS)

  set_target_properties(libcxx_test_objects
          PROPERTIES
            COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
            LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
            EXCLUDE_FROM_ALL ON
  )
endif()