126 lines
4.5 KiB
Text
126 lines
4.5 KiB
Text
|
include(HandleLitArguments)
|
||
|
add_subdirectory(tools)
|
||
|
|
||
|
# By default, libcxx and libcxxabi share a library directory.
|
||
|
if (NOT LIBCXX_CXX_ABI_LIBRARY_PATH)
|
||
|
set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_LIBRARY_DIR}" CACHE PATH
|
||
|
"The path to libc++abi library.")
|
||
|
endif()
|
||
|
|
||
|
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
|
||
|
set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
|
||
|
|
||
|
if (LIBCXX_EXECUTOR)
|
||
|
message(DEPRECATION "LIBCXX_EXECUTOR is deprecated, please add executor=... to LIBCXX_TEST_PARAMS")
|
||
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS executor "${LIBCXX_EXECUTOR}")
|
||
|
endif()
|
||
|
|
||
|
if (NOT LIBCXX_ENABLE_EXCEPTIONS)
|
||
|
serialize_lit_param(SERIALIZED_LIT_PARAMS enable_exceptions False)
|
||
|
endif()
|
||
|
|
||
|
if (NOT LIBCXX_ENABLE_RTTI)
|
||
|
serialize_lit_param(SERIALIZED_LIT_PARAMS enable_rtti False)
|
||
|
endif()
|
||
|
|
||
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS hardening_mode "${LIBCXX_HARDENING_MODE}")
|
||
|
|
||
|
if (CMAKE_CXX_COMPILER_TARGET)
|
||
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${CMAKE_CXX_COMPILER_TARGET}")
|
||
|
else()
|
||
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${LLVM_DEFAULT_TARGET_TRIPLE}")
|
||
|
endif()
|
||
|
|
||
|
if (LLVM_USE_SANITIZER)
|
||
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS use_sanitizer "${LLVM_USE_SANITIZER}")
|
||
|
endif()
|
||
|
|
||
|
serialize_lit_params_list(SERIALIZED_LIT_PARAMS LIBCXX_TEST_PARAMS)
|
||
|
|
||
|
if (NOT DEFINED LIBCXX_TEST_DEPS)
|
||
|
message(FATAL_ERROR "Expected LIBCXX_TEST_DEPS to be defined")
|
||
|
endif()
|
||
|
|
||
|
if (MSVC)
|
||
|
# Shared code for initializing some parameters used by all
|
||
|
# llvm-libc++-*-clangcl.cfg.in test configs.
|
||
|
set(dbg_include "")
|
||
|
|
||
|
if (NOT CMAKE_MSVC_RUNTIME_LIBRARY OR CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$")
|
||
|
set(fms_runtime_lib "dll")
|
||
|
set(cxx_lib "msvcprt")
|
||
|
else()
|
||
|
set(fms_runtime_lib "static")
|
||
|
set(cxx_lib "libcpmt")
|
||
|
endif()
|
||
|
|
||
|
if ((NOT CMAKE_MSVC_RUNTIME_LIBRARY AND uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
||
|
OR (CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "Debug"))
|
||
|
set(dbg_include " -include set_windows_crt_report_mode.h")
|
||
|
set(fms_runtime_lib "${fms_runtime_lib}_dbg")
|
||
|
set(cxx_lib "${cxx_lib}d")
|
||
|
endif()
|
||
|
|
||
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS dbg_include "${dbg_include}")
|
||
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS fms_runtime_lib "${fms_runtime_lib}")
|
||
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS cxx_lib "${cxx_lib}")
|
||
|
endif()
|
||
|
|
||
|
if (LIBCXX_INCLUDE_TESTS)
|
||
|
include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
|
||
|
|
||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
|
||
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
|
||
|
@ONLY)
|
||
|
|
||
|
configure_lit_site_cfg(
|
||
|
"${LIBCXX_TEST_CONFIG}"
|
||
|
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
||
|
MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py")
|
||
|
|
||
|
add_custom_target(cxx-test-depends
|
||
|
DEPENDS cxx ${LIBCXX_TEST_DEPS}
|
||
|
COMMENT "Builds dependencies required to run the test suite.")
|
||
|
|
||
|
add_lit_testsuite(check-cxx
|
||
|
"Running libcxx tests"
|
||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||
|
DEPENDS cxx-test-depends)
|
||
|
|
||
|
endif()
|
||
|
|
||
|
if (LIBCXX_GENERATE_COVERAGE)
|
||
|
include(CodeCoverage)
|
||
|
set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage")
|
||
|
set(capture_dirs
|
||
|
"${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_objects.dir/"
|
||
|
"${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/"
|
||
|
"${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/"
|
||
|
"${CMAKE_CURRENT_BINARY_DIR}")
|
||
|
set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src")
|
||
|
setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}")
|
||
|
endif()
|
||
|
|
||
|
if (LIBCXX_CONFIGURE_IDE)
|
||
|
# Create dummy targets for each of the tests in the test suite, this allows
|
||
|
# IDE's such as CLion to correctly highlight the tests because it knows
|
||
|
# roughly what include paths/compile flags/macro definitions are needed.
|
||
|
include_directories(support)
|
||
|
file(GLOB_RECURSE LIBCXX_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/*.pass.cpp)
|
||
|
file(GLOB LIBCXX_TEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/support/*)
|
||
|
file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
|
||
|
add_executable(libcxx_test_objects EXCLUDE_FROM_ALL
|
||
|
${LIBCXX_TESTS} ${LIBCXX_TEST_HEADERS} ${LIBCXX_HEADERS})
|
||
|
add_dependencies(libcxx_test_objects cxx)
|
||
|
|
||
|
split_list(LIBCXX_COMPILE_FLAGS)
|
||
|
split_list(LIBCXX_LINK_FLAGS)
|
||
|
|
||
|
set_target_properties(libcxx_test_objects
|
||
|
PROPERTIES
|
||
|
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
|
||
|
LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
|
||
|
EXCLUDE_FROM_ALL ON
|
||
|
)
|
||
|
endif()
|