Download googlebenchmark if not found; requires cmake 3.11
This commit is contained in:
		@@ -9,7 +9,24 @@ if(NOT TARGET spdlog)
 | 
				
			|||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
find_package(Threads REQUIRED)
 | 
					find_package(Threads REQUIRED)
 | 
				
			||||||
find_package(benchmark CONFIG REQUIRED)
 | 
					find_package(benchmark CONFIG)
 | 
				
			||||||
 | 
					if (NOT benchmark_FOUND)
 | 
				
			||||||
 | 
					    message(STATUS "Using CMake Version ${CMAKE_VERSION}")
 | 
				
			||||||
 | 
					    if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.11.0")
 | 
				
			||||||
 | 
					        # User can fetch googlebenchmark 			
 | 
				
			||||||
 | 
					        message(STATUS "Downloading GoogleBenchmark")
 | 
				
			||||||
 | 
					        include(FetchContent)
 | 
				
			||||||
 | 
					        set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE INTERNAL "")
 | 
				
			||||||
 | 
					        # Do not build and run googlebenchmark tests
 | 
				
			||||||
 | 
					        FetchContent_Declare(googlebenchmark
 | 
				
			||||||
 | 
					            GIT_REPOSITORY https://github.com/google/benchmark.git
 | 
				
			||||||
 | 
					            GIT_TAG v1.5.2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        FetchContent_MakeAvailable(googlebenchmark)
 | 
				
			||||||
 | 
					    else()
 | 
				
			||||||
 | 
					        message(FATAL_ERROR "GoogleBenchmark is missing. Use CMake >= 3.11 or download it")
 | 
				
			||||||
 | 
					    endif()
 | 
				
			||||||
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_executable(bench bench.cpp)
 | 
					add_executable(bench bench.cpp)
 | 
				
			||||||
spdlog_enable_warnings(bench)
 | 
					spdlog_enable_warnings(bench)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user