[libcxx] Add code coverage configuration to CMake and LIT.
Summary:
This patch adds configuration to CMake and LIT for running the libc++ test-suite to generate code coverage.
To use code coverage use following instructions.
* Find the clang resource dir using `$CXX -print-search-dirs`. Let <library-dir> be the first library search directory.
* `cmake <regular-options> -DLIBCXX_GENERATE_COVERAGE=ON -DLIBCXX_COVERAGE_LIBRARY=<library-dir>/lib/<platform>/libclang_rt.profile.a <source>`
* `make cxx`
* `make check-libcxx`
* `make generate-libcxx-coverage`
The reason I want this patch upstreamed is so I can setup a bot that generates code coverage and posts in online for every revision.
Reviewers: mclow.lists, jroelofs, danalbert
Reviewed By: danalbert
Differential Revision: http://reviews.llvm.org/D8716
llvm-svn: 233669
diff --git a/libcxx/lib/CMakeLists.txt b/libcxx/lib/CMakeLists.txt
index ee6cec4..d3d5f38 100644
--- a/libcxx/lib/CMakeLists.txt
+++ b/libcxx/lib/CMakeLists.txt
@@ -1,3 +1,5 @@
+set(LIBCXX_LIB_CMAKEFILES_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}" PARENT_SCOPE)
+
# Get sources
file(GLOB LIBCXX_SOURCES ../src/*.cpp)
if(WIN32)
@@ -61,8 +63,12 @@
append_if(libraries LIBCXX_HAS_RT_LIB rt)
append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s)
+if (LIBCXX_COVERAGE_LIBRARY)
+ target_link_libraries(cxx ${LIBCXX_COVERAGE_LIBRARY})
+endif()
target_link_libraries(cxx ${libraries})
+
# Setup flags.
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_FPIC_FLAG -fPIC)
append_if(LIBCXX_LINK_FLAGS LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)