Clang doesn't produce gcov compatible coverage files. This causes lcov to break because it uses gcov by default. This patch switches lcov to use llvm-cov as the gcov-tool. Unfortunatly llvm-cov doesn't provide a gcov like interface by default so it won't work with lcov. However `llvm-cov gcov` does. For this reason we generate 'llvm-cov-wrapper' script that always passes the gcov flag. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@297553 91177308-0d34-0410-b5e6-96231b3b80d8
44 lines
1.6 KiB
CMake
44 lines
1.6 KiB
CMake
function(find_compiler_rt_library name dest)
|
|
if (NOT DEFINED LIBCXX_COMPILE_FLAGS)
|
|
message(FATAL_ERROR "LIBCXX_COMPILE_FLAGS must be defined when using this function")
|
|
endif()
|
|
set(dest "" PARENT_SCOPE)
|
|
set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBCXX_COMPILE_FLAGS}
|
|
"--rtlib=compiler-rt" "--print-libgcc-file-name")
|
|
execute_process(
|
|
COMMAND ${CLANG_COMMAND}
|
|
RESULT_VARIABLE HAD_ERROR
|
|
OUTPUT_VARIABLE LIBRARY_FILE
|
|
)
|
|
string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE)
|
|
string(REPLACE "builtins" "${name}" LIBRARY_FILE "${LIBRARY_FILE}")
|
|
if (NOT HAD_ERROR AND EXISTS "${LIBRARY_FILE}")
|
|
message(STATUS "Found compiler-rt library: ${LIBRARY_FILE}")
|
|
set(${dest} "${LIBRARY_FILE}" PARENT_SCOPE)
|
|
else()
|
|
message(STATUS "Failed to find compiler-rt library")
|
|
endif()
|
|
endfunction()
|
|
|
|
function(find_compiler_rt_dir dest)
|
|
if (NOT DEFINED LIBCXX_COMPILE_FLAGS)
|
|
message(FATAL_ERROR "LIBCXX_COMPILE_FLAGS must be defined when using this function")
|
|
endif()
|
|
set(dest "" PARENT_SCOPE)
|
|
set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBCXX_COMPILE_FLAGS}
|
|
"--rtlib=compiler-rt" "--print-libgcc-file-name")
|
|
execute_process(
|
|
COMMAND ${CLANG_COMMAND}
|
|
RESULT_VARIABLE HAD_ERROR
|
|
OUTPUT_VARIABLE LIBRARY_FILE
|
|
)
|
|
string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE)
|
|
get_filename_component(LIBRARY_DIR "${LIBRARY_FILE}" DIRECTORY)
|
|
if (NOT HAD_ERROR AND EXISTS "${LIBRARY_DIR}")
|
|
message(STATUS "Found compiler-rt directory: ${LIBRARY_DIR}")
|
|
set(${dest} "${LIBRARY_DIR}" PARENT_SCOPE)
|
|
else()
|
|
message(STATUS "Failed to find compiler-rt directory")
|
|
endif()
|
|
endfunction()
|