-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
12 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,19 @@ | ||
find_package(benchmark QUIET) | ||
|
||
if(benchmark_FOUND) | ||
add_library(benchmarkLib ALIAS benchmark::benchmark) | ||
add_library(benchmarkInc ALIAS benchmark::benchmark) | ||
else() | ||
include(ExternalProject) | ||
if(NOT benchmark_FOUND) | ||
include(FetchContent) | ||
|
||
ExternalProject_Add( | ||
benchmarkBuild | ||
set(BENCHMARK_ENABLE_TESTING Off) | ||
FetchContent_Declare( | ||
benchmark | ||
GIT_REPOSITORY https://github.com/google/benchmark | ||
GIT_TAG v1.5.5 | ||
PREFIX external | ||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/external | ||
-DCMAKE_BUILD_TYPE=Release | ||
-DBENCHMARK_ENABLE_TESTING=Off | ||
GIT_TAG v1.8.4 | ||
) | ||
|
||
add_library(benchmarkLib STATIC IMPORTED) | ||
set_target_properties(benchmarkLib PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/external/lib/libbenchmark.a) | ||
add_library(benchmarkInc INTERFACE) | ||
target_include_directories(benchmarkInc INTERFACE ${CMAKE_BINARY_DIR}/external/include) | ||
add_dependencies(benchmarkInc benchmarkBuild) | ||
FetchContent_MakeAvailable(benchmark) | ||
endif() | ||
|
||
function(add_benchmark benchname) | ||
add_executable(${benchname} ${ARGN}) | ||
target_link_libraries(${benchname} benchmarkInc benchmarkLib) | ||
target_link_libraries(${benchname} benchmark::benchmark) | ||
endfunction() |