Unverified Commit 64eaa9be authored by Martin Weinelt's avatar Martin Weinelt Committed by GitHub
Browse files

lunasvg: init at 3.2.1 (#398973)

parents 47d90ec9 45800a94
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  cmake,
  plutovg,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "lunasvg";
  version = "3.2.1";

  src = fetchFromGitHub {
    owner = "sammycage";
    repo = "lunasvg";
    tag = "v${finalAttrs.version}";
    hash = "sha256-CBhz117Y8e7AdD1JJtNkR/EthsfyiQ05HW41beaY95I=";
  };

  nativeBuildInputs = [
    cmake
  ];

  buildInputs = [
    plutovg
  ];

  patches = [
    # https://github.com/sammycage/lunasvg/pull/219
    # can be removed when the PR 219 and a new release is created
    ./use_system_plutovg.patch
  ];

  cmakeFlags = [
    (lib.cmakeBool "USE_SYSTEM_PLUTOVG" true)
  ];

  meta = {
    homepage = "https://github.com/sammycage/lunasvg";
    changelog = "https://github.com/sammycage/lunasvg/releases/tag/v${finalAttrs.version}";
    description = "SVG rendering and manipulation library in C++";
    license = lib.licenses.mit;
    maintainers = [ lib.maintainers.eymeric ];
    platforms = lib.platforms.all;
  };
})
+47 −0
Original line number Diff line number Diff line
From 18d25de94046ed8223fe8987ca55b44f8b5f902c Mon Sep 17 00:00:00 2001
From: eymeric <eymericdechelette@gmail.com>
Date: Tue, 15 Apr 2025 22:16:50 +0200
Subject: [PATCH] Refactor CMakeLists.txt to conditionally use system plutovg
 library

---
 CMakeLists.txt | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 08cee28..9724827 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,8 +6,17 @@ set(LUNASVG_VERSION_MICRO 1)
 
 project(lunasvg LANGUAGES CXX VERSION ${LUNASVG_VERSION_MAJOR}.${LUNASVG_VERSION_MINOR}.${LUNASVG_VERSION_MICRO})
 
-find_package(plutovg 0.0.4 QUIET)
+option(USE_SYSTEM_PLUTOVG "Use system plutovg library" OFF)
+
+if(USE_SYSTEM_PLUTOVG)
+    find_package(plutovg 1.0.0 QUIET)
+    if(NOT plutovg_FOUND)
+        message(WARNING "Could not find: plutovg>=1.0.0. Falling back to plutovg submodule.")
+    endif()
+endif()
+
 if(NOT plutovg_FOUND)
+    message(STATUS "Using plutovg submodule.")
     add_subdirectory(plutovg)
 endif()
 
@@ -57,7 +66,12 @@ target_include_directories(lunasvg PUBLIC
     $<INSTALL_INTERFACE:include/lunasvg>
 )
 
-target_link_libraries(lunasvg PRIVATE plutovg::plutovg)
+if(USE_SYSTEM_PLUTOVG AND plutovg_FOUND)
+    target_link_libraries(lunasvg PRIVATE plutovg::plutovg)
+else()
+    target_link_libraries(lunasvg PRIVATE plutovg)
+endif()
+
 target_compile_definitions(lunasvg PRIVATE LUNASVG_BUILD)
 if(NOT BUILD_SHARED_LIBS)
     target_compile_definitions(lunasvg PUBLIC LUNASVG_BUILD_STATIC)