From: Huang Rui <vowstar@gmail.com>
Date: Sat, 13 Dec 2025 12:28:22 +0800
Subject: [PATCH] Use shared nanopb library instead of static

Gentoo provides nanopb as a shared library by default. This patch
allows chiaki-ng to link against the shared version, falling back
to static if shared is not available.

Bug: https://bugs.gentoo.org/965824
---
 cmake/FindNanopb.cmake | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cmake/FindNanopb.cmake b/cmake/FindNanopb.cmake
index 1234567..abcdefg 100644
--- a/cmake/FindNanopb.cmake
+++ b/cmake/FindNanopb.cmake
@@ -12,6 +12,10 @@ find_package_handle_standard_args(Nanopb

 if(Nanopb_FOUND)
 	if(NOT TARGET Nanopb::nanopb)
-		add_library(Nanopb::nanopb ALIAS nanopb::protobuf-nanopb-static)
+		if(TARGET nanopb::protobuf-nanopb)
+			add_library(Nanopb::nanopb ALIAS nanopb::protobuf-nanopb)
+		else()
+			add_library(Nanopb::nanopb ALIAS nanopb::protobuf-nanopb-static)
+		endif()
 	endif()
 endif()
