[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / libcxxabi / test / CMakeLists.txt
blob0a4541b9443c6bc58efc9f6111fed08a1456ee03
1 include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
2 macro(pythonize_bool var)
3   if (${var})
4     set(${var} True)
5   else()
6     set(${var} False)
7   endif()
8 endmacro()
10 if (NOT DEFINED LIBCXX_ENABLE_SHARED)
11   set(LIBCXX_ENABLE_SHARED ON)
12 endif()
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")
24 endif()
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()
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()
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")
38 endif()
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)
56 else()
57   set(LIBCXXABI_TEST_DEPS cxxabi_static)
58 endif()
60 if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
61   list(APPEND LIBCXXABI_TEST_DEPS cxx_external_threads)
62 endif()
64 list(APPEND LIBCXXABI_TEST_DEPS cxx)
65 if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
66   list(APPEND LIBCXXABI_TEST_DEPS unwind)
67 endif()
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")
74 endmacro()
76 if (NOT LIBCXXABI_ENABLE_EXCEPTIONS)
77   serialize_lit_param(enable_exceptions False)
78 endif()
80 if (LIBCXXABI_ENABLE_ASSERTIONS)
81   serialize_lit_param(enable_assertions True)
82 endif()
84 serialize_lit_param(enable_experimental False)
86 if (LLVM_USE_SANITIZER)
87   serialize_lit_param(use_sanitizer "\"${LLVM_USE_SANITIZER}\"")
88 endif()
90 if (CMAKE_CXX_COMPILER_TARGET)
91   serialize_lit_param(target_triple "\"${CMAKE_CXX_COMPILER_TARGET}\"")
92 else()
93   serialize_lit_param(target_triple "\"${LLVM_DEFAULT_TARGET_TRIPLE}\"")
94 endif()
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}\"")
100 endforeach()
102 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
103                "${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
104                @ONLY)
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})