blob: c695069e64e441c7a85d160bd0c458556372d167 [file] [log] [blame]
Louis Dionneea285d12021-07-07 09:45:26 -04001include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
Dan Albertdb7f9a32014-07-10 02:20:11 +00002macro(pythonize_bool var)
3 if (${var})
4 set(${var} True)
5 else()
6 set(${var} False)
7 endif()
8endmacro()
9
Ben Craig1d74ace2016-04-19 12:47:38 +000010if (NOT DEFINED LIBCXX_ENABLE_SHARED)
11 set(LIBCXX_ENABLE_SHARED ON)
12endif()
13
Sergej Jaskiewiczbe4c4392020-01-30 13:05:14 +030014option(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI
15 "Whether the libc++abi tests should link with the shared libc++abi library"
16 ${LIBCXXABI_ENABLE_SHARED})
17
18option(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX
19 "Whether the libc++abi tests should link with the shared libc++ library"
20 ${LIBCXX_ENABLE_SHARED})
21
22if(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")
24endif()
25
26if(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")
28endif()
29
30if(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")
32endif()
33
34if(DEFINED LIBCXX_ENABLE_STATIC
Louis Dionne50723352020-06-11 15:41:38 -040035 AND NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX
Sergej Jaskiewiczbe4c4392020-01-30 13:05:14 +030036 AND NOT LIBCXX_ENABLE_STATIC)
37 message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX being OFF requires LIBCXX_ENABLE_STATIC to be ON")
38endif()
39
Ben Craig1d74ace2016-04-19 12:47:38 +000040pythonize_bool(LIBCXX_ENABLE_SHARED)
Dan Albertdb7f9a32014-07-10 02:20:11 +000041pythonize_bool(LIBCXXABI_ENABLE_SHARED)
Eric Fiselier797d39b2014-11-24 22:42:03 +000042pythonize_bool(LIBCXXABI_ENABLE_THREADS)
Dan Albert37bd6572014-07-11 15:36:02 +000043pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
Petr Hosek8a650ce2019-02-05 04:44:03 +000044pythonize_bool(LIBCXXABI_USE_COMPILER_RT)
Asiri Rathnayake0a33e542017-01-09 11:57:21 +000045pythonize_bool(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
Louis Dionne4d0e0b92019-08-08 12:43:20 +000046pythonize_bool(LIBCXX_ENABLE_PARALLEL_ALGORITHMS)
Sergej Jaskiewiczb2007fd2019-12-26 12:28:39 +030047pythonize_bool(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX)
48pythonize_bool(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI)
Jonathan Roelofsc09886b2015-02-26 15:55:01 +000049set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
50 "TargetInfo to use when setting up test environment.")
Louis Dionne50723352020-06-11 15:41:38 -040051set(LIBCXXABI_EXECUTOR "${Python3_EXECUTABLE} ${LIBCXXABI_LIBCXX_PATH}/utils/run.py" CACHE STRING
Jonathan Roelofsc09886b2015-02-26 15:55:01 +000052 "Executor to use when running tests.")
Dan Albertdb7f9a32014-07-10 02:20:11 +000053
Ben Craig1d74ace2016-04-19 12:47:38 +000054if (LIBCXXABI_ENABLE_SHARED)
55 set(LIBCXXABI_TEST_DEPS cxxabi_shared)
56else()
57 set(LIBCXXABI_TEST_DEPS cxxabi_static)
58endif()
59
Asiri Rathnayake0a33e542017-01-09 11:57:21 +000060if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
Asiri Rathnayakefb90fce2017-01-03 12:58:34 +000061 list(APPEND LIBCXXABI_TEST_DEPS cxx_external_threads)
62endif()
63
Eric Fiselier0f872292016-08-28 18:16:18 +000064if (NOT LIBCXXABI_STANDALONE_BUILD)
Dan Albertdb7f9a32014-07-10 02:20:11 +000065 list(APPEND LIBCXXABI_TEST_DEPS cxx)
Michał Górny45e01f52022-02-11 12:48:31 +010066 if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
Petr Hoseka969d232016-08-08 22:09:54 +000067 list(APPEND LIBCXXABI_TEST_DEPS unwind)
68 endif()
Dan Albert37bd6572014-07-11 15:36:02 +000069endif()
70
Louis Dionne8b9ef2a2020-06-25 11:46:00 -040071set(AUTO_GEN_COMMENT "## Autogenerated by libcxxabi configuration.\n# Do not edit!")
Louis Dionneaf541702021-06-01 17:16:11 -040072set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
73
74macro(serialize_lit_param param value)
75 string(APPEND SERIALIZED_LIT_PARAMS "config.${param} = ${value}\n")
76endmacro()
77
78if (NOT LIBCXXABI_ENABLE_EXCEPTIONS)
79 serialize_lit_param(enable_exceptions False)
80endif()
81
Louis Dionnef26979f2022-03-28 13:10:14 -040082if (LIBCXXABI_ENABLE_ASSERTIONS)
83 serialize_lit_param(enable_assertions True)
84endif()
85
Louis Dionneaf541702021-06-01 17:16:11 -040086serialize_lit_param(enable_experimental False)
87
88if (LLVM_USE_SANITIZER)
89 serialize_lit_param(use_sanitizer "\"${LLVM_USE_SANITIZER}\"")
90endif()
91
Louis Dionne4642f462021-10-12 15:59:08 -040092if (CMAKE_CXX_COMPILER_TARGET)
93 serialize_lit_param(target_triple "\"${CMAKE_CXX_COMPILER_TARGET}\"")
94else()
95 serialize_lit_param(target_triple "\"${LLVM_DEFAULT_TARGET_TRIPLE}\"")
Louis Dionneaf541702021-06-01 17:16:11 -040096endif()
97
Louis Dionnef96e8532021-07-14 11:36:22 -040098foreach(param IN LISTS LIBCXXABI_TEST_PARAMS)
99 string(REGEX REPLACE "(.+)=(.+)" "\\1" name "${param}")
100 string(REGEX REPLACE "(.+)=(.+)" "\\2" value "${param}")
101 serialize_lit_param("${name}" "\"${value}\"")
102endforeach()
103
Louis Dionne58f39ec2021-10-12 17:45:45 -0400104configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
105 "${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
106 @ONLY)
107
Eric Fiselierc919c882018-01-17 22:07:09 +0000108configure_lit_site_cfg(
Louis Dionne8b9ef2a2020-06-25 11:46:00 -0400109 "${LIBCXXABI_TEST_CONFIG}"
110 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
111 MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py")
Eric Fiselierc919c882018-01-17 22:07:09 +0000112
Petr Hosek71c873b2021-03-03 22:40:11 -0800113add_lit_testsuite(check-cxxabi "Running libcxxabi tests"
Dan Albertdb7f9a32014-07-10 02:20:11 +0000114 ${CMAKE_CURRENT_BINARY_DIR}
Louis Dionnef96e8532021-07-14 11:36:22 -0400115 DEPENDS ${LIBCXXABI_TEST_DEPS})