From 81aef681437cc1cb98f309b9d6f769ff3468dc87 Mon Sep 17 00:00:00 2001 From: Orange Date: Mon, 27 Oct 2025 06:42:43 +0300 Subject: [PATCH] Adds support for tests and benchmarks via Vcpkg features Enables building unit tests using GTest and benchmarks using Benchmark, through Vcpkg features. Adds `tests` and `benchmark` features to `vcpkg.json`, and adds corresponding CMake logic to control their build based on Vcpkg manifest features. --- CMakeLists.txt | 7 ++++++- vcpkg.json | 13 ++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 26df32f..d68071c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,11 +29,16 @@ if (CMAKE_TOOLCHAIN_FILE AND VCPKG_MANIFEST_FEATURES) set(OMATH_IMGUI_INTEGRATION ON) elseif (omath_feature STREQUAL "avx2") set(OMATH_USE_AVX2 ${COMPILER_SUPPORTS_AVX2}) - else() + elseif (omath_feature STREQUAL "tests") + set(OMATH_BUILD_TESTS ON) + elseif (omath_feature STREQUAL "benchmark") + set(OMATH_BUILD_BENCHMARK ON) + else () message(WARNING "[${PROJECT_NAME}]: UNKNOWN VCPKG LIBRARY FEATURE CALLED \"${omath_feature}\" ") endif () endforeach () endif () + if (OMATH_USE_AVX2 AND NOT COMPILER_SUPPORTS_AVX2) message(WARNING "OMATH_USE_AVX2 requested, but compiler/target does not support AVX2. Disabling.") set(OMATH_USE_AVX2 OFF CACHE BOOL "Omath will use AVX2 to boost performance" FORCE) diff --git a/vcpkg.json b/vcpkg.json index 0a8c9c1..1fd4afc 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -14,7 +14,6 @@ "name": "vcpkg-cmake-config", "host": true } - ], "features": { "avx2": { @@ -26,6 +25,18 @@ "dependencies": [ "imgui" ] + }, + "tests": { + "description": "Build unit-tests using GTest", + "dependencies": [ + "gtest" + ] + }, + "benchmark": { + "description": "Build benchmarks", + "dependencies": [ + "benchmark" + ] } } } \ No newline at end of file