mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
Merge pull request #92 from orange-cpp/feature/projection_utility
added vcpkg integration
This commit is contained in:
21
.github/workflows/cmake-multi-platform.yml
vendored
21
.github/workflows/cmake-multi-platform.yml
vendored
@@ -19,23 +19,28 @@ jobs:
|
||||
name: Arch Linux (Clang)
|
||||
runs-on: ubuntu-latest
|
||||
container: archlinux:latest
|
||||
|
||||
env:
|
||||
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
|
||||
steps:
|
||||
- name: Install basic tool-chain with pacman
|
||||
shell: bash
|
||||
run: |
|
||||
pacman -Sy --noconfirm archlinux-keyring
|
||||
pacman -Syu --noconfirm --needed \
|
||||
git base-devel clang cmake ninja
|
||||
git base-devel clang cmake ninja zip unzip fmt
|
||||
|
||||
- name: Checkout repository (with sub-modules)
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Set up vcpkg
|
||||
shell: bash
|
||||
run: |
|
||||
git clone https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
|
||||
- name: Configure (cmake --preset)
|
||||
shell: bash
|
||||
run: cmake --preset linux-release -DOMATH_BUILD_TESTS=ON -DOMATH_BUILD_BENCHMARK=OFF
|
||||
run: cmake --preset linux-release -DOMATH_BUILD_TESTS=ON -DOMATH_BUILD_BENCHMARK=OFF -DOMATH_BUILD_VIA_VCPKG=ON -DVCPKG_MANIFEST_FEATURES="imgui;avx2;tests"
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
@@ -47,12 +52,14 @@ jobs:
|
||||
|
||||
|
||||
|
||||
##############################################################################
|
||||
# 2) Windows – MSVC / Ninja
|
||||
##############################################################################
|
||||
##############################################################################
|
||||
# 2) Windows – MSVC / Ninja
|
||||
##############################################################################
|
||||
windows-build-and-test:
|
||||
name: Windows (MSVC)
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
OMATH_BUILD_VIA_VCPKG: ON
|
||||
|
||||
steps:
|
||||
- name: Checkout repository (with sub-modules)
|
||||
@@ -68,7 +75,7 @@ jobs:
|
||||
|
||||
- name: Configure (cmake --preset)
|
||||
shell: bash
|
||||
run: cmake --preset windows-release -DOMATH_BUILD_TESTS=ON -DOMATH_BUILD_BENCHMARK=OFF
|
||||
run: cmake --preset windows-release -DOMATH_BUILD_TESTS=ON -DOMATH_BUILD_BENCHMARK=OFF -DOMATH_BUILD_VIA_VCPKG=ON -DVCPKG_MANIFEST_FEATURES="imgui;avx2;tests"
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
|
||||
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -1,6 +0,0 @@
|
||||
[submodule "extlibs/googletest"]
|
||||
path = extlibs/googletest
|
||||
url = https://github.com/google/googletest.git
|
||||
[submodule "extlibs/benchmark"]
|
||||
path = extlibs/benchmark
|
||||
url = https://github.com/google/benchmark.git
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.26)
|
||||
|
||||
project(omath VERSION 3.9.2 LANGUAGES CXX)
|
||||
project(omath VERSION 4.0.0 LANGUAGES CXX)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(CheckCXXCompilerFlag)
|
||||
@@ -12,7 +12,7 @@ else ()
|
||||
endif ()
|
||||
|
||||
option(OMATH_BUILD_TESTS "Build unit tests" ${PROJECT_IS_TOP_LEVEL})
|
||||
option(OMATH_BUILD_BENCHMARK "Build benchmarks" ${PROJECT_IS_TOP_LEVEL})
|
||||
option(OMATH_BUILD_BENCHMARK "Build benchmarks" OFF)
|
||||
option(OMATH_THREAT_WARNING_AS_ERROR "Set highest level of warnings and force compiler to treat them as errors" ON)
|
||||
option(OMATH_BUILD_AS_SHARED_LIBRARY "Build Omath as .so or .dll" OFF)
|
||||
option(OMATH_USE_AVX2 "Omath will use AVX2 to boost performance" ${COMPILER_SUPPORTS_AVX2})
|
||||
@@ -21,7 +21,28 @@ option(OMATH_BUILD_EXAMPLES "Build example projects with you can learn & play" O
|
||||
option(OMATH_STATIC_MSVC_RUNTIME_LIBRARY "Force Omath to link static runtime" OFF)
|
||||
option(OMATH_SUPRESS_SAFETY_CHECKS "Supress some safety checks in release build to improve general performance" ON)
|
||||
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" ON)
|
||||
|
||||
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)
|
||||
elseif (omath_feature STREQUAL "avx2")
|
||||
set(OMATH_USE_AVX2 ${COMPILER_SUPPORTS_AVX2})
|
||||
elseif (omath_feature STREQUAL "tests")
|
||||
set(OMATH_BUILD_TESTS ON)
|
||||
elseif (omath_feature STREQUAL "benchmark")
|
||||
set(OMATH_BUILD_BENCHMARK ON)
|
||||
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.")
|
||||
@@ -40,6 +61,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")
|
||||
@@ -84,7 +106,7 @@ if (OMATH_SUPRESS_SAFETY_CHECKS)
|
||||
endif ()
|
||||
|
||||
if (OMATH_ENABLE_LEGACY)
|
||||
target_compile_options(${PROJECT_NAME} PUBLIC OMATH_ENABLE_LEGACY)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_ENABLE_LEGACY)
|
||||
endif ()
|
||||
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
@@ -117,9 +139,6 @@ endif ()
|
||||
|
||||
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23)
|
||||
|
||||
add_subdirectory(extlibs)
|
||||
|
||||
|
||||
if (OMATH_BUILD_TESTS)
|
||||
add_subdirectory(tests)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_BUILD_TESTS)
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
"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_INSTALLED_DIR": "${sourceDir}/cmake-build/vcpkg_installed",
|
||||
"CMAKE_MAKE_PROGRAM": "Ninja"
|
||||
},
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
@@ -24,6 +27,25 @@
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-debug-vcpkg",
|
||||
"displayName": "Debug",
|
||||
"inherits": "windows-base",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug",
|
||||
"OMATH_BUILD_VIA_VCPKG": "ON",
|
||||
"VCPKG_MANIFEST_FEATURES": "tests;imgui;avx2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-release-vcpkg",
|
||||
"displayName": "Release",
|
||||
"inherits": "windows-base",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"OMATH_BUILD_VIA_VCPKG": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-release",
|
||||
"displayName": "Release",
|
||||
@@ -39,7 +61,10 @@
|
||||
"binaryDir": "${sourceDir}/cmake-build/build/${presetName}",
|
||||
"installDir": "${sourceDir}/cmake-build/install/${presetName}",
|
||||
"cacheVariables": {
|
||||
"CMAKE_CXX_COMPILER": "clang++"
|
||||
"CMAKE_CXX_COMPILER": "clang++",
|
||||
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
|
||||
"VCPKG_INSTALLED_DIR": "${sourceDir}/cmake-build/vcpkg_installed",
|
||||
"CMAKE_MAKE_PROGRAM": "ninja"
|
||||
},
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
@@ -55,6 +80,15 @@
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-debug-vcpkg",
|
||||
"displayName": "Linux Debug",
|
||||
"inherits": "linux-base",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug",
|
||||
"OMATH_BUILD_VIA_VCPKG": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-release",
|
||||
"displayName": "Linux Release",
|
||||
@@ -63,6 +97,15 @@
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-release-vcpkg",
|
||||
"displayName": "Linux Release",
|
||||
"inherits": "linux-debug",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"OMATH_BUILD_VIA_VCPKG": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "darwin-base",
|
||||
"hidden": true,
|
||||
@@ -86,6 +129,15 @@
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "darwin-debug-vcpkg",
|
||||
"displayName": "Darwin Debug",
|
||||
"inherits": "darwin-base",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug",
|
||||
"OMATH_BUILD_VIA_VCPKG": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "darwin-release",
|
||||
"displayName": "Darwin Release",
|
||||
@@ -93,6 +145,15 @@
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "darwin-release-vcpkg",
|
||||
"displayName": "Darwin Release",
|
||||
"inherits": "darwin-debug",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"OMATH_BUILD_VIA_VCPKG": "ON"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -11,5 +11,9 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
CXX_STANDARD 23
|
||||
CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark omath)
|
||||
if (TARGET benchmark::benchmark)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark omath)
|
||||
else()
|
||||
find_package(benchmark CONFIG REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark omath)
|
||||
endif ()
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
if (OMATH_BUILD_TESTS)
|
||||
add_subdirectory(googletest)
|
||||
endif ()
|
||||
|
||||
if (OMATH_BUILD_BENCHMARK)
|
||||
set(BENCHMARK_ENABLE_TESTING OFF)
|
||||
add_subdirectory(benchmark)
|
||||
endif ()
|
||||
Submodule extlibs/benchmark deleted from 2948b6a2e6
Submodule extlibs/googletest deleted from 52eb8108c5
@@ -39,6 +39,7 @@ namespace omath
|
||||
class Mat final
|
||||
{
|
||||
public:
|
||||
using ContainedType = Type;
|
||||
constexpr Mat() noexcept
|
||||
{
|
||||
clear();
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace omath
|
||||
}
|
||||
#ifdef OMATH_IMGUI_INTEGRATION
|
||||
[[nodiscard]]
|
||||
ImVec2 to_im_vec2() const noexcept
|
||||
constexpr ImVec2 to_im_vec2() const noexcept
|
||||
{
|
||||
return {static_cast<float>(this->x), static_cast<float>(this->y)};
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace omath
|
||||
|
||||
#ifdef OMATH_IMGUI_INTEGRATION
|
||||
[[nodiscard]]
|
||||
ImVec4 to_im_vec4() const noexcept
|
||||
constexpr ImVec4 to_im_vec4() const noexcept
|
||||
{
|
||||
return {
|
||||
static_cast<float>(this->x),
|
||||
|
||||
@@ -233,7 +233,8 @@ namespace
|
||||
constexpr bool invalid_nt_header_file(const NtHeaderVariant& variant)
|
||||
{
|
||||
constexpr std::uint32_t nt_hdr_magic = 0x4550;
|
||||
return std::visit([](const auto& header) -> bool { return header.signature != nt_hdr_magic; }, variant);
|
||||
return std::visit([&nt_hdr_magic](const auto& header) -> bool { return header.signature != nt_hdr_magic; },
|
||||
variant);
|
||||
}
|
||||
|
||||
struct ExtractedSection
|
||||
|
||||
@@ -15,5 +15,11 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE gtest gtest_main omath::omath)
|
||||
|
||||
if (TARGET gtest)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE gtest gtest_main omath::omath)
|
||||
else()
|
||||
find_package(GTest CONFIG REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE GTest::gtest GTest::gtest_main omath::omath)
|
||||
endif()
|
||||
gtest_discover_tests(${PROJECT_NAME})
|
||||
39
tests/general/unit_test_imgui_intergration.cpp
Normal file
39
tests/general/unit_test_imgui_intergration.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Created by Vlad on 10/23/2025.
|
||||
//
|
||||
#ifdef OMATH_IMGUI_INTEGRATION
|
||||
#include <omath/omath.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
#include <imgui.h>
|
||||
|
||||
|
||||
|
||||
using namespace omath;
|
||||
|
||||
TEST(unit_test_imgui_intergration, Vector2ToImVec2)
|
||||
{
|
||||
constexpr Vector2 omath_vector_2d = {1.f, 2.f};
|
||||
constexpr ImVec2 imgui_vector_2d = {1, 2.f};
|
||||
|
||||
constexpr auto converted = omath_vector_2d.to_im_vec2();
|
||||
EXPECT_NEAR(converted.x, imgui_vector_2d.x, 1.e-5f);
|
||||
EXPECT_NEAR(converted.y, imgui_vector_2d.y, 1.e-5f);
|
||||
}
|
||||
|
||||
TEST(unit_test_imgui_intergration, Vector4ToImVec4)
|
||||
{
|
||||
constexpr Vector4 omath_vector_2d = {1.f, 2.f, 3.f, 4.f};
|
||||
constexpr ImVec4 imgui_vector_4d = {1, 2.f, 3.f, 4.f};
|
||||
|
||||
constexpr auto converted = omath_vector_2d.to_im_vec4();
|
||||
|
||||
EXPECT_NEAR(converted.x, imgui_vector_4d.x, 1.e-5f);
|
||||
EXPECT_NEAR(converted.y, imgui_vector_4d.y, 1.e-5f);
|
||||
EXPECT_NEAR(converted.z, imgui_vector_4d.z, 1.e-5f);
|
||||
EXPECT_NEAR(converted.w, imgui_vector_4d.w, 1.e-5f);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
14
vcpkg-configuration.json
Normal file
14
vcpkg-configuration.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"default-registry": {
|
||||
"kind": "git",
|
||||
"baseline": "b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01",
|
||||
"repository": "https://github.com/microsoft/vcpkg"
|
||||
},
|
||||
"registries": [
|
||||
{
|
||||
"kind": "artifact",
|
||||
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
|
||||
"name": "microsoft"
|
||||
}
|
||||
]
|
||||
}
|
||||
42
vcpkg.json
Normal file
42
vcpkg.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "omath",
|
||||
"version": "3.10.1",
|
||||
"description": "General purpose math library",
|
||||
"homepage": "https://github.com/orange-cpp/omath",
|
||||
"license": "Zlib",
|
||||
"supports": "windows | linux",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "vcpkg-cmake",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake-config",
|
||||
"host": true
|
||||
}
|
||||
],
|
||||
"features": {
|
||||
"avx2": {
|
||||
"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": [
|
||||
"imgui"
|
||||
]
|
||||
},
|
||||
"tests": {
|
||||
"description": "Build unit-tests using GTest",
|
||||
"dependencies": [
|
||||
"gtest"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user