Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 1 | macro(pythonize_bool var) |
| 2 | if (${var}) |
| 3 | set(${var} True) |
| 4 | else() |
| 5 | set(${var} False) |
| 6 | endif() |
| 7 | endmacro() |
| 8 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 9 | set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING |
| 10 | "Configuration variant to use for LIT.") |
Greg Fitzgerald | 35f1c49 | 2015-02-03 18:02:04 +0000 | [diff] [blame] | 11 | |
Alexander Richardson | 9880456 | 2018-02-23 15:19:48 +0000 | [diff] [blame] | 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") |
| 16 | |
Eric Fiselier | 3bf8a9c | 2016-10-09 21:34:03 +0000 | [diff] [blame] | 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") |
| 21 | endif() |
| 22 | |
| 23 | # The tests shouldn't link to libunwind if we have a linker script which |
| 24 | # already does so. |
| 25 | if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) |
| 26 | set(LIBCXXABI_USE_LLVM_UNWINDER OFF) |
| 27 | endif() |
| 28 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 29 | pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS) |
Eric Fiselier | 5e4698c | 2016-05-03 21:30:18 +0000 | [diff] [blame] | 30 | pythonize_bool(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) |
Eric Fiselier | 6e9a694 | 2016-06-17 19:46:40 +0000 | [diff] [blame] | 31 | pythonize_bool(LIBCXX_ENABLE_FILESYSTEM) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 32 | pythonize_bool(LIBCXX_ENABLE_RTTI) |
| 33 | pythonize_bool(LIBCXX_ENABLE_SHARED) |
| 34 | pythonize_bool(LIBCXX_BUILD_32_BITS) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 35 | pythonize_bool(LIBCXX_GENERATE_COVERAGE) |
Ben Craig | 611ab2b | 2016-04-19 12:49:05 +0000 | [diff] [blame] | 36 | pythonize_bool(LIBCXXABI_ENABLE_SHARED) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 37 | pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER) |
Petr Hosek | 95b20f8 | 2018-01-08 23:36:53 +0000 | [diff] [blame] | 38 | pythonize_bool(LIBCXX_USE_COMPILER_RT) |
Vasileios Kalintiris | cb6641a | 2016-02-11 12:43:04 +0000 | [diff] [blame] | 39 | pythonize_bool(LIBCXX_HAS_ATOMIC_LIB) |
Eric Fiselier | 5432e3b | 2016-07-18 06:01:50 +0000 | [diff] [blame] | 40 | pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB) |
Eric Fiselier | 66134e8 | 2017-01-06 20:05:40 +0000 | [diff] [blame] | 41 | pythonize_bool(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) |
Eric Fiselier | 157fd34 | 2017-01-14 07:54:39 +0000 | [diff] [blame] | 42 | pythonize_bool(LIBCXX_DEBUG_BUILD) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 43 | |
Ben Craig | 611ab2b | 2016-04-19 12:49:05 +0000 | [diff] [blame] | 44 | # By default, for non-standalone builds, libcxx and libcxxabi share a library |
| 45 | # directory. |
| 46 | if (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.") |
| 49 | endif() |
| 50 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 51 | set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING |
| 52 | "TargetInfo to use when setting up test environment.") |
| 53 | set(LIBCXX_EXECUTOR "None" CACHE STRING |
| 54 | "Executor to use when running tests.") |
Greg Fitzgerald | 015fb24 | 2015-02-03 18:47:37 +0000 | [diff] [blame] | 55 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 56 | set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!") |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 57 | |
Eric Fiselier | b124ade | 2018-11-14 20:38:46 +0000 | [diff] [blame] | 58 | if (NOT DEFINED LIBCXX_TEST_DEPS) |
| 59 | message(FATAL_ERROR "Expected LIBCXX_TEST_DEPS to be defined") |
Asiri Rathnayake | 040945b | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 60 | endif() |
| 61 | |
Eric Fiselier | c57fb58 | 2017-03-01 21:53:30 +0000 | [diff] [blame] | 62 | if (LIBCXX_INCLUDE_TESTS) |
Petr Hosek | aec189a | 2017-12-01 03:16:50 +0000 | [diff] [blame] | 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 | |
Eric Fiselier | c57fb58 | 2017-03-01 21:53:30 +0000 | [diff] [blame] | 69 | add_lit_testsuite(check-cxx |
| 70 | "Running libcxx tests" |
| 71 | ${CMAKE_CURRENT_BINARY_DIR} |
| 72 | DEPENDS cxx ${LIBCXX_TEST_DEPS}) |
Eric Fiselier | bf9653d | 2015-03-31 04:15:45 +0000 | [diff] [blame] | 73 | |
Eric Fiselier | c57fb58 | 2017-03-01 21:53:30 +0000 | [diff] [blame] | 74 | add_custom_target(check-libcxx DEPENDS check-cxx) |
| 75 | endif() |
Chris Bieneman | e0620e2 | 2016-08-24 22:17:06 +0000 | [diff] [blame] | 76 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 77 | if (LIBCXX_GENERATE_COVERAGE) |
| 78 | include(CodeCoverage) |
| 79 | set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage") |
Eric Fiselier | 5cdf673 | 2017-03-11 05:28:09 +0000 | [diff] [blame] | 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}") |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 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}") |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 87 | endif() |
Eric Fiselier | f26da86 | 2017-07-05 03:50:03 +0000 | [diff] [blame] | 88 | |
| 89 | |
| 90 | if (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 | |
Eric Fiselier | 0be5527 | 2018-07-27 03:42:58 +0000 | [diff] [blame] | 102 | set(STATIC_ROOT ${LIBCXX_SOURCE_DIR}/test/std/input.output/filesystems/Inputs/static_test_env) |
Eric Fiselier | f26da86 | 2017-07-05 03:50:03 +0000 | [diff] [blame] | 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 | ) |
| 120 | endif() |