diff --git a/CMakeLists.txt b/CMakeLists.txt index 94298ec..8b01464 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,13 +67,17 @@ endif() if(BUILD_TESTS) enable_testing() - include(FetchContent) - FetchContent_Declare( - googletest - URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.zip - ) - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - FetchContent_MakeAvailable(googletest) + find_package(GTest QUIET) + + if(NOT GTest_FOUND) + include(FetchContent) + FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.zip + ) + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + FetchContent_MakeAvailable(googletest) + endif() file(GLOB TEST_SOURCES "${CMAKE_SOURCE_DIR}/tests/*.cpp") @@ -86,3 +90,4 @@ if(BUILD_TESTS) include(GoogleTest) gtest_discover_tests(smath_tests) endif() + diff --git a/README.md b/README.md index 4fb4c30..26a45ea 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,19 @@ # smath -Single-file linear algebra math library for C++23. +Single-file, header-only linear algebra math library for C++23. + +## Features + +- Generic `Vec` class with useful aliases `Vec2/Vec3/Vec4` and friendly accessors (`x/y/z/w`, `r/g/b/a`). They support approx-equal and tuple/structured bindings. +- `std::format` support. +- Compile-time swizzles via `swizzle<"...">`. +- Generic matrix `Mat` class with useful aliases `Mat2/Mat3/Mat4`. +- `Quaternion` built on `Vec4`. +- Angle helpers `rad/deg/turns` respecting a configurable base unit via the macro `SMATH_ANGLE_UNIT`. +- Optional implicit conversions. +- Packing utilities for normalized RGBA (`pack_unorm4x8`, `unpack_snorm4x8`, etc.). + +## License + +This library is licensed under the Apache License 2.0. See the (LICENSE.txt)[LICENSE.txt] file for more details. diff --git a/flake.nix b/flake.nix index ce4b778..3126772 100644 --- a/flake.nix +++ b/flake.nix @@ -36,7 +36,11 @@ src = ./.; - nativeBuildInputs = [ pkgs.copyPkgconfigItems ]; + nativeBuildInputs = with pkgs; [ + cmake + gtest + copyPkgconfigItems + ]; pkgconfigItems = [ (pkgs.makePkgconfigItem rec { @@ -51,17 +55,18 @@ }) ]; - dontBuild = true; - installPhase = '' runHook preInstall mkdir -p $out/include - cp include/*.hpp $out/include/ + cp ../include/smath.hpp $out/include/ runHook postInstall ''; + dontBuild = false; + doCheck = true; + meta = with pkgs.lib; { - description = desc; + description = "Single-file linear algebra math library for C++23."; homepage = "https://github.com/slendidev/smath"; license = licenses.asl20; platforms = platforms.all;