Commit 7543786c authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Adding cmake install of Google benchmark.

parent 941fe28f
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -155,6 +155,9 @@ endif()
# https://en.cppreference.com/w/cpp/filesystem
link_libraries( stdc++fs )

####
# Gtest install
#
# gtest has to be built before we add the MPI flags
if( ${BUILD_TESTS} OR ${BUILD_MATRIX_TESTS} )
   enable_testing()
@@ -179,6 +182,14 @@ if( ${BUILD_TESTS} OR ${BUILD_MATRIX_TESTS} )
   endif()
endif()

####
# Gbenchmark install
#
if( ${BUILD_BENCHMARKS} )
   include( BuildGBenchmark )
endif()


####
# Check for OpenMP
#
+38 −0
Original line number Diff line number Diff line
# Gtest developers recommend to build the gtest libraries directly from
# the projects' build systems, see
# https://github.com/google/googletest/tree/master/googletest#incorporating-into-an-existing-cmake-project

#find_package( GTest )
#if( GTEST_FOUND )
#   set( CXX_TESTS_FLAGS "${CXX_TESTS_FLAGS} -DHAVE_GTEST" )
#endif( GTEST_FOUND )


# compatibility with the GTest package
set( GTEST_BOTH_LIBRARIES gtest gtest_main )
set( CXX_TESTS_FLAGS ${CXX_TESTS_FLAGS} -DHAVE_GBENCHMARK )


# Download and unpack googletest at configure time
configure_file(cmake/Gbenchmark.cmake.in googlebenchmark-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -DBENCHMARK_ENABLE_GTEST_TESTS=OFF -G "${CMAKE_GENERATOR}" .
 RESULT_VARIABLE result
 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googlebenchmark-download )
if(result)
 message(FATAL_ERROR "CMake step for google benchmark failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
 RESULT_VARIABLE result
 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googlebenchmark-download )
if(result)
 message(FATAL_ERROR "Build step for google benchmark failed: ${result}")
endif()

# Prevent overriding the parent project's compiler/linker
# settings on Windows
#set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

# Add googletest directly to our build. This defines
# the gbenchmark and gbenchmark_main targets.
add_subdirectory(${CMAKE_BINARY_DIR}/googlebenchmark-src
                ${CMAKE_BINARY_DIR}/googlebenchmark-build)
+24 −0
Original line number Diff line number Diff line
# vim: ft=cmake

# This is a separate template for CMakeLists.txt to build google benchmark as a separate project
#
cmake_minimum_required(VERSION 2.8.2)

project(googlebenchmark-download NONE)

include(ExternalProject)
ExternalProject_Add(googlebenchmark
  GIT_REPOSITORY    https://github.com/google/benchmark.git
  #GIT_TAG           master
  # build from a stable branch instead of master (which gets broken pretty often)
  GIT_TAG           v1.5.3
  SOURCE_DIR        "${CMAKE_BINARY_DIR}/googlebenchmark-src"
  BINARY_DIR        "${CMAKE_BINARY_DIR}/googlebenchmark-build"
  CONFIGURE_COMMAND ""
  BUILD_COMMAND     ""
  INSTALL_COMMAND   ""
  TEST_COMMAND      ""
  # Disable update of the external project in an offline build
  # reference: https://stackoverflow.com/a/40423683
  UPDATE_DISCONNECTED ${OFFLINE_BUILD}
)