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 pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
30 pythonize_bool(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
31 pythonize_bool(LIBCXX_ENABLE_RTTI)
32 pythonize_bool(LIBCXX_ENABLE_SHARED)
33 pythonize_bool(LIBCXX_ENABLE_FILESYSTEM)
34 pythonize_bool(LIBCXX_BUILD_32_BITS)
35 pythonize_bool(LIBCXX_GENERATE_COVERAGE)
36 pythonize_bool(LIBCXXABI_ENABLE_SHARED)
37 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
38 pythonize_bool(LIBCXX_USE_COMPILER_RT)
39 pythonize_bool(LIBCXX_HAS_ATOMIC_LIB)
40 pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB)
41 pythonize_bool(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
42 pythonize_bool(LIBCXX_DEBUG_BUILD)
43 pythonize_bool(LIBCXX_ENABLE_PARALLEL_ALGORITHMS)
45 # By default, for non-standalone builds, libcxx and libcxxabi share a library
47 if (NOT LIBCXX_CXX_ABI_LIBRARY_PATH)
48 set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_LIBRARY_DIR}" CACHE PATH
49 "The path to libc++abi library." FORCE)
52 set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
53 "TargetInfo to use when setting up test environment.")
54 set(LIBCXX_EXECUTOR "None" CACHE STRING
55 "Executor to use when running tests.")
57 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
59 if (NOT DEFINED LIBCXX_TEST_DEPS)
60 message(FATAL_ERROR "Expected LIBCXX_TEST_DEPS to be defined")
63 # Turn this on by default when the pretty printers are python3
65 if(LIBCXX_TEST_GDB_PRETTY_PRINTERS)
66 find_program(LIBCXX_GDB gdb)
68 set(LIBCXX_GDB "${LIBCXX_GDB}")
69 message(STATUS "gdb found: ${LIBCXX_GDB}")
71 message(STATUS "gdb not found. Disabling dependent tests.")
75 if (LIBCXX_INCLUDE_TESTS)
76 include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuit
78 configure_lit_site_cfg(
79 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
80 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
82 add_lit_testsuite(check-cxx
83 "Running libcxx tests"
84 ${CMAKE_CURRENT_BINARY_DIR}
85 DEPENDS cxx ${LIBCXX_TEST_DEPS})
87 add_custom_target(check-libcxx DEPENDS check-cxx)
90 if (LIBCXX_GENERATE_COVERAGE)
92 set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage")
94 "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_objects.dir/"
95 "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/"
96 "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/"
97 "${CMAKE_CURRENT_BINARY_DIR}")
98 set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src")
99 setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}")
102 if (LIBCXX_CONFIGURE_IDE)
103 # Create dummy targets for each of the tests in the test suite, this allows
104 # IDE's such as CLion to correctly highlight the tests because it knows
105 # roughly what include paths/compile flags/macro definitions are needed.
106 include_directories(support)
107 file(GLOB_RECURSE LIBCXX_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/*.pass.cpp)
108 file(GLOB LIBCXX_TEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/support/*)
109 file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
110 add_executable(libcxx_test_objects EXCLUDE_FROM_ALL
111 ${LIBCXX_TESTS} ${LIBCXX_TEST_HEADERS} ${LIBCXX_HEADERS})
112 add_dependencies(libcxx_test_objects cxx)
114 set(STATIC_ROOT ${LIBCXX_SOURCE_DIR}/test/std/input.output/filesystems/Inputs/static_test_env)
115 add_definitions(-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="${STATIC_ROOT}")
117 set(DYNAMIC_ROOT ${LIBCXX_BINARY_DIR}/test/filesystem/Output/dynamic_env)
118 add_definitions(-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="${DYNAMIC_ROOT}")
120 set(DYNAMIC_HELPER "python ${LIBCXX_SOURCE_DIR}/test/support/filesystem_dynamic_test_helper.py ")
121 add_definitions(-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="${DYNAMIC_HELPER}")
123 split_list(LIBCXX_COMPILE_FLAGS)
124 split_list(LIBCXX_LINK_FLAGS)
126 set_target_properties(libcxx_test_objects
128 COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
129 LINK_FLAGS "${LIBCXX_LINK_FLAGS}"