1*58b9f456SAndroid Build Coastguard Workercmake_minimum_required (VERSION 2.8.12) 2*58b9f456SAndroid Build Coastguard Worker 3*58b9f456SAndroid Build Coastguard Workerproject (benchmark) 4*58b9f456SAndroid Build Coastguard Worker 5*58b9f456SAndroid Build Coastguard Workerforeach(p 6*58b9f456SAndroid Build Coastguard Worker CMP0054 # CMake 3.1 7*58b9f456SAndroid Build Coastguard Worker CMP0056 # export EXE_LINKER_FLAGS to try_run 8*58b9f456SAndroid Build Coastguard Worker CMP0057 # Support no if() IN_LIST operator 9*58b9f456SAndroid Build Coastguard Worker ) 10*58b9f456SAndroid Build Coastguard Worker if(POLICY ${p}) 11*58b9f456SAndroid Build Coastguard Worker cmake_policy(SET ${p} NEW) 12*58b9f456SAndroid Build Coastguard Worker endif() 13*58b9f456SAndroid Build Coastguard Workerendforeach() 14*58b9f456SAndroid Build Coastguard Worker 15*58b9f456SAndroid Build Coastguard Workeroption(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." ON) 16*58b9f456SAndroid Build Coastguard Workeroption(BENCHMARK_ENABLE_EXCEPTIONS "Enable the use of exceptions in the benchmark library." ON) 17*58b9f456SAndroid Build Coastguard Workeroption(BENCHMARK_ENABLE_LTO "Enable link time optimisation of the benchmark library." OFF) 18*58b9f456SAndroid Build Coastguard Workeroption(BENCHMARK_USE_LIBCXX "Build and test using libc++ as the standard library." OFF) 19*58b9f456SAndroid Build Coastguard Workerif(NOT MSVC) 20*58b9f456SAndroid Build Coastguard Worker option(BENCHMARK_BUILD_32_BITS "Build a 32 bit version of the library." OFF) 21*58b9f456SAndroid Build Coastguard Workerelse() 22*58b9f456SAndroid Build Coastguard Worker set(BENCHMARK_BUILD_32_BITS OFF CACHE BOOL "Build a 32 bit version of the library - unsupported when using MSVC)" FORCE) 23*58b9f456SAndroid Build Coastguard Workerendif() 24*58b9f456SAndroid Build Coastguard Workeroption(BENCHMARK_ENABLE_INSTALL "Enable installation of benchmark. (Projects embedding benchmark may want to turn this OFF.)" ON) 25*58b9f456SAndroid Build Coastguard Worker 26*58b9f456SAndroid Build Coastguard Worker# Allow unmet dependencies to be met using CMake's ExternalProject mechanics, which 27*58b9f456SAndroid Build Coastguard Worker# may require downloading the source code. 28*58b9f456SAndroid Build Coastguard Workeroption(BENCHMARK_DOWNLOAD_DEPENDENCIES "Allow the downloading and in-tree building of unmet dependencies" OFF) 29*58b9f456SAndroid Build Coastguard Worker 30*58b9f456SAndroid Build Coastguard Worker# This option can be used to disable building and running unit tests which depend on gtest 31*58b9f456SAndroid Build Coastguard Worker# in cases where it is not possible to build or find a valid version of gtest. 32*58b9f456SAndroid Build Coastguard Workeroption(BENCHMARK_ENABLE_GTEST_TESTS "Enable building the unit tests which depend on gtest" ON) 33*58b9f456SAndroid Build Coastguard Worker 34*58b9f456SAndroid Build Coastguard Workerset(ENABLE_ASSEMBLY_TESTS_DEFAULT OFF) 35*58b9f456SAndroid Build Coastguard Workerfunction(should_enable_assembly_tests) 36*58b9f456SAndroid Build Coastguard Worker if(CMAKE_BUILD_TYPE) 37*58b9f456SAndroid Build Coastguard Worker string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER) 38*58b9f456SAndroid Build Coastguard Worker if (${CMAKE_BUILD_TYPE_LOWER} MATCHES "coverage") 39*58b9f456SAndroid Build Coastguard Worker # FIXME: The --coverage flag needs to be removed when building assembly 40*58b9f456SAndroid Build Coastguard Worker # tests for this to work. 41*58b9f456SAndroid Build Coastguard Worker return() 42*58b9f456SAndroid Build Coastguard Worker endif() 43*58b9f456SAndroid Build Coastguard Worker endif() 44*58b9f456SAndroid Build Coastguard Worker if (MSVC) 45*58b9f456SAndroid Build Coastguard Worker return() 46*58b9f456SAndroid Build Coastguard Worker elseif(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") 47*58b9f456SAndroid Build Coastguard Worker return() 48*58b9f456SAndroid Build Coastguard Worker elseif(NOT CMAKE_SIZEOF_VOID_P EQUAL 8) 49*58b9f456SAndroid Build Coastguard Worker # FIXME: Make these work on 32 bit builds 50*58b9f456SAndroid Build Coastguard Worker return() 51*58b9f456SAndroid Build Coastguard Worker elseif(BENCHMARK_BUILD_32_BITS) 52*58b9f456SAndroid Build Coastguard Worker # FIXME: Make these work on 32 bit builds 53*58b9f456SAndroid Build Coastguard Worker return() 54*58b9f456SAndroid Build Coastguard Worker endif() 55*58b9f456SAndroid Build Coastguard Worker find_program(LLVM_FILECHECK_EXE FileCheck) 56*58b9f456SAndroid Build Coastguard Worker if (LLVM_FILECHECK_EXE) 57*58b9f456SAndroid Build Coastguard Worker set(LLVM_FILECHECK_EXE "${LLVM_FILECHECK_EXE}" CACHE PATH "llvm filecheck" FORCE) 58*58b9f456SAndroid Build Coastguard Worker message(STATUS "LLVM FileCheck Found: ${LLVM_FILECHECK_EXE}") 59*58b9f456SAndroid Build Coastguard Worker else() 60*58b9f456SAndroid Build Coastguard Worker message(STATUS "Failed to find LLVM FileCheck") 61*58b9f456SAndroid Build Coastguard Worker return() 62*58b9f456SAndroid Build Coastguard Worker endif() 63*58b9f456SAndroid Build Coastguard Worker set(ENABLE_ASSEMBLY_TESTS_DEFAULT ON PARENT_SCOPE) 64*58b9f456SAndroid Build Coastguard Workerendfunction() 65*58b9f456SAndroid Build Coastguard Workershould_enable_assembly_tests() 66*58b9f456SAndroid Build Coastguard Worker 67*58b9f456SAndroid Build Coastguard Worker# This option disables the building and running of the assembly verification tests 68*58b9f456SAndroid Build Coastguard Workeroption(BENCHMARK_ENABLE_ASSEMBLY_TESTS "Enable building and running the assembly tests" 69*58b9f456SAndroid Build Coastguard Worker ${ENABLE_ASSEMBLY_TESTS_DEFAULT}) 70*58b9f456SAndroid Build Coastguard Worker 71*58b9f456SAndroid Build Coastguard Worker# Make sure we can import out CMake functions 72*58b9f456SAndroid Build Coastguard Workerlist(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") 73*58b9f456SAndroid Build Coastguard Workerlist(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 74*58b9f456SAndroid Build Coastguard Worker 75*58b9f456SAndroid Build Coastguard Worker 76*58b9f456SAndroid Build Coastguard Worker# Read the git tags to determine the project version 77*58b9f456SAndroid Build Coastguard Workerinclude(GetGitVersion) 78*58b9f456SAndroid Build Coastguard Workerget_git_version(GIT_VERSION) 79*58b9f456SAndroid Build Coastguard Worker 80*58b9f456SAndroid Build Coastguard Worker# Tell the user what versions we are using 81*58b9f456SAndroid Build Coastguard Workerstring(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION ${GIT_VERSION}) 82*58b9f456SAndroid Build Coastguard Workermessage(STATUS "Version: ${VERSION}") 83*58b9f456SAndroid Build Coastguard Worker 84*58b9f456SAndroid Build Coastguard Worker# The version of the libraries 85*58b9f456SAndroid Build Coastguard Workerset(GENERIC_LIB_VERSION ${VERSION}) 86*58b9f456SAndroid Build Coastguard Workerstring(SUBSTRING ${VERSION} 0 1 GENERIC_LIB_SOVERSION) 87*58b9f456SAndroid Build Coastguard Worker 88*58b9f456SAndroid Build Coastguard Worker# Import our CMake modules 89*58b9f456SAndroid Build Coastguard Workerinclude(CheckCXXCompilerFlag) 90*58b9f456SAndroid Build Coastguard Workerinclude(AddCXXCompilerFlag) 91*58b9f456SAndroid Build Coastguard Workerinclude(CXXFeatureCheck) 92*58b9f456SAndroid Build Coastguard Worker 93*58b9f456SAndroid Build Coastguard Workerif (BENCHMARK_BUILD_32_BITS) 94*58b9f456SAndroid Build Coastguard Worker add_required_cxx_compiler_flag(-m32) 95*58b9f456SAndroid Build Coastguard Workerendif() 96*58b9f456SAndroid Build Coastguard Worker 97*58b9f456SAndroid Build Coastguard Workerif (MSVC) 98*58b9f456SAndroid Build Coastguard Worker # Turn compiler warnings up to 11 99*58b9f456SAndroid Build Coastguard Worker string(REGEX REPLACE "[-/]W[1-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 100*58b9f456SAndroid Build Coastguard Worker set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") 101*58b9f456SAndroid Build Coastguard Worker add_definitions(-D_CRT_SECURE_NO_WARNINGS) 102*58b9f456SAndroid Build Coastguard Worker 103*58b9f456SAndroid Build Coastguard Worker if (NOT BENCHMARK_ENABLE_EXCEPTIONS) 104*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-EHs-) 105*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-EHa-) 106*58b9f456SAndroid Build Coastguard Worker add_definitions(-D_HAS_EXCEPTIONS=0) 107*58b9f456SAndroid Build Coastguard Worker endif() 108*58b9f456SAndroid Build Coastguard Worker # Link time optimisation 109*58b9f456SAndroid Build Coastguard Worker if (BENCHMARK_ENABLE_LTO) 110*58b9f456SAndroid Build Coastguard Worker set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL") 111*58b9f456SAndroid Build Coastguard Worker set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG") 112*58b9f456SAndroid Build Coastguard Worker set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG") 113*58b9f456SAndroid Build Coastguard Worker set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG") 114*58b9f456SAndroid Build Coastguard Worker 115*58b9f456SAndroid Build Coastguard Worker set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /GL") 116*58b9f456SAndroid Build Coastguard Worker string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO}") 117*58b9f456SAndroid Build Coastguard Worker set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG") 118*58b9f456SAndroid Build Coastguard Worker string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}") 119*58b9f456SAndroid Build Coastguard Worker set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /LTCG") 120*58b9f456SAndroid Build Coastguard Worker string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}") 121*58b9f456SAndroid Build Coastguard Worker set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /LTCG") 122*58b9f456SAndroid Build Coastguard Worker 123*58b9f456SAndroid Build Coastguard Worker set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /GL") 124*58b9f456SAndroid Build Coastguard Worker set(CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL "${CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL} /LTCG") 125*58b9f456SAndroid Build Coastguard Worker set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /LTCG") 126*58b9f456SAndroid Build Coastguard Worker set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /LTCG") 127*58b9f456SAndroid Build Coastguard Worker endif() 128*58b9f456SAndroid Build Coastguard Workerelse() 129*58b9f456SAndroid Build Coastguard Worker # Try and enable C++11. Don't use C++14 because it doesn't work in some 130*58b9f456SAndroid Build Coastguard Worker # configurations. 131*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-std=c++11) 132*58b9f456SAndroid Build Coastguard Worker if (NOT HAVE_CXX_FLAG_STD_CXX11) 133*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-std=c++0x) 134*58b9f456SAndroid Build Coastguard Worker endif() 135*58b9f456SAndroid Build Coastguard Worker 136*58b9f456SAndroid Build Coastguard Worker # Turn compiler warnings up to 11 137*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-Wall) 138*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-Wextra) 139*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-Wshadow) 140*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-Werror RELEASE) 141*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-Werror RELWITHDEBINFO) 142*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-Werror MINSIZEREL) 143*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-pedantic) 144*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-pedantic-errors) 145*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-Wshorten-64-to-32) 146*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-fstrict-aliasing) 147*58b9f456SAndroid Build Coastguard Worker # Disable warnings regarding deprecated parts of the library while building 148*58b9f456SAndroid Build Coastguard Worker # and testing those parts of the library. 149*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-Wno-deprecated-declarations) 150*58b9f456SAndroid Build Coastguard Worker if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") 151*58b9f456SAndroid Build Coastguard Worker # Intel silently ignores '-Wno-deprecated-declarations', 152*58b9f456SAndroid Build Coastguard Worker # warning no. 1786 must be explicitly disabled. 153*58b9f456SAndroid Build Coastguard Worker # See #631 for rationale. 154*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-wd1786) 155*58b9f456SAndroid Build Coastguard Worker endif() 156*58b9f456SAndroid Build Coastguard Worker # Disable deprecation warnings for release builds (when -Werror is enabled). 157*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-Wno-deprecated RELEASE) 158*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-Wno-deprecated RELWITHDEBINFO) 159*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-Wno-deprecated MINSIZEREL) 160*58b9f456SAndroid Build Coastguard Worker if (NOT BENCHMARK_ENABLE_EXCEPTIONS) 161*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-fno-exceptions) 162*58b9f456SAndroid Build Coastguard Worker endif() 163*58b9f456SAndroid Build Coastguard Worker 164*58b9f456SAndroid Build Coastguard Worker if (HAVE_CXX_FLAG_FSTRICT_ALIASING) 165*58b9f456SAndroid Build Coastguard Worker if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel") #ICC17u2: Many false positives for Wstrict-aliasing 166*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-Wstrict-aliasing) 167*58b9f456SAndroid Build Coastguard Worker endif() 168*58b9f456SAndroid Build Coastguard Worker endif() 169*58b9f456SAndroid Build Coastguard Worker # ICC17u2: overloaded virtual function "benchmark::Fixture::SetUp" is only partially overridden 170*58b9f456SAndroid Build Coastguard Worker # (because of deprecated overload) 171*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-wd654) 172*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-Wthread-safety) 173*58b9f456SAndroid Build Coastguard Worker if (HAVE_CXX_FLAG_WTHREAD_SAFETY) 174*58b9f456SAndroid Build Coastguard Worker cxx_feature_check(THREAD_SAFETY_ATTRIBUTES) 175*58b9f456SAndroid Build Coastguard Worker endif() 176*58b9f456SAndroid Build Coastguard Worker 177*58b9f456SAndroid Build Coastguard Worker # On most UNIX like platforms g++ and clang++ define _GNU_SOURCE as a 178*58b9f456SAndroid Build Coastguard Worker # predefined macro, which turns on all of the wonderful libc extensions. 179*58b9f456SAndroid Build Coastguard Worker # However g++ doesn't do this in Cygwin so we have to define it ourselfs 180*58b9f456SAndroid Build Coastguard Worker # since we depend on GNU/POSIX/BSD extensions. 181*58b9f456SAndroid Build Coastguard Worker if (CYGWIN) 182*58b9f456SAndroid Build Coastguard Worker add_definitions(-D_GNU_SOURCE=1) 183*58b9f456SAndroid Build Coastguard Worker endif() 184*58b9f456SAndroid Build Coastguard Worker 185*58b9f456SAndroid Build Coastguard Worker # Link time optimisation 186*58b9f456SAndroid Build Coastguard Worker if (BENCHMARK_ENABLE_LTO) 187*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-flto) 188*58b9f456SAndroid Build Coastguard Worker if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") 189*58b9f456SAndroid Build Coastguard Worker find_program(GCC_AR gcc-ar) 190*58b9f456SAndroid Build Coastguard Worker if (GCC_AR) 191*58b9f456SAndroid Build Coastguard Worker set(CMAKE_AR ${GCC_AR}) 192*58b9f456SAndroid Build Coastguard Worker endif() 193*58b9f456SAndroid Build Coastguard Worker find_program(GCC_RANLIB gcc-ranlib) 194*58b9f456SAndroid Build Coastguard Worker if (GCC_RANLIB) 195*58b9f456SAndroid Build Coastguard Worker set(CMAKE_RANLIB ${GCC_RANLIB}) 196*58b9f456SAndroid Build Coastguard Worker endif() 197*58b9f456SAndroid Build Coastguard Worker elseif("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") 198*58b9f456SAndroid Build Coastguard Worker include(llvm-toolchain) 199*58b9f456SAndroid Build Coastguard Worker endif() 200*58b9f456SAndroid Build Coastguard Worker endif() 201*58b9f456SAndroid Build Coastguard Worker 202*58b9f456SAndroid Build Coastguard Worker # Coverage build type 203*58b9f456SAndroid Build Coastguard Worker set(BENCHMARK_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG}" 204*58b9f456SAndroid Build Coastguard Worker CACHE STRING "Flags used by the C++ compiler during coverage builds." 205*58b9f456SAndroid Build Coastguard Worker FORCE) 206*58b9f456SAndroid Build Coastguard Worker set(BENCHMARK_EXE_LINKER_FLAGS_COVERAGE "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" 207*58b9f456SAndroid Build Coastguard Worker CACHE STRING "Flags used for linking binaries during coverage builds." 208*58b9f456SAndroid Build Coastguard Worker FORCE) 209*58b9f456SAndroid Build Coastguard Worker set(BENCHMARK_SHARED_LINKER_FLAGS_COVERAGE "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" 210*58b9f456SAndroid Build Coastguard Worker CACHE STRING "Flags used by the shared libraries linker during coverage builds." 211*58b9f456SAndroid Build Coastguard Worker FORCE) 212*58b9f456SAndroid Build Coastguard Worker mark_as_advanced( 213*58b9f456SAndroid Build Coastguard Worker BENCHMARK_CXX_FLAGS_COVERAGE 214*58b9f456SAndroid Build Coastguard Worker BENCHMARK_EXE_LINKER_FLAGS_COVERAGE 215*58b9f456SAndroid Build Coastguard Worker BENCHMARK_SHARED_LINKER_FLAGS_COVERAGE) 216*58b9f456SAndroid Build Coastguard Worker set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING 217*58b9f456SAndroid Build Coastguard Worker "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage.") 218*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(--coverage COVERAGE) 219*58b9f456SAndroid Build Coastguard Workerendif() 220*58b9f456SAndroid Build Coastguard Worker 221*58b9f456SAndroid Build Coastguard Workerif (BENCHMARK_USE_LIBCXX) 222*58b9f456SAndroid Build Coastguard Worker if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") 223*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-stdlib=libc++) 224*58b9f456SAndroid Build Coastguard Worker elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR 225*58b9f456SAndroid Build Coastguard Worker "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") 226*58b9f456SAndroid Build Coastguard Worker add_cxx_compiler_flag(-nostdinc++) 227*58b9f456SAndroid Build Coastguard Worker message(WARNING "libc++ header path must be manually specified using CMAKE_CXX_FLAGS") 228*58b9f456SAndroid Build Coastguard Worker # Adding -nodefaultlibs directly to CMAKE_<TYPE>_LINKER_FLAGS will break 229*58b9f456SAndroid Build Coastguard Worker # configuration checks such as 'find_package(Threads)' 230*58b9f456SAndroid Build Coastguard Worker list(APPEND BENCHMARK_CXX_LINKER_FLAGS -nodefaultlibs) 231*58b9f456SAndroid Build Coastguard Worker # -lc++ cannot be added directly to CMAKE_<TYPE>_LINKER_FLAGS because 232*58b9f456SAndroid Build Coastguard Worker # linker flags appear before all linker inputs and -lc++ must appear after. 233*58b9f456SAndroid Build Coastguard Worker list(APPEND BENCHMARK_CXX_LIBRARIES c++) 234*58b9f456SAndroid Build Coastguard Worker else() 235*58b9f456SAndroid Build Coastguard Worker message(FATAL_ERROR "-DBENCHMARK_USE_LIBCXX:BOOL=ON is not supported for compiler") 236*58b9f456SAndroid Build Coastguard Worker endif() 237*58b9f456SAndroid Build Coastguard Workerendif(BENCHMARK_USE_LIBCXX) 238*58b9f456SAndroid Build Coastguard Worker 239*58b9f456SAndroid Build Coastguard Worker# C++ feature checks 240*58b9f456SAndroid Build Coastguard Worker# Determine the correct regular expression engine to use 241*58b9f456SAndroid Build Coastguard Workercxx_feature_check(STD_REGEX) 242*58b9f456SAndroid Build Coastguard Workercxx_feature_check(GNU_POSIX_REGEX) 243*58b9f456SAndroid Build Coastguard Workercxx_feature_check(POSIX_REGEX) 244*58b9f456SAndroid Build Coastguard Workerif(NOT HAVE_STD_REGEX AND NOT HAVE_GNU_POSIX_REGEX AND NOT HAVE_POSIX_REGEX) 245*58b9f456SAndroid Build Coastguard Worker message(FATAL_ERROR "Failed to determine the source files for the regular expression backend") 246*58b9f456SAndroid Build Coastguard Workerendif() 247*58b9f456SAndroid Build Coastguard Workerif (NOT BENCHMARK_ENABLE_EXCEPTIONS AND HAVE_STD_REGEX 248*58b9f456SAndroid Build Coastguard Worker AND NOT HAVE_GNU_POSIX_REGEX AND NOT HAVE_POSIX_REGEX) 249*58b9f456SAndroid Build Coastguard Worker message(WARNING "Using std::regex with exceptions disabled is not fully supported") 250*58b9f456SAndroid Build Coastguard Workerendif() 251*58b9f456SAndroid Build Coastguard Workercxx_feature_check(STEADY_CLOCK) 252*58b9f456SAndroid Build Coastguard Worker# Ensure we have pthreads 253*58b9f456SAndroid Build Coastguard Workerfind_package(Threads REQUIRED) 254*58b9f456SAndroid Build Coastguard Worker 255*58b9f456SAndroid Build Coastguard Worker# Set up directories 256*58b9f456SAndroid Build Coastguard Workerinclude_directories(${PROJECT_SOURCE_DIR}/include) 257*58b9f456SAndroid Build Coastguard Worker 258*58b9f456SAndroid Build Coastguard Worker# Build the targets 259*58b9f456SAndroid Build Coastguard Workeradd_subdirectory(src) 260*58b9f456SAndroid Build Coastguard Worker 261*58b9f456SAndroid Build Coastguard Workerif (BENCHMARK_ENABLE_TESTING) 262*58b9f456SAndroid Build Coastguard Worker enable_testing() 263*58b9f456SAndroid Build Coastguard Worker if (BENCHMARK_ENABLE_GTEST_TESTS) 264*58b9f456SAndroid Build Coastguard Worker include(HandleGTest) 265*58b9f456SAndroid Build Coastguard Worker endif() 266*58b9f456SAndroid Build Coastguard Worker add_subdirectory(test) 267*58b9f456SAndroid Build Coastguard Workerendif() 268