|
| 1 | +# |
| 2 | +# CMake Install Google Benchmark by Parra Studios |
| 3 | +# CMake script to install Google Benchmark library. |
| 4 | +# |
| 5 | +# Copyright (C) 2016 - 2019 Vicente Eduardo Ferrer Garcia <[email protected]> |
| 6 | +# |
| 7 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +# you may not use this file except in compliance with the License. |
| 9 | +# You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +# See the License for the specific language governing permissions and |
| 17 | +# limitations under the License. |
| 18 | +# |
| 19 | + |
| 20 | +# The following variables are set: |
| 21 | +# |
| 22 | +# GBENCH_INCLUDE_DIR - Path where Google Benchmark header is located. |
| 23 | +# GBENCH_LIBRARY - Path where Google Benchmark library is located. |
| 24 | + |
| 25 | +if(NOT GBENCH_FOUND OR USE_BUNDLED_GBENCH) |
| 26 | + if(NOT GBENCH_VERSION OR USE_BUNDLED_GBENCH) |
| 27 | + set(GBENCH_VERSION 1.4.1) |
| 28 | + set(GBENCH_URL_MD5 482dddb22bec43f5507a000456d6bb88) |
| 29 | + endif() |
| 30 | + |
| 31 | + ExternalProject_Add(GoogleBench |
| 32 | + DOWNLOAD_NAME GBench-${GBENCH_VERSION}.tar.gz |
| 33 | + URL https://github.com/google/benchmark/archive/v${GBENCH_VERSION}.tar.gz |
| 34 | + URL_MD5 ${GBENCH_URL_MD5} |
| 35 | + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON |
| 36 | + TEST_COMMAND "" |
| 37 | + ) |
| 38 | + |
| 39 | + ExternalProject_Get_Property(GoogleBench INSTALL_DIR) |
| 40 | + |
| 41 | + if(MSVC) |
| 42 | + set(GBENCH_LIB_SUFFIX "lib") |
| 43 | + else() |
| 44 | + set(GBENCH_LIB_SUFFIX "a") |
| 45 | + endif() |
| 46 | + |
| 47 | + set(GBENCH_ROOT_DIR "${INSTALL_DIR}") |
| 48 | + set(GBENCH_INCLUDE_DIR "${GBENCH_ROOT_DIR}/include") |
| 49 | + set(GBENCH_LIBRARY "${GBENCH_ROOT_DIR}/lib/libbenchmark.${GBENCH_LIB_SUFFIX}") |
| 50 | + set(GBENCH_FOUND TRUE) |
| 51 | + |
| 52 | + mark_as_advanced(GBENCH_INCLUDE_DIR GBENCH_LIBRARY) |
| 53 | + |
| 54 | + message(STATUS "Install Google Benchmark v${GBENCH_VERSION}") |
| 55 | +endif () |
0 commit comments