I want to use Google Benchmark, for that I have a simple test written in main.cpp file. to build my project I have a CMake file as follow:
cmake_minimum_required(VERSION 3.10)
include_directories(${CMAKE_SOURCE_DIR}/include)
find_library(BENCHMARK_LIBRARY NAMES benchmark HINTS "${CMAKE_SOURCE_DIR}/externals/lib")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# benchmark binary
add_executable(benchmark main.cpp)
target_link_libraries(benchmark ${BENCHMARK_LIBRARY} Threads::Threads)
But every time I run "make" it gives me the error:
In function `benchmark::RunSpecifiedBenchmarks(benchmark::BenchmarkReporter*,
benchmark::BenchmarkReporter*)':
benchmark.cc:(.text+0x214b): undefined reference to `std::thread
::_M_start_thread(std::unique_ptr<std::thread::_State,
std::default_delete<std::thread::_State> >, void (*)())'
What am I doing wrong? I just started working with CMake so I don't have a lot of knowledge. I searched but couldn't get a solution. Thanks in advance for any help.