diff options
Diffstat (limited to '3rdparty/benchmark/cmake')
-rw-r--r-- | 3rdparty/benchmark/cmake/AddCXXCompilerFlag.cmake | 37 | ||||
-rw-r--r-- | 3rdparty/benchmark/cmake/CXXFeatureCheck.cmake | 39 | ||||
-rw-r--r-- | 3rdparty/benchmark/cmake/GetGitVersion.cmake | 51 | ||||
-rw-r--r-- | 3rdparty/benchmark/cmake/gnu_posix_regex.cpp | 12 | ||||
-rw-r--r-- | 3rdparty/benchmark/cmake/posix_regex.cpp | 12 | ||||
-rw-r--r-- | 3rdparty/benchmark/cmake/std_regex.cpp | 10 | ||||
-rw-r--r-- | 3rdparty/benchmark/cmake/steady_clock.cpp | 7 | ||||
-rw-r--r-- | 3rdparty/benchmark/cmake/thread_safety_attributes.cpp | 4 |
8 files changed, 172 insertions, 0 deletions
diff --git a/3rdparty/benchmark/cmake/AddCXXCompilerFlag.cmake b/3rdparty/benchmark/cmake/AddCXXCompilerFlag.cmake new file mode 100644 index 00000000000..870f11ae4d8 --- /dev/null +++ b/3rdparty/benchmark/cmake/AddCXXCompilerFlag.cmake @@ -0,0 +1,37 @@ +# - Adds a compiler flag if it is supported by the compiler +# +# This function checks that the supplied compiler flag is supported and then +# adds it to the corresponding compiler flags +# +# add_cxx_compiler_flag(<FLAG> [<VARIANT>]) +# +# - Example +# +# include(AddCXXCompilerFlag) +# add_cxx_compiler_flag(-Wall) +# add_cxx_compiler_flag(-no-strict-aliasing RELEASE) +# Requires CMake 2.6+ + +if(__add_cxx_compiler_flag) + return() +endif() +set(__add_cxx_compiler_flag INCLUDED) + +include(CheckCXXCompilerFlag) + +function(add_cxx_compiler_flag FLAG) + string(TOUPPER "HAVE_CXX_FLAG_${FLAG}" SANITIZED_FLAG) + string(REPLACE "+" "X" SANITIZED_FLAG ${SANITIZED_FLAG}) + string(REGEX REPLACE "[^A-Za-z_0-9]" "_" SANITIZED_FLAG ${SANITIZED_FLAG}) + string(REGEX REPLACE "_+" "_" SANITIZED_FLAG ${SANITIZED_FLAG}) + set(CMAKE_REQUIRED_FLAGS "${FLAG}") + check_cxx_compiler_flag("" ${SANITIZED_FLAG}) + if(${SANITIZED_FLAG}) + set(VARIANT ${ARGV1}) + if(ARGV1) + string(TOUPPER "_${VARIANT}" VARIANT) + endif() + set(CMAKE_CXX_FLAGS${VARIANT} "${CMAKE_CXX_FLAGS${VARIANT}} ${FLAG}" PARENT_SCOPE) + endif() +endfunction() + diff --git a/3rdparty/benchmark/cmake/CXXFeatureCheck.cmake b/3rdparty/benchmark/cmake/CXXFeatureCheck.cmake new file mode 100644 index 00000000000..23ee8ac6572 --- /dev/null +++ b/3rdparty/benchmark/cmake/CXXFeatureCheck.cmake @@ -0,0 +1,39 @@ +# - 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.6+ + +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) + message("-- Performing Test ${FEATURE}") + try_run(RUN_${FEATURE} COMPILE_${FEATURE} + ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp) + 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() + diff --git a/3rdparty/benchmark/cmake/GetGitVersion.cmake b/3rdparty/benchmark/cmake/GetGitVersion.cmake new file mode 100644 index 00000000000..8dd94800459 --- /dev/null +++ b/3rdparty/benchmark/cmake/GetGitVersion.cmake @@ -0,0 +1,51 @@ +# - 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() diff --git a/3rdparty/benchmark/cmake/gnu_posix_regex.cpp b/3rdparty/benchmark/cmake/gnu_posix_regex.cpp new file mode 100644 index 00000000000..b5b91cdab7c --- /dev/null +++ b/3rdparty/benchmark/cmake/gnu_posix_regex.cpp @@ -0,0 +1,12 @@ +#include <gnuregex.h> +#include <string> +int main() { + std::string str = "test0159"; + regex_t re; + int ec = regcomp(&re, "^[a-z]+[0-9]+$", REG_EXTENDED | REG_NOSUB); + if (ec != 0) { + return ec; + } + return regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0; +} + diff --git a/3rdparty/benchmark/cmake/posix_regex.cpp b/3rdparty/benchmark/cmake/posix_regex.cpp new file mode 100644 index 00000000000..a31af80481a --- /dev/null +++ b/3rdparty/benchmark/cmake/posix_regex.cpp @@ -0,0 +1,12 @@ +#include <regex.h> +#include <string> +int main() { + std::string str = "test0159"; + regex_t re; + int ec = regcomp(&re, "^[a-z]+[0-9]+$", REG_EXTENDED | REG_NOSUB); + if (ec != 0) { + return ec; + } + return regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0; +} + diff --git a/3rdparty/benchmark/cmake/std_regex.cpp b/3rdparty/benchmark/cmake/std_regex.cpp new file mode 100644 index 00000000000..696f2a26bce --- /dev/null +++ b/3rdparty/benchmark/cmake/std_regex.cpp @@ -0,0 +1,10 @@ +#include <regex> +#include <string> +int main() { + const std::string str = "test0159"; + std::regex re; + re = std::regex("^[a-z]+[0-9]+$", + std::regex_constants::extended | std::regex_constants::nosubs); + return std::regex_search(str, re) ? 0 : -1; +} + diff --git a/3rdparty/benchmark/cmake/steady_clock.cpp b/3rdparty/benchmark/cmake/steady_clock.cpp new file mode 100644 index 00000000000..66d50d17e9e --- /dev/null +++ b/3rdparty/benchmark/cmake/steady_clock.cpp @@ -0,0 +1,7 @@ +#include <chrono> + +int main() { + typedef std::chrono::steady_clock Clock; + Clock::time_point tp = Clock::now(); + ((void)tp); +} diff --git a/3rdparty/benchmark/cmake/thread_safety_attributes.cpp b/3rdparty/benchmark/cmake/thread_safety_attributes.cpp new file mode 100644 index 00000000000..46161babdb1 --- /dev/null +++ b/3rdparty/benchmark/cmake/thread_safety_attributes.cpp @@ -0,0 +1,4 @@ +#define HAVE_THREAD_SAFETY_ATTRIBUTES +#include "../src/mutex.h" + +int main() {} |