1macro(pythonize_bool var) 2 if (${var}) 3 set(${var} True) 4 else() 5 set(${var} False) 6 endif() 7endmacro() 8 9set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING 10 "Configuration variant to use for LIT.") 11 12set(LIBCXX_TEST_LINKER_FLAGS "" CACHE STRING 13 "Additonal linker flags to pass when compiling the tests") 14set(LIBCXX_TEST_COMPILER_FLAGS "" CACHE STRING 15 "Additonal linker flags to pass when compiling the tests") 16 17# The tests shouldn't link to any ABI library when it has been linked into 18# libc++ statically or via a linker script. 19if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY OR LIBCXX_ENABLE_ABI_LINKER_SCRIPT) 20 set(LIBCXX_CXX_ABI_LIBNAME "none") 21endif() 22 23# The tests shouldn't link to libunwind if we have a linker script which 24# already does so. 25if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) 26 set(LIBCXXABI_USE_LLVM_UNWINDER OFF) 27endif() 28 29pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS) 30pythonize_bool(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) 31pythonize_bool(LIBCXX_ENABLE_FILESYSTEM) 32pythonize_bool(LIBCXX_ENABLE_RTTI) 33pythonize_bool(LIBCXX_ENABLE_SHARED) 34pythonize_bool(LIBCXX_BUILD_32_BITS) 35pythonize_bool(LIBCXX_GENERATE_COVERAGE) 36pythonize_bool(LIBCXXABI_ENABLE_SHARED) 37pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER) 38pythonize_bool(LIBCXX_USE_COMPILER_RT) 39pythonize_bool(LIBCXX_HAS_ATOMIC_LIB) 40pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB) 41pythonize_bool(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) 42pythonize_bool(LIBCXX_DEBUG_BUILD) 43 44# By default, for non-standalone builds, libcxx and libcxxabi share a library 45# directory. 46if (NOT LIBCXX_CXX_ABI_LIBRARY_PATH) 47 set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_LIBRARY_DIR}" CACHE PATH 48 "The path to libc++abi library.") 49endif() 50 51set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING 52 "TargetInfo to use when setting up test environment.") 53set(LIBCXX_EXECUTOR "None" CACHE STRING 54 "Executor to use when running tests.") 55 56set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!") 57 58if (NOT DEFINED LIBCXX_TEST_DEPS) 59 message(FATAL_ERROR "Expected LIBCXX_TEST_DEPS to be defined") 60endif() 61 62if (LIBCXX_INCLUDE_TESTS) 63 include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuit 64 65 configure_lit_site_cfg( 66 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in 67 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) 68 69 add_lit_testsuite(check-cxx 70 "Running libcxx tests" 71 ${CMAKE_CURRENT_BINARY_DIR} 72 DEPENDS cxx ${LIBCXX_TEST_DEPS}) 73 74 add_custom_target(check-libcxx DEPENDS check-cxx) 75endif() 76 77if (LIBCXX_GENERATE_COVERAGE) 78 include(CodeCoverage) 79 set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage") 80 set(capture_dirs 81 "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_objects.dir/" 82 "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/" 83 "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/" 84 "${CMAKE_CURRENT_BINARY_DIR}") 85 set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src") 86 setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}") 87endif() 88 89 90if (LIBCXX_CONFIGURE_IDE) 91 # Create dummy targets for each of the tests in the test suite, this allows 92 # IDE's such as CLion to correctly highlight the tests because it knows 93 # roughly what include paths/compile flags/macro definitions are needed. 94 include_directories(support) 95 file(GLOB_RECURSE LIBCXX_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/*.pass.cpp) 96 file(GLOB LIBCXX_TEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/support/*) 97 file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*) 98 add_executable(libcxx_test_objects EXCLUDE_FROM_ALL 99 ${LIBCXX_TESTS} ${LIBCXX_TEST_HEADERS} ${LIBCXX_HEADERS}) 100 add_dependencies(libcxx_test_objects cxx) 101 102 set(STATIC_ROOT ${LIBCXX_SOURCE_DIR}/test/std/input.output/filesystems/Inputs/static_test_env) 103 add_definitions(-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="${STATIC_ROOT}") 104 105 set(DYNAMIC_ROOT ${LIBCXX_BINARY_DIR}/test/filesystem/Output/dynamic_env) 106 add_definitions(-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="${DYNAMIC_ROOT}") 107 108 set(DYNAMIC_HELPER "python ${LIBCXX_SOURCE_DIR}/test/support/filesystem_dynamic_test_helper.py ") 109 add_definitions(-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="${DYNAMIC_HELPER}") 110 111 split_list(LIBCXX_COMPILE_FLAGS) 112 split_list(LIBCXX_LINK_FLAGS) 113 114 set_target_properties(libcxx_test_objects 115 PROPERTIES 116 COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" 117 LINK_FLAGS "${LIBCXX_LINK_FLAGS}" 118 EXCLUDE_FROM_ALL ON 119 ) 120endif() 121