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.
This commit is contained in:
2025-10-27 06:42:43 +03:00
parent 69575c1cb3
commit 81aef68143
2 changed files with 18 additions and 2 deletions

View File

@@ -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)

View File

@@ -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"
]
}
}
}