Skip to content

Commit

Permalink
Fix CMake benchmark build to not build googlebenchmark tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesYang007 committed May 4, 2020
1 parent a1508da commit ebd6588
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
16 changes: 7 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,25 @@ if (FastAD_FOUND)
set(AUTOPPL_LIBS ${AUTOPPL_LIBS} FastAD::FastAD)
endif()

# Set directory for GoogleTest
set(GTEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/benchmark/googletest/googletest)
set(GBENCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/benchmark)

# Add lib subdirectory
add_subdirectory(${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}/lib)

# Configure tests
if (AUTOPPL_ENABLE_TEST)
include(CTest) # enable memcheck
enable_testing()

# Set directories for third-party libraries
# tests in other subdirectories require access to these as well
set(GTEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/benchmark/googletest/googletest)

add_subdirectory(${PROJECT_SOURCE_DIR}/test ${PROJECT_BINARY_DIR}/test)
endif()

# Configure benchmarking
if (AUTOPPL_ENABLE_BENCHMARK)
add_subdirectory(${PROJECT_SOURCE_DIR}/benchmark ${PROJECT_BINARY_DIR}/benchmark)
set(GBENCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/benchmark)
endif()

# Add lib subdirectory
add_subdirectory(${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}/lib)

# Compile examples if enabled
if (AUTOPPL_ENABLE_EXAMPLE)
add_subdirectory(${PROJECT_SOURCE_DIR}/docs/example ${PROJECT_BINARY_DIR}/example)
Expand Down
6 changes: 3 additions & 3 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ if (AUTOPPL_ENABLE_BENCHMARK)
# Taken from https://github.com/google/benchmark
# Recommended way to build google benchmark
# Disable all tests within google benchmark.
set(BENCHMARK_ENABLE_TESTING OFF)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
set(BENCHMARK_ENABLE_ASSEMBLY_TESTS OFF)
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable GoogleBenchmark tests.")
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable GoogleBenchmark googletest tests.")
set(BENCHMARK_ENABLE_ASSEMBLY_TESTS OFF CACHE BOOL "Disable GoogleBenchmark assembly tests.")
add_subdirectory(benchmark)
endif()

Expand Down

0 comments on commit ebd6588

Please sign in to comment.