2015-04-02 22:24:48 +00:00
|
|
|
cmake_minimum_required (VERSION 2.8.11)
|
2013-12-19 00:55:45 +00:00
|
|
|
project (benchmark)
|
|
|
|
|
2015-03-06 17:35:00 +00:00
|
|
|
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." ON)
|
2014-08-01 14:00:43 +00:00
|
|
|
# Make sure we can import out CMake functions
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
|
|
|
2015-03-06 17:35:00 +00:00
|
|
|
# Read the git tags to determine the project version
|
|
|
|
include(GetGitVersion)
|
|
|
|
get_git_version(GIT_VERSION)
|
|
|
|
|
|
|
|
# Tell the user what versions we are using
|
|
|
|
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION ${GIT_VERSION})
|
|
|
|
message("-- Version: ${VERSION}")
|
|
|
|
|
|
|
|
# The version of the libraries
|
|
|
|
set(GENERIC_LIB_VERSION ${VERSION})
|
|
|
|
string(SUBSTRING ${VERSION} 0 1 GENERIC_LIB_SOVERSION)
|
2014-04-23 07:48:52 +00:00
|
|
|
|
2015-02-19 21:38:30 +00:00
|
|
|
# Try and enable C++11. Don't use C++14 because it doesn't work in some
|
|
|
|
# configurations.
|
2014-08-01 13:24:56 +00:00
|
|
|
include(CheckCXXCompilerFlag)
|
2015-03-06 17:35:00 +00:00
|
|
|
include(AddCXXCompilerFlag)
|
|
|
|
include(CXXFeatureCheck)
|
|
|
|
|
|
|
|
check_cxx_compiler_flag(-std=c++11 HAVE_FLAG_CXX_11)
|
|
|
|
check_cxx_compiler_flag(-std=c++0x HAVE_FLAG_CXX_0X)
|
2015-02-19 21:38:30 +00:00
|
|
|
if (HAVE_FLAG_CXX_11)
|
2015-03-06 17:35:00 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
2014-08-01 09:48:16 +00:00
|
|
|
elseif (HAVE_FLAG_CXX_0X)
|
2015-03-06 17:35:00 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
2014-08-01 09:48:16 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Turn compiler warnings up to 11
|
2014-08-01 13:24:56 +00:00
|
|
|
add_cxx_compiler_flag(-Wall)
|
2015-03-06 17:35:00 +00:00
|
|
|
add_cxx_compiler_flag(-Wextra)
|
2014-08-01 13:24:56 +00:00
|
|
|
add_cxx_compiler_flag(-Wshadow)
|
2015-04-30 13:10:06 +00:00
|
|
|
add_cxx_compiler_flag(-Werror RELEASE)
|
|
|
|
add_cxx_compiler_flag(-pedantic)
|
2014-08-01 13:24:56 +00:00
|
|
|
add_cxx_compiler_flag(-pedantic-errors)
|
2015-03-13 00:17:40 +00:00
|
|
|
add_cxx_compiler_flag(-Wshorten-64-to-32)
|
2015-03-13 00:27:29 +00:00
|
|
|
add_cxx_compiler_flag(-Wfloat-equal)
|
2015-03-12 23:16:06 +00:00
|
|
|
add_cxx_compiler_flag(-Wzero-as-null-pointer-constant)
|
2014-08-01 13:24:56 +00:00
|
|
|
# Release flags
|
|
|
|
add_cxx_compiler_flag(-fno-strict-aliasing RELEASE)
|
2014-08-01 09:48:16 +00:00
|
|
|
|
2015-03-06 17:35:00 +00:00
|
|
|
add_cxx_compiler_flag(-Wthread-safety)
|
2015-03-12 22:03:33 +00:00
|
|
|
if (HAVE_WTHREAD_SAFETY)
|
|
|
|
add_definitions(-DHAVE_WTHREAD_SAFETY)
|
|
|
|
cxx_feature_check(THREAD_SAFETY_ATTRIBUTES)
|
|
|
|
endif()
|
2014-07-30 15:59:14 +00:00
|
|
|
|
2014-07-31 14:20:20 +00:00
|
|
|
# C++ feature checks
|
|
|
|
cxx_feature_check(STD_REGEX)
|
|
|
|
cxx_feature_check(GNU_POSIX_REGEX)
|
|
|
|
cxx_feature_check(POSIX_REGEX)
|
2015-03-26 21:52:28 +00:00
|
|
|
cxx_feature_check(STEADY_CLOCK)
|
2014-07-31 14:20:20 +00:00
|
|
|
|
2015-04-03 20:33:54 +00:00
|
|
|
# Ensure we have pthreads
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
2013-12-19 00:55:45 +00:00
|
|
|
# Set up directories
|
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/include)
|
|
|
|
|
|
|
|
# Build the targets
|
2014-04-23 07:47:07 +00:00
|
|
|
add_subdirectory(src)
|
2015-03-06 17:35:00 +00:00
|
|
|
|
|
|
|
if (BENCHMARK_ENABLE_TESTING)
|
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|