Skip to content

Commit 495a2a8

Browse files
authored
Merge pull request #92 from orange-cpp/feature/projection_utility
added vcpkg integration
2 parents e2a37f2 + 6fbc010 commit 495a2a8

File tree

17 files changed

+217
-40
lines changed

17 files changed

+217
-40
lines changed

.github/workflows/cmake-multi-platform.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,28 @@ jobs:
1919
name: Arch Linux (Clang)
2020
runs-on: ubuntu-latest
2121
container: archlinux:latest
22-
22+
env:
23+
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
2324
steps:
2425
- name: Install basic tool-chain with pacman
2526
shell: bash
2627
run: |
2728
pacman -Sy --noconfirm archlinux-keyring
2829
pacman -Syu --noconfirm --needed \
29-
git base-devel clang cmake ninja
30+
git base-devel clang cmake ninja zip unzip fmt
3031
3132
- name: Checkout repository (with sub-modules)
3233
uses: actions/checkout@v4
3334
with:
3435
submodules: recursive
3536

37+
- name: Set up vcpkg
38+
shell: bash
39+
run: |
40+
git clone https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
3641
- name: Configure (cmake --preset)
3742
shell: bash
38-
run: cmake --preset linux-release -DOMATH_BUILD_TESTS=ON -DOMATH_BUILD_BENCHMARK=OFF
43+
run: cmake --preset linux-release -DOMATH_BUILD_TESTS=ON -DOMATH_BUILD_BENCHMARK=OFF -DOMATH_BUILD_VIA_VCPKG=ON -DVCPKG_MANIFEST_FEATURES="imgui;avx2;tests"
3944

4045
- name: Build
4146
shell: bash
@@ -47,12 +52,14 @@ jobs:
4752

4853

4954

50-
##############################################################################
51-
# 2) Windows – MSVC / Ninja
52-
##############################################################################
55+
##############################################################################
56+
# 2) Windows – MSVC / Ninja
57+
##############################################################################
5358
windows-build-and-test:
5459
name: Windows (MSVC)
5560
runs-on: windows-latest
61+
env:
62+
OMATH_BUILD_VIA_VCPKG: ON
5663

5764
steps:
5865
- name: Checkout repository (with sub-modules)
@@ -68,7 +75,7 @@ jobs:
6875

6976
- name: Configure (cmake --preset)
7077
shell: bash
71-
run: cmake --preset windows-release -DOMATH_BUILD_TESTS=ON -DOMATH_BUILD_BENCHMARK=OFF
78+
run: cmake --preset windows-release -DOMATH_BUILD_TESTS=ON -DOMATH_BUILD_BENCHMARK=OFF -DOMATH_BUILD_VIA_VCPKG=ON -DVCPKG_MANIFEST_FEATURES="imgui;avx2;tests"
7279

7380
- name: Build
7481
shell: bash

.gitmodules

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +0,0 @@
1-
[submodule "extlibs/googletest"]
2-
path = extlibs/googletest
3-
url = https://github.com/google/googletest.git
4-
[submodule "extlibs/benchmark"]
5-
path = extlibs/benchmark
6-
url = https://github.com/google/benchmark.git

CMakeLists.txt

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.26)
22

3-
project(omath VERSION 3.9.2 LANGUAGES CXX)
3+
project(omath VERSION 4.0.0 LANGUAGES CXX)
44

55
include(CMakePackageConfigHelpers)
66
include(CheckCXXCompilerFlag)
@@ -12,7 +12,7 @@ else ()
1212
endif ()
1313

1414
option(OMATH_BUILD_TESTS "Build unit tests" ${PROJECT_IS_TOP_LEVEL})
15-
option(OMATH_BUILD_BENCHMARK "Build benchmarks" ${PROJECT_IS_TOP_LEVEL})
15+
option(OMATH_BUILD_BENCHMARK "Build benchmarks" OFF)
1616
option(OMATH_THREAT_WARNING_AS_ERROR "Set highest level of warnings and force compiler to treat them as errors" ON)
1717
option(OMATH_BUILD_AS_SHARED_LIBRARY "Build Omath as .so or .dll" OFF)
1818
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
2121
option(OMATH_STATIC_MSVC_RUNTIME_LIBRARY "Force Omath to link static runtime" OFF)
2222
option(OMATH_SUPRESS_SAFETY_CHECKS "Supress some safety checks in release build to improve general performance" ON)
2323
option(OMATH_USE_UNITY_BUILD "Will enable unity build to speed up compilation" OFF)
24-
option(OMATH_ENABLE_LEGACY "Will enable legacy classes that MUST be used ONLY for backward compatibility" OFF)
24+
option(OMATH_ENABLE_LEGACY "Will enable legacy classes that MUST be used ONLY for backward compatibility" ON)
25+
26+
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)
27+
28+
if (OMATH_BUILD_VIA_VCPKG AND NOT CMAKE_TOOLCHAIN_FILE)
29+
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' ")
30+
endif ()
31+
32+
if (OMATH_BUILD_VIA_VCPKG AND VCPKG_MANIFEST_FEATURES)
33+
foreach (omath_feature IN LISTS VCPKG_MANIFEST_FEATURES)
34+
if (omath_feature STREQUAL "imgui")
35+
set(OMATH_IMGUI_INTEGRATION ON)
36+
elseif (omath_feature STREQUAL "avx2")
37+
set(OMATH_USE_AVX2 ${COMPILER_SUPPORTS_AVX2})
38+
elseif (omath_feature STREQUAL "tests")
39+
set(OMATH_BUILD_TESTS ON)
40+
elseif (omath_feature STREQUAL "benchmark")
41+
set(OMATH_BUILD_BENCHMARK ON)
42+
endif ()
43+
44+
endforeach ()
45+
endif ()
2546

2647
if (OMATH_USE_AVX2 AND NOT COMPILER_SUPPORTS_AVX2)
2748
message(WARNING "OMATH_USE_AVX2 requested, but compiler/target does not support AVX2. Disabling.")
@@ -40,6 +61,7 @@ if (${PROJECT_IS_TOP_LEVEL})
4061
message(STATUS "[${PROJECT_NAME}]: AVX2 feature status ${OMATH_USE_AVX2}")
4162
message(STATUS "[${PROJECT_NAME}]: ImGUI integration feature status ${OMATH_IMGUI_INTEGRATION}")
4263
message(STATUS "[${PROJECT_NAME}]: Legacy features support ${OMATH_ENABLE_LEGACY}")
64+
message(STATUS "[${PROJECT_NAME}]: Building using vcpkg ${OMATH_BUILD_VIA_VCPKG}")
4365
endif ()
4466

4567
file(GLOB_RECURSE OMATH_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp")
@@ -84,7 +106,7 @@ if (OMATH_SUPRESS_SAFETY_CHECKS)
84106
endif ()
85107

86108
if (OMATH_ENABLE_LEGACY)
87-
target_compile_options(${PROJECT_NAME} PUBLIC OMATH_ENABLE_LEGACY)
109+
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_ENABLE_LEGACY)
88110
endif ()
89111

90112
set_target_properties(${PROJECT_NAME} PROPERTIES
@@ -117,9 +139,6 @@ endif ()
117139

118140
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23)
119141

120-
add_subdirectory(extlibs)
121-
122-
123142
if (OMATH_BUILD_TESTS)
124143
add_subdirectory(tests)
125144
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_BUILD_TESTS)

CMakePresets.json

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"binaryDir": "${sourceDir}/cmake-build/build/${presetName}",
99
"installDir": "${sourceDir}/cmake-build/install/${presetName}",
1010
"cacheVariables": {
11-
"CMAKE_CXX_COMPILER": "cl.exe"
11+
"CMAKE_CXX_COMPILER": "cl.exe",
12+
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
13+
"VCPKG_INSTALLED_DIR": "${sourceDir}/cmake-build/vcpkg_installed",
14+
"CMAKE_MAKE_PROGRAM": "Ninja"
1215
},
1316
"condition": {
1417
"type": "equals",
@@ -24,6 +27,25 @@
2427
"CMAKE_BUILD_TYPE": "Debug"
2528
}
2629
},
30+
{
31+
"name": "windows-debug-vcpkg",
32+
"displayName": "Debug",
33+
"inherits": "windows-base",
34+
"cacheVariables": {
35+
"CMAKE_BUILD_TYPE": "Debug",
36+
"OMATH_BUILD_VIA_VCPKG": "ON",
37+
"VCPKG_MANIFEST_FEATURES": "tests;imgui;avx2"
38+
}
39+
},
40+
{
41+
"name": "windows-release-vcpkg",
42+
"displayName": "Release",
43+
"inherits": "windows-base",
44+
"cacheVariables": {
45+
"CMAKE_BUILD_TYPE": "Release",
46+
"OMATH_BUILD_VIA_VCPKG": "ON"
47+
}
48+
},
2749
{
2850
"name": "windows-release",
2951
"displayName": "Release",
@@ -39,7 +61,10 @@
3961
"binaryDir": "${sourceDir}/cmake-build/build/${presetName}",
4062
"installDir": "${sourceDir}/cmake-build/install/${presetName}",
4163
"cacheVariables": {
42-
"CMAKE_CXX_COMPILER": "clang++"
64+
"CMAKE_CXX_COMPILER": "clang++",
65+
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
66+
"VCPKG_INSTALLED_DIR": "${sourceDir}/cmake-build/vcpkg_installed",
67+
"CMAKE_MAKE_PROGRAM": "ninja"
4368
},
4469
"condition": {
4570
"type": "equals",
@@ -55,6 +80,15 @@
5580
"CMAKE_BUILD_TYPE": "Debug"
5681
}
5782
},
83+
{
84+
"name": "linux-debug-vcpkg",
85+
"displayName": "Linux Debug",
86+
"inherits": "linux-base",
87+
"cacheVariables": {
88+
"CMAKE_BUILD_TYPE": "Debug",
89+
"OMATH_BUILD_VIA_VCPKG": "ON"
90+
}
91+
},
5892
{
5993
"name": "linux-release",
6094
"displayName": "Linux Release",
@@ -63,6 +97,15 @@
6397
"CMAKE_BUILD_TYPE": "Release"
6498
}
6599
},
100+
{
101+
"name": "linux-release-vcpkg",
102+
"displayName": "Linux Release",
103+
"inherits": "linux-debug",
104+
"cacheVariables": {
105+
"CMAKE_BUILD_TYPE": "Release",
106+
"OMATH_BUILD_VIA_VCPKG": "ON"
107+
}
108+
},
66109
{
67110
"name": "darwin-base",
68111
"hidden": true,
@@ -86,13 +129,31 @@
86129
"CMAKE_BUILD_TYPE": "Debug"
87130
}
88131
},
132+
{
133+
"name": "darwin-debug-vcpkg",
134+
"displayName": "Darwin Debug",
135+
"inherits": "darwin-base",
136+
"cacheVariables": {
137+
"CMAKE_BUILD_TYPE": "Debug",
138+
"OMATH_BUILD_VIA_VCPKG": "ON"
139+
}
140+
},
89141
{
90142
"name": "darwin-release",
91143
"displayName": "Darwin Release",
92144
"inherits": "darwin-debug",
93145
"cacheVariables": {
94146
"CMAKE_BUILD_TYPE": "Release"
95147
}
148+
},
149+
{
150+
"name": "darwin-release-vcpkg",
151+
"displayName": "Darwin Release",
152+
"inherits": "darwin-debug",
153+
"cacheVariables": {
154+
"CMAKE_BUILD_TYPE": "Release",
155+
"OMATH_BUILD_VIA_VCPKG": "ON"
156+
}
96157
}
97158
]
98159
}

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.9.2
1+
4.0.0

benchmark/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
1111
CXX_STANDARD 23
1212
CXX_STANDARD_REQUIRED ON)
1313

14-
15-
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark omath)
14+
if (TARGET benchmark::benchmark)
15+
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark omath)
16+
else()
17+
find_package(benchmark CONFIG REQUIRED)
18+
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark omath)
19+
endif ()

extlibs/CMakeLists.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

extlibs/benchmark

Lines changed: 0 additions & 1 deletion
This file was deleted.

extlibs/googletest

Lines changed: 0 additions & 1 deletion
This file was deleted.

include/omath/linear_algebra/mat.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespace omath
3939
class Mat final
4040
{
4141
public:
42+
using ContainedType = Type;
4243
constexpr Mat() noexcept
4344
{
4445
clear();

0 commit comments

Comments
 (0)