diff --git a/CMakeLists.txt b/CMakeLists.txt index d68071c..d57f26e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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_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) if (omath_feature STREQUAL "imgui") 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}]: ImGUI integration feature status ${OMATH_IMGUI_INTEGRATION}") message(STATUS "[${PROJECT_NAME}]: Legacy features support ${OMATH_ENABLE_LEGACY}") + message(STATUS "[${PROJECT_NAME}]: Building using vcpkg ${OMATH_BUILD_VIA_VCPKG}") endif () file(GLOB_RECURSE OMATH_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp") diff --git a/CMakePresets.json b/CMakePresets.json index a37b0c3..5f13630 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -8,7 +8,11 @@ "binaryDir": "${sourceDir}/cmake-build/build/${presetName}", "installDir": "${sourceDir}/cmake-build/install/${presetName}", "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": { "type": "equals", diff --git a/vcpkg.json b/vcpkg.json index 1fd4afc..519781d 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -4,6 +4,7 @@ "description": "General purpose math library", "homepage": "https://github.com/orange-cpp/omath", "license": "Zlib", + "builtin-baseline": "b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01", "supports": "windows | linux", "dependencies": [ { @@ -20,6 +21,12 @@ "description": "Omath will use AVX2 to boost performance", "supports": "!arm" }, + "benchmark": { + "description": "Build benchmarks", + "dependencies": [ + "benchmark" + ] + }, "imgui": { "description": "Omath will define method to convert omath types to imgui types", "dependencies": [ @@ -31,12 +38,6 @@ "dependencies": [ "gtest" ] - }, - "benchmark": { - "description": "Build benchmarks", - "dependencies": [ - "benchmark" - ] } } -} \ No newline at end of file +}