Skip to content
Closed
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
8 changes: 8 additions & 0 deletions pkgs/development/libraries/opencv/4.x.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
stdenv,
fetchurl,
fetchFromGitHub,
fetchpatch2,
cmake,
pkg-config,
unzip,
Expand Down Expand Up @@ -300,6 +301,13 @@ effectiveStdenv.mkDerivation {
patches =
[
./cmake-don-t-use-OpenCVFindOpenEXR.patch
# NOTE: remove patch in opencv v4.12.0 (next release)
# https://github.com/opencv/opencv/pull/27428
# it is required to allow cross compilation by letting PROTOC_EXE be set by protobuf hook
(fetchpatch2 {
url = "https://github.com/opencv/opencv/commit/bbe2f50b5d50a282b2260100be9e559067e55fbf.patch?full_index=1";
hash = "sha256-T+zmrOeyEmNyu1hJPDGUub59EMXwe6ZqP6PV/tDJFCk=";
})
]
++ optionals enableCuda [
./cuda_opt_flow.patch
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
commit 649864521c0e09f3a3bd7939d91ba1ef488946dc
Author: phanirithvij <phanirithvij2000@gmail.com>
Date: Tue Jun 10 10:58:49 2025 +0530

[CMake] Allow for protoc executable to be configured

copied from commit 3163111b6fb1da08b9d6ad75518d91b89cd03bbf

Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>

diff --git a/cmake/protobuf-config.cmake.in b/cmake/protobuf-config.cmake.in
index 61669118c..55f32516f 100644
--- a/cmake/protobuf-config.cmake.in
+++ b/cmake/protobuf-config.cmake.in
@@ -11,7 +11,7 @@ function(protobuf_generate)
include(CMakeParseArguments)

set(_options APPEND_PATH)
- set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR PLUGIN PLUGIN_OPTIONS)
+ set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR PLUGIN PLUGIN_OPTIONS PROTOC_EXE)
if(COMMAND target_sources)
list(APPEND _singleargs TARGET)
endif()
@@ -92,6 +92,11 @@ function(protobuf_generate)
endforeach()
endif()

+ if(NOT protobuf_generate_PROTOC_EXE)
+ # Default to using the CMake executable
+ set(protobuf_generate_PROTOC_EXE protobuf::protoc)
+ endif()
+
foreach(DIR ${protobuf_generate_IMPORT_DIRS})
get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
@@ -146,9 +151,9 @@ function(protobuf_generate)

add_custom_command(
OUTPUT ${_generated_srcs}
- COMMAND protobuf::protoc
+ COMMAND ${protobuf_generate_PROTOC_EXE}
ARGS ${protobuf_generate_PROTOC_OPTIONS} --${protobuf_generate_LANGUAGE}_out ${_plugin_options}:${protobuf_generate_PROTOC_OUT_DIR} ${_plugin} ${_protobuf_include_path} ${_abs_file}
- DEPENDS ${_abs_file} protobuf::protoc
+ DEPENDS ${_abs_file} ${protobuf_generate_PROTOC_EXE}
COMMENT ${_comment}
VERBATIM )
endforeach()
30 changes: 21 additions & 9 deletions pkgs/development/libraries/protobuf/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
zlib,
version,
hash,
replaceVars,
versionCheckHook,

# downstream dependencies
Expand Down Expand Up @@ -42,14 +41,27 @@ stdenv.mkDerivation (finalAttrs: {
--replace-fail 'tmpnam(b)' '"'$TMPDIR'/foo"'
'';

patches = lib.optionals (lib.versionOlder version "22") [
# fix protobuf-targets.cmake installation paths, and allow for CMAKE_INSTALL_LIBDIR to be absolute
# https://github.com/protocolbuffers/protobuf/pull/10090
(fetchpatch {
url = "https://github.com/protocolbuffers/protobuf/commit/a7324f88e92bc16b57f3683403b6c993bf68070b.patch";
hash = "sha256-SmwaUjOjjZulg/wgNmR/F5b8rhYA2wkKAjHIOxjcQdQ=";
})
];
patches =
lib.optionals (lib.versionOlder version "22") [
# fix protobuf-targets.cmake installation paths, and allow for CMAKE_INSTALL_LIBDIR to be absolute
# https://github.com/protocolbuffers/protobuf/pull/10090
(fetchpatch {
url = "https://github.com/protocolbuffers/protobuf/commit/a7324f88e92bc16b57f3683403b6c993bf68070b.patch";
hash = "sha256-SmwaUjOjjZulg/wgNmR/F5b8rhYA2wkKAjHIOxjcQdQ=";
})
]
++ lib.optionals (lib.head (lib.splitVersion version) == "21") [
# patch 3163111b6fb1da08b9d6ad75518d91b89cd03bbf with additional modifications
./cmake-configure-protoc-exe-21.patch
]
++ lib.optionals (lib.versionAtLeast version "22" && lib.versionOlder version "29") [
# for cross compilation allow for invocations of `protobuf_generate` pass their preferred programs
# https://github.com/protocolbuffers/protobuf/pull/17888 (in tree from 29 onwards)
(fetchpatch {
url = "https://github.com/protocolbuffers/protobuf/commit/3163111b6fb1da08b9d6ad75518d91b89cd03bbf.patch";
hash = "sha256-px085y1MRt9qgYHCqR7ZOaNaHO1RV+VK3WWaI9I9wPg=";
})
];

# hook to provide the path to protoc executable, used at build time
build_protobuf =
Expand Down