build: add benchmark
Change-Id: I42977a327869e1d545c140361a9a155ebf13de9e
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 69cd73b..fd65ec9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,6 +18,7 @@
option(DHTNET_NATPMP "Enable NAT-PMP support" ON)
option(DHTNET_TESTABLE "Enable API for tests" ON)
option(BUILD_TOOLS "Build tools" ON)
+option(BUILD_BENCHMARKS "Build benchamrks" ON)
if (NOT MSVC)
find_package (PkgConfig REQUIRED)
@@ -122,6 +123,8 @@
if (NOT upnp_FOUND)
message("libupnp not found: disabling")
set(DHTNET_PUPNP Off)
+ else()
+ set(upnp_LIBRARIES PkgConfig::upnp)
endif()
endif()
if (DHTNET_NATPMP AND NOT MSVC)
@@ -225,6 +228,15 @@
install(TARGETS upnpctrl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
+if (BUILD_BENCHMARKS)
+ add_executable(bench
+ tools/benchmark/main.cpp
+ tools/common.cpp)
+ target_link_libraries(bench PRIVATE dhtnet fmt::fmt)
+ target_include_directories(bench PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools)
+ install(TARGETS bench RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+endif()
+
if (BUILD_TESTING AND NOT MSVC)
pkg_search_module(Cppunit REQUIRED IMPORTED_TARGET cppunit)
add_executable(tests_certstore tests/certstore.cpp)