Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ on:
branches: [ "main" ]

jobs:
test:
test-cmake:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

Expand All @@ -20,4 +19,21 @@ jobs:
run: cmake --build build --config Release

- name: Run tests
run: ctest --test-dir build -C Release --output-on-failure
run: ctest --test-dir build -C Release --output-on-failure

test-meson:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Meson and Ninja
run: pip install meson ninja

- name: Configure Meson
run: meson setup build -Dbuild_tests=true

- name: Build
run: meson compile -C build

- name: Run tests
run: meson test -C build --verbose
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

build/

# Meson subproject downloads
subprojects/*/
subprojects/packagecache/

# User-specific files
*.rsuser
*.suo
Expand Down Expand Up @@ -399,4 +403,4 @@ FodyWeavers.xsd
*.msp

# JetBrains Rider
*.sln.iml
*.sln.iml
37 changes: 22 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ This makes it perfect for learning, experimentation, but not a drop-in replaceme
`pi`, `radians()`, `degrees()`
- **Starlet** Project Constants


<br/>


## Prerequisites
- C++20 or later
- CMake 3.20+
- One of the following Build Systems,
- CMake 3.20+
- Meson 1.1+

## Using as a Dependency

### CMake
```cmake
include(FetchContent)

Expand All @@ -45,25 +45,32 @@ FetchContent_MakeAvailable(starlet_math)
target_link_libraries(app_name PRIVATE starlet_math)
```

<br/>
### Meson
```python
starlet_math = subproject('starlet_math')
starlet_math_dep = starlet_math.get_variable('starlet_math_dep')
```

## Building and Testing
```bash
# 1. Clone starlet-math
git clone https://github.com/masonlet/starlet-math.git
cd starlet-math
```

# 2. Create a Build Directory and Generate Build Files
mkdir build
cd build
cmake -DBUILD_TESTS=ON ..

# 3. Build and run tests
cmake --build .
ctest
### CMake
```bash
cmake -B build -DBUILD_TESTS=ON
cmake --build build
ctest --test-dir build
```

<br/>
### Meson
```bash
meson setup build -Dbuild_tests=true
meson compile -C build
meson test -C build
```

## License
MIT License — see [LICENSE](./LICENSE) for details.
18 changes: 18 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
project('starlet-math', 'cpp',
version : '1.0.0',
meson_version : '>=1.1',
default_options : ['cpp_std=c++20']
)

inc = include_directories('inc')

starlet_math_dep = declare_dependency(
include_directories : inc
)

if get_option('build_tests')
gtest_dep = dependency('gtest_main',
fallback : ['gtest', 'gtest_main_dep']
)
subdir('tests')
endif
1 change: 1 addition & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('build_tests', type : 'boolean', value : false, description : 'Build unit tests')
Empty file added subprojects/.wraplock
Empty file.
16 changes: 16 additions & 0 deletions subprojects/gtest.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[wrap-file]
directory = googletest-1.17.0
source_url = https://github.com/google/googletest/archive/refs/tags/v1.17.0.tar.gz
source_filename = googletest-1.17.0.tar.gz
source_hash = 65fab701d9829d38cb77c14acdc431d2108bfdbf8979e40eb8ae567edf10b27c
patch_filename = gtest_1.17.0-4_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/gtest_1.17.0-4/get_patch
patch_hash = 3abf7662d09db706453a5b064a1e914678c74b9d9b0b19382747ca561d0d8750
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/gtest_1.17.0-4/googletest-1.17.0.tar.gz
wrapdb_version = 1.17.0-4

[provide]
gtest = gtest_dep
gtest_main = gtest_main_dep
gmock = gmock_dep
gmock_main = gmock_main_dep
10 changes: 10 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test_exe = executable('starlet_math_tests',
files(
'vec2_test.cpp',
'vec3_test.cpp',
'vec4_test.cpp',
),
dependencies : [starlet_math_dep, gtest_dep]
)

test('starlet-math tests', test_exe)