Skip to content

Commit

Permalink
Use fmt6 because the project can't be built with fmt8 currently
Browse files Browse the repository at this point in the history
  • Loading branch information
knazarov committed Sep 29, 2023
1 parent a278a23 commit 35876f4
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
]);
nativeBuildInputs = [
cmake
fmt_8
(pkgs.callPackage ./fmt.nix {}).fmt_6
protobuf
c-ares
boost177
Expand Down
39 changes: 39 additions & 0 deletions fmt.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5f0fff01..07ed8faa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -226,16 +226,6 @@ if (FMT_SAFE_DURATION_CAST)
target_compile_definitions(fmt PUBLIC FMT_SAFE_DURATION_CAST)
endif()

-add_library(fmt-header-only INTERFACE)
-add_library(fmt::fmt-header-only ALIAS fmt-header-only)
-
-target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1)
-target_compile_features(fmt-header-only INTERFACE ${FMT_REQUIRED_FEATURES})
-
-target_include_directories(fmt-header-only INTERFACE
- $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
- $<INSTALL_INTERFACE:${FMT_INC_DIR}>)
-
# Install targets.
if (FMT_INSTALL)
include(CMakePackageConfigHelpers)
@@ -273,7 +263,7 @@ if (FMT_INSTALL)
${project_config}
INSTALL_DESTINATION ${FMT_CMAKE_DIR})

- set(INSTALL_TARGETS fmt fmt-header-only)
+ set(INSTALL_TARGETS fmt)
# Use a namespace because CMake provides better diagnostics for namespaced
# imported targets.
export(TARGETS ${INSTALL_TARGETS} NAMESPACE fmt::
@@ -292,8 +282,6 @@ if (FMT_INSTALL)
ARCHIVE DESTINATION ${FMT_LIB_DIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

- install(FILES $<TARGET_PDB_FILE:${INSTALL_TARGETS}>
- DESTINATION ${FMT_LIB_DIR} OPTIONAL)
install(FILES ${FMT_HEADERS} DESTINATION "${FMT_INC_DIR}/fmt")
install(FILES "${pkgconfig}" DESTINATION "${FMT_PKGCONFIG_DIR}")
endif ()
98 changes: 98 additions & 0 deletions fmt.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{ lib
, stdenv
, fetchFromGitHub, fetchpatch
, cmake
, enableShared ? !stdenv.hostPlatform.isStatic
# tests
, mpd
, openimageio
, fcitx5
, spdlog
}:

let
generic = { version, sha256, patches ? [ ] }:
stdenv.mkDerivation {
pname = "fmt";
inherit version;

outputs = [ "out" "dev" ];

src = fetchFromGitHub {
owner = "fmtlib";
repo = "fmt";
rev = version;
inherit sha256;
};
patches = [
# Fix BC break breaking Kodi
# https://github.com/xbmc/xbmc/issues/17629
# https://github.com/fmtlib/fmt/issues/1620
(fetchpatch {
url = "https://github.com/fmtlib/fmt/commit/7d01859ef16e6b65bc023ad8bebfedecb088bf81.patch";
sha256 = "0v8hm5958ih1bmnjr16fsbcmdnq4ykyf6b0hg6dxd5hxd126vnxx";
})

# Fix paths in pkg-config file
# https://github.com/fmtlib/fmt/pull/1657
(fetchpatch {
url = "https://github.com/fmtlib/fmt/commit/78f041ab5b40a1145ba686aeb8013e8788b08cd2.patch";
sha256 = "1hqp96zl9l3qyvsm7pxl6ah8c26z035q2mz2pqhqa0wvzd1klcc6";
})

# Fix cmake config paths.
(fetchpatch {
url = "https://github.com/fmtlib/fmt/pull/1702.patch";
sha256 = "18cadqi7nac37ymaz3ykxjqs46rvki396g6qkqwp4k00cmic23y3";
})
./fmt.diff
];


nativeBuildInputs = [ cmake ];

cmakeFlags = [
"-DBUILD_SHARED_LIBS=${if enableShared then "ON" else "OFF"}"
];

doCheck = true;

passthru.tests = {
inherit mpd openimageio fcitx5 spdlog;
};

meta = with lib; {
description = "Small, safe and fast formatting library";
longDescription = ''
fmt (formerly cppformat) is an open-source formatting library. It can be
used as a fast and safe alternative to printf and IOStreams.
'';
homepage = "https://fmt.dev/";
changelog = "https://github.com/fmtlib/fmt/blob/${version}/ChangeLog.rst";
downloadPage = "https://github.com/fmtlib/fmt/";
maintainers = [ maintainers.jdehaas ];
license = licenses.mit;
platforms = platforms.all;
};
};
in
{
fmt_6 = generic {
version = "6.2.1";
sha256 = "sha256-LGKMl65YGbOdMuGmvVpG+mA8efyD+a5HLqAR/FV31sQ=";
};
fmt_8 = generic {
version = "8.1.1";
sha256 = "sha256-leb2800CwdZMJRWF5b1Y9ocK0jXpOX/nwo95icDf308=";
};

fmt_9 = generic {
version = "9.1.0";
sha256 = "sha256-rP6ymyRc7LnKxUXwPpzhHOQvpJkpnRFOt2ctvUNlYI0=";
};

fmt_10 = generic {
version = "10.1.1";
sha256 = "sha256-H9+1lEaHM12nzXSmo9m8S6527t+97e6necayyjCPm1A=";
};
}

0 comments on commit 35876f4

Please sign in to comment.