Adds vcpkg integration and updates build configuration

Configures CMakePresets.json to utilize vcpkg for dependency management.
Adds support for building with vcpkg.

Adds error message for missing VCPKG_ROOT environment variable.
Adds explicit VCPKG_MANIFEST_FEATURES and VCPKG_INSTALLED_DIR to CMakePresets.json.
Adds benchmark dependency to vcpkg.json.
This commit is contained in:
2025-10-27 07:53:53 +03:00
parent 81aef68143
commit 878e3358c0
3 changed files with 21 additions and 9 deletions

View File

@@ -23,7 +23,13 @@ option(OMATH_SUPRESS_SAFETY_CHECKS "Supress some safety checks in release build
option(OMATH_USE_UNITY_BUILD "Will enable unity build to speed up compilation" OFF) option(OMATH_USE_UNITY_BUILD "Will enable unity build to speed up compilation" OFF)
option(OMATH_ENABLE_LEGACY "Will enable legacy classes that MUST be used ONLY for backward compatibility" OFF) option(OMATH_ENABLE_LEGACY "Will enable legacy classes that MUST be used ONLY for backward compatibility" OFF)
if (CMAKE_TOOLCHAIN_FILE AND VCPKG_MANIFEST_FEATURES) option(OMATH_BUILD_VIA_VCPKG "Will enable building using vcpkg, vcpkg will override some options that were set in vcpkg.json file, and search for dependencies using vcpkg" OFF)
if (OMATH_BUILD_VIA_VCPKG AND NOT CMAKE_TOOLCHAIN_FILE)
message(FATAL_ERROR "[${PROJECT_NAME}] CMAKE_TOOLCHAIN_FILE IS EMPTY! Please set env variable called 'VCPKG_ROOT' to vcpkg root folder here is an example: 'C:/vcpkg' or '/home/user/vcpkg' ")
endif ()
if (OMATH_BUILD_VIA_VCPKG AND VCPKG_MANIFEST_FEATURES)
foreach (omath_feature IN LISTS VCPKG_MANIFEST_FEATURES) foreach (omath_feature IN LISTS VCPKG_MANIFEST_FEATURES)
if (omath_feature STREQUAL "imgui") if (omath_feature STREQUAL "imgui")
set(OMATH_IMGUI_INTEGRATION ON) set(OMATH_IMGUI_INTEGRATION ON)
@@ -56,6 +62,7 @@ if (${PROJECT_IS_TOP_LEVEL})
message(STATUS "[${PROJECT_NAME}]: AVX2 feature status ${OMATH_USE_AVX2}") message(STATUS "[${PROJECT_NAME}]: AVX2 feature status ${OMATH_USE_AVX2}")
message(STATUS "[${PROJECT_NAME}]: ImGUI integration feature status ${OMATH_IMGUI_INTEGRATION}") message(STATUS "[${PROJECT_NAME}]: ImGUI integration feature status ${OMATH_IMGUI_INTEGRATION}")
message(STATUS "[${PROJECT_NAME}]: Legacy features support ${OMATH_ENABLE_LEGACY}") message(STATUS "[${PROJECT_NAME}]: Legacy features support ${OMATH_ENABLE_LEGACY}")
message(STATUS "[${PROJECT_NAME}]: Building using vcpkg ${OMATH_BUILD_VIA_VCPKG}")
endif () endif ()
file(GLOB_RECURSE OMATH_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp") file(GLOB_RECURSE OMATH_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp")

View File

@@ -8,7 +8,11 @@
"binaryDir": "${sourceDir}/cmake-build/build/${presetName}", "binaryDir": "${sourceDir}/cmake-build/build/${presetName}",
"installDir": "${sourceDir}/cmake-build/install/${presetName}", "installDir": "${sourceDir}/cmake-build/install/${presetName}",
"cacheVariables": { "cacheVariables": {
"CMAKE_CXX_COMPILER": "cl.exe" "CMAKE_CXX_COMPILER": "cl.exe",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_MANIFEST_FEATURES": "imgui;avx2;tests",
"VCPKG_INSTALLED_DIR": "${sourceDir}/cmake-build/vcpkg_installed",
"CMAKE_MAKE_PROGRAM": "Ninja"
}, },
"condition": { "condition": {
"type": "equals", "type": "equals",

View File

@@ -4,6 +4,7 @@
"description": "General purpose math library", "description": "General purpose math library",
"homepage": "https://github.com/orange-cpp/omath", "homepage": "https://github.com/orange-cpp/omath",
"license": "Zlib", "license": "Zlib",
"builtin-baseline": "b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01",
"supports": "windows | linux", "supports": "windows | linux",
"dependencies": [ "dependencies": [
{ {
@@ -20,6 +21,12 @@
"description": "Omath will use AVX2 to boost performance", "description": "Omath will use AVX2 to boost performance",
"supports": "!arm" "supports": "!arm"
}, },
"benchmark": {
"description": "Build benchmarks",
"dependencies": [
"benchmark"
]
},
"imgui": { "imgui": {
"description": "Omath will define method to convert omath types to imgui types", "description": "Omath will define method to convert omath types to imgui types",
"dependencies": [ "dependencies": [
@@ -31,12 +38,6 @@
"dependencies": [ "dependencies": [
"gtest" "gtest"
] ]
},
"benchmark": {
"description": "Build benchmarks",
"dependencies": [
"benchmark"
]
} }
} }
} }