1 macro(pythonize_bool var)
9 set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING
10 "Configuration variant to use for LIT.")
12 set(LIBCXX_TEST_LINKER_FLAGS "" CACHE STRING
13 "Additonal linker flags to pass when compiling the tests")
14 set(LIBCXX_TEST_COMPILER_FLAGS "" CACHE STRING
15 "Additonal linker flags to pass when compiling the tests")
17 # The tests shouldn't link to any ABI library when it has been linked into
18 # libc++ statically or via a linker script.
19 if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY OR LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
20 set(LIBCXX_CXX_ABI_LIBNAME "none")
23 # The tests shouldn't link to libunwind if we have a linker script which
25 if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
26 set(LIBCXXABI_USE_LLVM_UNWINDER OFF)
29 option(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI
30 "Whether the libc++ tests should link with the shared libc++abi library"
31 ${LIBCXXABI_ENABLE_SHARED})
33 option(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX
34 "Whether the libc++ tests should link with the shared libc++ library"
35 ${LIBCXX_ENABLE_SHARED})
37 if(DEFINED LIBCXXABI_ENABLE_SHARED
38 AND LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI
39 AND NOT LIBCXXABI_ENABLE_SHARED)
40 message(FATAL_ERROR "LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI being ON requires LIBCXXABI_ENABLE_SHARED to be ON")
43 if(DEFINED LIBCXXABI_ENABLE_STATIC
44 AND NOT LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI
45 AND NOT LIBCXXABI_ENABLE_STATIC)
46 message(FATAL_ERROR "LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI being OFF requires LIBCXXABI_ENABLE_STATIC to be ON")
49 if(LIBCXX_INCLUDE_TESTS AND LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX AND NOT LIBCXX_ENABLE_SHARED)
50 message(FATAL_ERROR "LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX being ON requires LIBCXX_ENABLE_SHARED to be ON")
53 if(LIBCXX_INCLUDE_TESTS AND NOT LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX AND NOT LIBCXX_ENABLE_STATIC)
54 message(FATAL_ERROR "LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX being OFF requires LIBCXX_ENABLE_STATIC to be ON")
57 pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
58 pythonize_bool(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
59 pythonize_bool(LIBCXX_ENABLE_RTTI)
60 pythonize_bool(LIBCXX_ENABLE_SHARED)
61 pythonize_bool(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX)
62 pythonize_bool(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI)
63 pythonize_bool(LIBCXX_ENABLE_FILESYSTEM)
64 pythonize_bool(LIBCXX_BUILD_32_BITS)
65 pythonize_bool(LIBCXX_GENERATE_COVERAGE)
66 pythonize_bool(LIBCXXABI_ENABLE_SHARED)
67 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
68 pythonize_bool(LIBCXX_USE_COMPILER_RT)
69 pythonize_bool(LIBCXX_HAS_ATOMIC_LIB)
70 pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB)
71 pythonize_bool(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
72 pythonize_bool(LIBCXX_DEBUG_BUILD)
73 pythonize_bool(LIBCXX_ENABLE_DEBUG_MODE_SUPPORT)
74 pythonize_bool(LIBCXX_ENABLE_PARALLEL_ALGORITHMS)
76 # By default, for non-standalone builds, libcxx and libcxxabi share a library
78 if (NOT LIBCXX_CXX_ABI_LIBRARY_PATH)
79 set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_LIBRARY_DIR}" CACHE PATH
80 "The path to libc++abi library.")
83 set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
84 "TargetInfo to use when setting up test environment.")
85 set(LIBCXX_EXECUTOR "${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/../utils/run.py" CACHE STRING
86 "Executor to use when running tests.")
88 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
90 if (NOT DEFINED LIBCXX_TEST_DEPS)
91 message(FATAL_ERROR "Expected LIBCXX_TEST_DEPS to be defined")
94 if (LIBCXX_INCLUDE_TESTS)
95 include(AddLLVM) # for configure_lit_site_cfg and add_lit_target
97 configure_lit_site_cfg(
98 "${LIBCXX_TEST_CONFIG}"
99 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
100 MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py")
102 add_custom_target(check-cxx-deps
103 DEPENDS cxx ${LIBCXX_TEST_DEPS}
104 COMMENT "Builds dependencies required to run the test suite.")
106 add_lit_target(check-cxx
107 "Running libcxx tests"
108 ${CMAKE_CURRENT_BINARY_DIR}
109 DEPENDS check-cxx-deps
110 PARAMS "${LIBCXX_TEST_PARAMS}")
113 if (LIBCXX_GENERATE_COVERAGE)
114 include(CodeCoverage)
115 set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage")
117 "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_objects.dir/"
118 "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/"
119 "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/"
120 "${CMAKE_CURRENT_BINARY_DIR}")
121 set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src")
122 setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}")
125 if (LIBCXX_CONFIGURE_IDE)
126 # Create dummy targets for each of the tests in the test suite, this allows
127 # IDE's such as CLion to correctly highlight the tests because it knows
128 # roughly what include paths/compile flags/macro definitions are needed.
129 include_directories(support)
130 file(GLOB_RECURSE LIBCXX_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/*.pass.cpp)
131 file(GLOB LIBCXX_TEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/support/*)
132 file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
133 add_executable(libcxx_test_objects EXCLUDE_FROM_ALL
134 ${LIBCXX_TESTS} ${LIBCXX_TEST_HEADERS} ${LIBCXX_HEADERS})
135 add_dependencies(libcxx_test_objects cxx)
137 split_list(LIBCXX_COMPILE_FLAGS)
138 split_list(LIBCXX_LINK_FLAGS)
140 set_target_properties(libcxx_test_objects
142 COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
143 LINK_FLAGS "${LIBCXX_LINK_FLAGS}"