1 add_subdirectory(tools)
3 # By default, libcxx and libcxxabi share a library directory.
4 if (NOT LIBCXX_CXX_ABI_LIBRARY_PATH)
5 set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_LIBRARY_DIR}" CACHE PATH
6 "The path to libc++abi library.")
9 set(LIBCXX_EXECUTOR "\\\"${Python3_EXECUTABLE}\\\" ${CMAKE_CURRENT_LIST_DIR}/../utils/run.py" CACHE STRING
10 "Executor to use when running tests.")
12 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
13 set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
15 macro(serialize_lit_param param value)
16 string(APPEND SERIALIZED_LIT_PARAMS "config.${param} = ${value}\n")
19 if (NOT LIBCXX_ENABLE_EXCEPTIONS)
20 serialize_lit_param(enable_exceptions False)
23 if (NOT LIBCXX_ENABLE_RTTI)
24 serialize_lit_param(enable_rtti False)
27 if (LIBCXX_ENABLE_ASSERTIONS)
28 serialize_lit_param(enable_assertions True)
31 if (CMAKE_CXX_COMPILER_TARGET)
32 serialize_lit_param(target_triple "\"${CMAKE_CXX_COMPILER_TARGET}\"")
34 serialize_lit_param(target_triple "\"${LLVM_DEFAULT_TARGET_TRIPLE}\"")
37 if (LLVM_USE_SANITIZER)
38 serialize_lit_param(use_sanitizer "\"${LLVM_USE_SANITIZER}\"")
41 foreach(param IN LISTS LIBCXX_TEST_PARAMS)
42 string(REGEX REPLACE "(.+)=(.+)" "\\1" name "${param}")
43 string(REGEX REPLACE "(.+)=(.+)" "\\2" value "${param}")
44 serialize_lit_param("${name}" "\"${value}\"")
47 if (NOT DEFINED LIBCXX_TEST_DEPS)
48 message(FATAL_ERROR "Expected LIBCXX_TEST_DEPS to be defined")
51 if (LIBCXX_INCLUDE_TESTS)
52 include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
54 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
55 "${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
58 configure_lit_site_cfg(
59 "${LIBCXX_TEST_CONFIG}"
60 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
61 MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py")
63 add_custom_target(cxx-test-depends
64 DEPENDS cxx ${LIBCXX_TEST_DEPS}
65 COMMENT "Builds dependencies required to run the test suite.")
67 add_lit_testsuite(check-cxx
68 "Running libcxx tests"
69 ${CMAKE_CURRENT_BINARY_DIR}
70 DEPENDS cxx-test-depends)
73 if (LIBCXX_GENERATE_COVERAGE)
75 set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage")
77 "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_objects.dir/"
78 "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/"
79 "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/"
80 "${CMAKE_CURRENT_BINARY_DIR}")
81 set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src")
82 setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}")
85 if (LIBCXX_CONFIGURE_IDE)
86 # Create dummy targets for each of the tests in the test suite, this allows
87 # IDE's such as CLion to correctly highlight the tests because it knows
88 # roughly what include paths/compile flags/macro definitions are needed.
89 include_directories(support)
90 file(GLOB_RECURSE LIBCXX_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/*.pass.cpp)
91 file(GLOB LIBCXX_TEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/support/*)
92 file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
93 add_executable(libcxx_test_objects EXCLUDE_FROM_ALL
94 ${LIBCXX_TESTS} ${LIBCXX_TEST_HEADERS} ${LIBCXX_HEADERS})
95 add_dependencies(libcxx_test_objects cxx)
97 split_list(LIBCXX_COMPILE_FLAGS)
98 split_list(LIBCXX_LINK_FLAGS)
100 set_target_properties(libcxx_test_objects
102 COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
103 LINK_FLAGS "${LIBCXX_LINK_FLAGS}"