Louis Dionne | ea285d1 | 2021-07-07 09:45:26 -0400 | [diff] [blame] | 1 | include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite |
Dan Albert | db7f9a3 | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 2 | macro(pythonize_bool var) |
| 3 | if (${var}) |
| 4 | set(${var} True) |
| 5 | else() |
| 6 | set(${var} False) |
| 7 | endif() |
| 8 | endmacro() |
| 9 | |
Ben Craig | 1d74ace | 2016-04-19 12:47:38 +0000 | [diff] [blame] | 10 | if (NOT DEFINED LIBCXX_ENABLE_SHARED) |
| 11 | set(LIBCXX_ENABLE_SHARED ON) |
| 12 | endif() |
| 13 | |
Sergej Jaskiewicz | be4c439 | 2020-01-30 13:05:14 +0300 | [diff] [blame] | 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}) |
| 17 | |
| 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}) |
| 21 | |
| 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") |
| 24 | endif() |
| 25 | |
| 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") |
| 28 | endif() |
| 29 | |
| 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") |
| 32 | endif() |
| 33 | |
| 34 | if(DEFINED LIBCXX_ENABLE_STATIC |
Louis Dionne | 5072335 | 2020-06-11 15:41:38 -0400 | [diff] [blame] | 35 | AND NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX |
Sergej Jaskiewicz | be4c439 | 2020-01-30 13:05:14 +0300 | [diff] [blame] | 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") |
| 38 | endif() |
| 39 | |
Ben Craig | 1d74ace | 2016-04-19 12:47:38 +0000 | [diff] [blame] | 40 | pythonize_bool(LIBCXX_ENABLE_SHARED) |
Dan Albert | db7f9a3 | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 41 | pythonize_bool(LIBCXXABI_ENABLE_SHARED) |
Eric Fiselier | 797d39b | 2014-11-24 22:42:03 +0000 | [diff] [blame] | 42 | pythonize_bool(LIBCXXABI_ENABLE_THREADS) |
Dan Albert | 37bd657 | 2014-07-11 15:36:02 +0000 | [diff] [blame] | 43 | pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER) |
Petr Hosek | 8a650ce | 2019-02-05 04:44:03 +0000 | [diff] [blame] | 44 | pythonize_bool(LIBCXXABI_USE_COMPILER_RT) |
Asiri Rathnayake | 0a33e54 | 2017-01-09 11:57:21 +0000 | [diff] [blame] | 45 | pythonize_bool(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY) |
Louis Dionne | 4d0e0b9 | 2019-08-08 12:43:20 +0000 | [diff] [blame] | 46 | pythonize_bool(LIBCXX_ENABLE_PARALLEL_ALGORITHMS) |
Sergej Jaskiewicz | b2007fd | 2019-12-26 12:28:39 +0300 | [diff] [blame] | 47 | pythonize_bool(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX) |
| 48 | pythonize_bool(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI) |
Jonathan Roelofs | c09886b | 2015-02-26 15:55:01 +0000 | [diff] [blame] | 49 | set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING |
| 50 | "TargetInfo to use when setting up test environment.") |
Louis Dionne | 5072335 | 2020-06-11 15:41:38 -0400 | [diff] [blame] | 51 | set(LIBCXXABI_EXECUTOR "${Python3_EXECUTABLE} ${LIBCXXABI_LIBCXX_PATH}/utils/run.py" CACHE STRING |
Jonathan Roelofs | c09886b | 2015-02-26 15:55:01 +0000 | [diff] [blame] | 52 | "Executor to use when running tests.") |
Dan Albert | db7f9a3 | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 53 | |
Ben Craig | 1d74ace | 2016-04-19 12:47:38 +0000 | [diff] [blame] | 54 | if (LIBCXXABI_ENABLE_SHARED) |
| 55 | set(LIBCXXABI_TEST_DEPS cxxabi_shared) |
| 56 | else() |
| 57 | set(LIBCXXABI_TEST_DEPS cxxabi_static) |
| 58 | endif() |
| 59 | |
Asiri Rathnayake | 0a33e54 | 2017-01-09 11:57:21 +0000 | [diff] [blame] | 60 | if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY) |
Asiri Rathnayake | fb90fce | 2017-01-03 12:58:34 +0000 | [diff] [blame] | 61 | list(APPEND LIBCXXABI_TEST_DEPS cxx_external_threads) |
| 62 | endif() |
| 63 | |
Eric Fiselier | 0f87229 | 2016-08-28 18:16:18 +0000 | [diff] [blame] | 64 | if (NOT LIBCXXABI_STANDALONE_BUILD) |
Dan Albert | db7f9a3 | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 65 | list(APPEND LIBCXXABI_TEST_DEPS cxx) |
Michał Górny | 45e01f5 | 2022-02-11 12:48:31 +0100 | [diff] [blame] | 66 | if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind) |
Petr Hosek | a969d23 | 2016-08-08 22:09:54 +0000 | [diff] [blame] | 67 | list(APPEND LIBCXXABI_TEST_DEPS unwind) |
| 68 | endif() |
Dan Albert | 37bd657 | 2014-07-11 15:36:02 +0000 | [diff] [blame] | 69 | endif() |
| 70 | |
Louis Dionne | 8b9ef2a | 2020-06-25 11:46:00 -0400 | [diff] [blame] | 71 | set(AUTO_GEN_COMMENT "## Autogenerated by libcxxabi configuration.\n# Do not edit!") |
Louis Dionne | af54170 | 2021-06-01 17:16:11 -0400 | [diff] [blame] | 72 | set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n") |
| 73 | |
| 74 | macro(serialize_lit_param param value) |
| 75 | string(APPEND SERIALIZED_LIT_PARAMS "config.${param} = ${value}\n") |
| 76 | endmacro() |
| 77 | |
| 78 | if (NOT LIBCXXABI_ENABLE_EXCEPTIONS) |
| 79 | serialize_lit_param(enable_exceptions False) |
| 80 | endif() |
| 81 | |
Louis Dionne | f26979f | 2022-03-28 13:10:14 -0400 | [diff] [blame] | 82 | if (LIBCXXABI_ENABLE_ASSERTIONS) |
| 83 | serialize_lit_param(enable_assertions True) |
| 84 | endif() |
| 85 | |
Louis Dionne | af54170 | 2021-06-01 17:16:11 -0400 | [diff] [blame] | 86 | serialize_lit_param(enable_experimental False) |
| 87 | |
| 88 | if (LLVM_USE_SANITIZER) |
| 89 | serialize_lit_param(use_sanitizer "\"${LLVM_USE_SANITIZER}\"") |
| 90 | endif() |
| 91 | |
Louis Dionne | 4642f46 | 2021-10-12 15:59:08 -0400 | [diff] [blame] | 92 | if (CMAKE_CXX_COMPILER_TARGET) |
| 93 | serialize_lit_param(target_triple "\"${CMAKE_CXX_COMPILER_TARGET}\"") |
| 94 | else() |
| 95 | serialize_lit_param(target_triple "\"${LLVM_DEFAULT_TARGET_TRIPLE}\"") |
Louis Dionne | af54170 | 2021-06-01 17:16:11 -0400 | [diff] [blame] | 96 | endif() |
| 97 | |
Louis Dionne | f96e853 | 2021-07-14 11:36:22 -0400 | [diff] [blame] | 98 | foreach(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}\"") |
| 102 | endforeach() |
| 103 | |
Louis Dionne | 58f39ec | 2021-10-12 17:45:45 -0400 | [diff] [blame] | 104 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in" |
| 105 | "${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg" |
| 106 | @ONLY) |
| 107 | |
Eric Fiselier | c919c88 | 2018-01-17 22:07:09 +0000 | [diff] [blame] | 108 | configure_lit_site_cfg( |
Louis Dionne | 8b9ef2a | 2020-06-25 11:46:00 -0400 | [diff] [blame] | 109 | "${LIBCXXABI_TEST_CONFIG}" |
| 110 | ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg |
| 111 | MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py") |
Eric Fiselier | c919c88 | 2018-01-17 22:07:09 +0000 | [diff] [blame] | 112 | |
Petr Hosek | 71c873b | 2021-03-03 22:40:11 -0800 | [diff] [blame] | 113 | add_lit_testsuite(check-cxxabi "Running libcxxabi tests" |
Dan Albert | db7f9a3 | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 114 | ${CMAKE_CURRENT_BINARY_DIR} |
Louis Dionne | f96e853 | 2021-07-14 11:36:22 -0400 | [diff] [blame] | 115 | DEPENDS ${LIBCXXABI_TEST_DEPS}) |