about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/ncnn
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/ncnn')
-rw-r--r--nixpkgs/pkgs/development/libraries/ncnn/cmakelists.patch35
-rw-r--r--nixpkgs/pkgs/development/libraries/ncnn/default.nix48
2 files changed, 83 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/ncnn/cmakelists.patch b/nixpkgs/pkgs/development/libraries/ncnn/cmakelists.patch
new file mode 100644
index 000000000000..a43d7b0c4b72
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/ncnn/cmakelists.patch
@@ -0,0 +1,35 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 785e2cd..459024d 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -589,7 +589,8 @@ endif()
+ if(NCNN_VULKAN)
+     if(NCNN_SYSTEM_GLSLANG)
+         find_package(Threads)
+-        find_package(glslang QUIET)
++        find_package(SPIRV-Tools-opt REQUIRED)
++        find_package(glslang REQUIRED)
+         if(glslang_FOUND)
+             add_library(glslang ALIAS glslang::glslang)
+             add_library(SPIRV ALIAS glslang::SPIRV)
+@@ -601,7 +602,6 @@ if(NCNN_VULKAN)
+                 set(NCNN_SYSTEM_GLSLANG OFF)
+             else()
+                 include("${GLSLANG_TARGET_DIR}/OSDependentTargets.cmake")
+-                include("${GLSLANG_TARGET_DIR}/OGLCompilerTargets.cmake")
+                 if(EXISTS "${GLSLANG_TARGET_DIR}/HLSLTargets.cmake")
+                     # hlsl support can be optional
+                     include("${GLSLANG_TARGET_DIR}/HLSLTargets.cmake")
+diff --git a/src/ncnn.pc.in b/src/ncnn.pc.in
+index b580fce..be2becd 100644
+--- a/src/ncnn.pc.in
++++ b/src/ncnn.pc.in
+@@ -1,6 +1,6 @@
+ prefix=${pcfiledir}/../..

+-librarydir=${prefix}/@CMAKE_INSTALL_LIBDIR@

+-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

++librarydir=@CMAKE_INSTALL_FULL_LIBDIR@

++includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@

+ 

+ Name: @CMAKE_PROJECT_NAME@

+ Description: high-performance neural network inference framework optimized for the mobile platform

diff --git a/nixpkgs/pkgs/development/libraries/ncnn/default.nix b/nixpkgs/pkgs/development/libraries/ncnn/default.nix
new file mode 100644
index 000000000000..71b4bbc8fd42
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/ncnn/default.nix
@@ -0,0 +1,48 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, cmake
+, vulkan-headers
+, vulkan-loader
+, glslang
+, opencv
+, protobuf
+}:
+
+stdenv.mkDerivation rec {
+  pname = "ncnn";
+  version = "20240102";
+
+  src = fetchFromGitHub {
+    owner = "Tencent";
+    repo = pname;
+    rev = version;
+    hash = "sha256-kk70oLY+2QJOkyYq10whLRMxBuibQMWMOBA9dcbKf/I=";
+  };
+
+  patches = [
+    ./cmakelists.patch
+  ];
+
+  cmakeFlags = [
+    "-DNCNN_CMAKE_VERBOSE=1" # Only for debugging the build
+    "-DNCNN_SHARED_LIB=1"
+    "-DNCNN_ENABLE_LTO=1"
+    "-DNCNN_VULKAN=1"
+    "-DNCNN_BUILD_EXAMPLES=0"
+    "-DNCNN_BUILD_TOOLS=0"
+    "-DNCNN_SYSTEM_GLSLANG=1"
+    "-DNCNN_PYTHON=0" # Should be an attribute
+  ];
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ vulkan-headers vulkan-loader glslang opencv protobuf ];
+
+  meta = with lib; {
+    description = "ncnn is a high-performance neural network inference framework optimized for the mobile platform";
+    homepage = "https://github.com/Tencent/ncnn";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ tilcreator ];
+    platforms = platforms.all;
+  };
+}