1 include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
2 macro(pythonize_bool var)
10 if (NOT DEFINED LIBCXX_ENABLE_SHARED)
11 set(LIBCXX_ENABLE_SHARED ON)
14 option(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI
15 "Whether the libc++abi tests should link with the shared libc++abi library"
16 ${LIBCXXABI_ENABLE_SHARED})
18 option(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX
19 "Whether the libc++abi tests should link with the shared libc++ library"
20 ${LIBCXX_ENABLE_SHARED})
22 if(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI AND NOT LIBCXXABI_ENABLE_SHARED)
23 message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI being ON requires LIBCXXABI_ENABLE_SHARED to be ON")
26 if(NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI AND NOT LIBCXXABI_ENABLE_STATIC)
27 message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI being OFF requires LIBCXXABI_ENABLE_STATIC to be ON")
30 if(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX AND NOT LIBCXX_ENABLE_SHARED)
31 message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX being ON requires LIBCXX_ENABLE_SHARED to be ON")
34 if(DEFINED LIBCXX_ENABLE_STATIC
35 AND NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX
36 AND NOT LIBCXX_ENABLE_STATIC)
37 message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX being OFF requires LIBCXX_ENABLE_STATIC to be ON")
40 pythonize_bool(LIBCXX_ENABLE_SHARED)
41 pythonize_bool(LIBCXXABI_ENABLE_SHARED)
42 pythonize_bool(LIBCXXABI_ENABLE_THREADS)
43 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
44 pythonize_bool(LIBCXXABI_USE_COMPILER_RT)
45 pythonize_bool(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
46 pythonize_bool(LIBCXX_ENABLE_PARALLEL_ALGORITHMS)
47 pythonize_bool(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX)
48 pythonize_bool(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI)
49 set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
50 "TargetInfo to use when setting up test environment.")
51 set(LIBCXXABI_EXECUTOR "${Python3_EXECUTABLE} ${LIBCXXABI_LIBCXX_PATH}/utils/run.py" CACHE STRING
52 "Executor to use when running tests.")
54 if (LIBCXXABI_ENABLE_SHARED)
55 set(LIBCXXABI_TEST_DEPS cxxabi_shared)
57 set(LIBCXXABI_TEST_DEPS cxxabi_static)
60 if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
61 list(APPEND LIBCXXABI_TEST_DEPS cxx_external_threads)
64 list(APPEND LIBCXXABI_TEST_DEPS cxx)
65 if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
66 list(APPEND LIBCXXABI_TEST_DEPS unwind)
69 set(AUTO_GEN_COMMENT "## Autogenerated by libcxxabi configuration.\n# Do not edit!")
70 set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
72 macro(serialize_lit_param param value)
73 string(APPEND SERIALIZED_LIT_PARAMS "config.${param} = ${value}\n")
76 if (NOT LIBCXXABI_ENABLE_EXCEPTIONS)
77 serialize_lit_param(enable_exceptions False)
80 if (LIBCXXABI_ENABLE_ASSERTIONS)
81 serialize_lit_param(enable_assertions True)
84 serialize_lit_param(enable_experimental False)
86 if (LLVM_USE_SANITIZER)
87 serialize_lit_param(use_sanitizer "\"${LLVM_USE_SANITIZER}\"")
90 if (CMAKE_CXX_COMPILER_TARGET)
91 serialize_lit_param(target_triple "\"${CMAKE_CXX_COMPILER_TARGET}\"")
93 serialize_lit_param(target_triple "\"${LLVM_DEFAULT_TARGET_TRIPLE}\"")
96 foreach(param IN LISTS LIBCXXABI_TEST_PARAMS)
97 string(REGEX REPLACE "(.+)=(.+)" "\\1" name "${param}")
98 string(REGEX REPLACE "(.+)=(.+)" "\\2" value "${param}")
99 serialize_lit_param("${name}" "\"${value}\"")
102 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
103 "${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
106 configure_lit_site_cfg(
107 "${LIBCXXABI_TEST_CONFIG}"
108 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
109 MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py")
111 add_lit_testsuite(check-cxxabi "Running libcxxabi tests"
112 ${CMAKE_CURRENT_BINARY_DIR}
113 DEPENDS ${LIBCXXABI_TEST_DEPS})