
Summary: This patch does the following: 1. Checks in a copy of the Google Benchmark library into the libc++ repo under `utils/google-benchmark`. 2. Teaches libc++ how to build Google Benchmark against both (A) in-tree libc++ and (B) the platforms native STL. 3. Allows performance benchmarks to be built as part of the libc++ build. Building the benchmarks (and Google Benchmark) is off by default. It must be enabled using the CMake option `-DLIBCXX_INCLUDE_BENCHMARKS=ON`. When this option is enabled the tests under `libcxx/benchmarks` can be built using the `libcxx-benchmarks` target. On Linux platforms where libstdc++ is the default STL the CMake option `-DLIBCXX_BUILD_BENCHMARKS_NATIVE_STDLIB=ON` can be used to build each benchmark test against libstdc++ as well. This is useful for comparing performance between standard libraries. Support for benchmarks is currently very minimal. They must be manually run by the user and there is no mechanism for detecting performance regressions. Known Issues: * `-DLIBCXX_INCLUDE_BENCHMARKS=ON` is only supported for Clang, and not GCC, since the `-stdlib=libc++` option is needed to build Google Benchmark. Reviewers: danalbert, dberlin, chandlerc, mclow.lists, jroelofs Subscribers: chandlerc, dberlin, tberghammer, danalbert, srhines, hfinkel Differential Revision: https://reviews.llvm.org/D22240 llvm-svn: 276049
52 lines
1.4 KiB
CMake
52 lines
1.4 KiB
CMake
# - Returns a version string from Git tags
|
|
#
|
|
# This function inspects the annotated git tags for the project and returns a string
|
|
# into a CMake variable
|
|
#
|
|
# get_git_version(<var>)
|
|
#
|
|
# - Example
|
|
#
|
|
# include(GetGitVersion)
|
|
# get_git_version(GIT_VERSION)
|
|
#
|
|
# Requires CMake 2.8.11+
|
|
find_package(Git)
|
|
|
|
if(__get_git_version)
|
|
return()
|
|
endif()
|
|
set(__get_git_version INCLUDED)
|
|
|
|
function(get_git_version var)
|
|
if(GIT_EXECUTABLE)
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} describe --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=8
|
|
RESULT_VARIABLE status
|
|
OUTPUT_VARIABLE GIT_VERSION
|
|
ERROR_QUIET)
|
|
if(${status})
|
|
set(GIT_VERSION "v0.0.0")
|
|
else()
|
|
string(STRIP ${GIT_VERSION} GIT_VERSION)
|
|
string(REGEX REPLACE "-[0-9]+-g" "-" GIT_VERSION ${GIT_VERSION})
|
|
endif()
|
|
|
|
# Work out if the repository is dirty
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} update-index -q --refresh
|
|
OUTPUT_QUIET
|
|
ERROR_QUIET)
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
|
|
OUTPUT_VARIABLE GIT_DIFF_INDEX
|
|
ERROR_QUIET)
|
|
string(COMPARE NOTEQUAL "${GIT_DIFF_INDEX}" "" GIT_DIRTY)
|
|
if (${GIT_DIRTY})
|
|
set(GIT_VERSION "${GIT_VERSION}-dirty")
|
|
endif()
|
|
else()
|
|
set(GIT_VERSION "v0.0.0")
|
|
endif()
|
|
|
|
message("-- git Version: ${GIT_VERSION}")
|
|
set(${var} ${GIT_VERSION} PARENT_SCOPE)
|
|
endfunction()
|