mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
0f55045526
This patch pulls google/benchmark v1.4.1 into the LLVM tree so that any project could use it for benchmark generation. A dummy benchmark is added to `llvm/benchmarks/DummyYAML.cpp` to validate the correctness of the build process. The current version does not utilize LLVM LNT and LLVM CMake infrastructure, but that might be sufficient for most users. Two introduced CMake variables: * `LLVM_INCLUDE_BENCHMARKS` (`ON` by default) generates benchmark targets * `LLVM_BUILD_BENCHMARKS` (`OFF` by default) adds generated benchmark targets to the list of default LLVM targets (i.e. if `ON` benchmarks will be built upon standard build invocation, e.g. `ninja` or `make` with no specific targets) List of modifications: * `BENCHMARK_ENABLE_TESTING` is disabled * `BENCHMARK_ENABLE_EXCEPTIONS` is disabled * `BENCHMARK_ENABLE_INSTALL` is disabled * `BENCHMARK_ENABLE_GTEST_TESTS` is disabled * `BENCHMARK_DOWNLOAD_DEPENDENCIES` is disabled Original discussion can be found here: http://lists.llvm.org/pipermail/llvm-dev/2018-August/125023.html Reviewed by: dberris, lebedev.ri Subscribers: ilya-biryukov, ioeric, EricWF, lebedev.ri, srhines, dschuff, mgorny, krytarowski, fedor.sergeev, mgrang, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D50894 llvm-svn: 340809
65 lines
1.9 KiB
CMake
65 lines
1.9 KiB
CMake
# - Compile and run code to check for C++ features
|
|
#
|
|
# This functions compiles a source file under the `cmake` folder
|
|
# and adds the corresponding `HAVE_[FILENAME]` flag to the CMake
|
|
# environment
|
|
#
|
|
# cxx_feature_check(<FLAG> [<VARIANT>])
|
|
#
|
|
# - Example
|
|
#
|
|
# include(CXXFeatureCheck)
|
|
# cxx_feature_check(STD_REGEX)
|
|
# Requires CMake 2.8.12+
|
|
|
|
if(__cxx_feature_check)
|
|
return()
|
|
endif()
|
|
set(__cxx_feature_check INCLUDED)
|
|
|
|
function(cxx_feature_check FILE)
|
|
string(TOLOWER ${FILE} FILE)
|
|
string(TOUPPER ${FILE} VAR)
|
|
string(TOUPPER "HAVE_${VAR}" FEATURE)
|
|
if (DEFINED HAVE_${VAR})
|
|
set(HAVE_${VAR} 1 PARENT_SCOPE)
|
|
add_definitions(-DHAVE_${VAR})
|
|
return()
|
|
endif()
|
|
|
|
if (NOT DEFINED COMPILE_${FEATURE})
|
|
message("-- Performing Test ${FEATURE}")
|
|
if(CMAKE_CROSSCOMPILING)
|
|
try_compile(COMPILE_${FEATURE}
|
|
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp
|
|
CMAKE_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS}
|
|
LINK_LIBRARIES ${BENCHMARK_CXX_LIBRARIES})
|
|
if(COMPILE_${FEATURE})
|
|
message(WARNING
|
|
"If you see build failures due to cross compilation, try setting HAVE_${VAR} to 0")
|
|
set(RUN_${FEATURE} 0)
|
|
else()
|
|
set(RUN_${FEATURE} 1)
|
|
endif()
|
|
else()
|
|
message("-- Performing Test ${FEATURE}")
|
|
try_run(RUN_${FEATURE} COMPILE_${FEATURE}
|
|
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp
|
|
CMAKE_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS}
|
|
LINK_LIBRARIES ${BENCHMARK_CXX_LIBRARIES})
|
|
endif()
|
|
endif()
|
|
|
|
if(RUN_${FEATURE} EQUAL 0)
|
|
message("-- Performing Test ${FEATURE} -- success")
|
|
set(HAVE_${VAR} 1 PARENT_SCOPE)
|
|
add_definitions(-DHAVE_${VAR})
|
|
else()
|
|
if(NOT COMPILE_${FEATURE})
|
|
message("-- Performing Test ${FEATURE} -- failed to compile")
|
|
else()
|
|
message("-- Performing Test ${FEATURE} -- compiled but failed to run")
|
|
endif()
|
|
endif()
|
|
endfunction()
|