From 30fbc348c85611cc047eff9dea1f5ec826621d04 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 1 Oct 2026 11:53:23 +0000 Subject: [PATCH] g2o: cleanup, fix --- pkgs/by-name/g2/g2o/package.nix | 38 ++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/pkgs/by-name/g2/g2o/package.nix b/pkgs/by-name/g2/g2o/package.nix index 96a67570f191..e6bde988963c 100644 --- a/pkgs/by-name/g2/g2o/package.nix +++ b/pkgs/by-name/g2/g2o/package.nix @@ -2,6 +2,7 @@ lib, stdenv, fetchFromGitHub, + fetchpatch, cmake, eigen, suitesparse, @@ -12,19 +13,32 @@ spdlog, }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "g2o"; version = "20241228"; + __structuredAttrs = true; + strictDeps = true; + src = fetchFromGitHub { owner = "RainerKuemmerle"; repo = "g2o"; - rev = "${version}_git"; + tag = "${finalAttrs.version}_git"; hash = "sha256-MW1IO1P2e3KgurOW5ZfHlxK0m5sF0JhdLmvQNEHWEtI="; }; - # Removes a reference to gcc that is only used in a debug message - patches = [ ./remove-compiler-reference.patch ]; + patches = [ + # Removes a reference to gcc that is only used in a debug message + ./remove-compiler-reference.patch + + # Fix invalid fmt format string (compile-time error with fmt 12) + # https://github.com/RainerKuemmerle/g2o/pull/899 + (fetchpatch { + name = "fix-fmt-format-string.patch"; + url = "https://github.com/RainerKuemmerle/g2o/commit/18b1894778a7a758a8fb1d4db49f45661ea4ea38.patch"; + hash = "sha256-sS9dYNB1RCTLVc5dnO/fDpcUD2i3ag8Gl/nDwUP43yw="; + }) + ]; outputs = [ "out" @@ -51,15 +65,15 @@ stdenv.mkDerivation rec { cmakeFlags = [ # Detection script is broken - "-DQGLVIEWER_INCLUDE_DIR=${libsForQt5.libqglviewer}/include/QGLViewer" - "-DG2O_BUILD_EXAMPLES=OFF" + (lib.cmakeFeature "QGLVIEWER_INCLUDE_DIR" "${libsForQt5.libqglviewer}/include/QGLViewer") + (lib.cmakeBool "G2O_BUILD_EXAMPLES" false) ] ++ lib.optionals stdenv.hostPlatform.isx86_64 [ - "-DDO_SSE_AUTODETECT=OFF" - "-DDISABLE_SSE3=${if stdenv.hostPlatform.sse3Support then "OFF" else "ON"}" - "-DDISABLE_SSE4_1=${if stdenv.hostPlatform.sse4_1Support then "OFF" else "ON"}" - "-DDISABLE_SSE4_2=${if stdenv.hostPlatform.sse4_2Support then "OFF" else "ON"}" - "-DDISABLE_SSE4_A=${if stdenv.hostPlatform.sse4_aSupport then "OFF" else "ON"}" + (lib.cmakeBool "DO_SSE_AUTODETECT" false) + (lib.cmakeBool "DISABLE_SSE3" (!stdenv.hostPlatform.sse3Support)) + (lib.cmakeBool "DISABLE_SSE4_1" (!stdenv.hostPlatform.sse4_1Support)) + (lib.cmakeBool "DISABLE_SSE4_2" (!stdenv.hostPlatform.sse4_2Support)) + (lib.cmakeBool "DISABLE_SSE4_A" (!stdenv.hostPlatform.sse4_aSupport)) ]; meta = { @@ -75,4 +89,4 @@ stdenv.mkDerivation rec { # fatal error: 'qglviewer.h' file not found broken = stdenv.hostPlatform.isDarwin; }; -} +})