Skip to content

Commit

Permalink
Merge branch 'feature/libfmt'
Browse files Browse the repository at this point in the history
  • Loading branch information
GerbilSoft committed Jan 25, 2025
2 parents da21290 + f26da71 commit 84251e8
Show file tree
Hide file tree
Showing 285 changed files with 49,464 additions and 19,527 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Install required packages
run: |
sudo apt-get update
sudo apt-get install --yes cmake ninja-build libcurl4-openssl-dev zlib1g-dev libpng-dev libjpeg-dev nettle-dev pkg-config libtinyxml2-dev gettext libseccomp-dev libzstd-dev liblz4-dev liblzo2-dev qtbase5-dev qttools5-dev-tools extra-cmake-modules libkf5kio-dev libkf5widgetsaddons-dev libkf5filemetadata-dev libkf5crash-dev libglib2.0-dev libgtk2.0-dev libgdk-pixbuf2.0-dev libcanberra-dev libgsound-dev libgtk-3-dev libcairo2-dev libthunarx-3-dev libcanberra-gtk3-dev libnautilus-extension-dev libgtk-4-dev lcov
sudo apt-get install --yes cmake ninja-build libcurl4-openssl-dev zlib1g-dev libpng-dev libjpeg-dev nettle-dev pkg-config libtinyxml2-dev gettext libseccomp-dev libfmt-dev libzstd-dev liblz4-dev liblzo2-dev qtbase5-dev qttools5-dev-tools extra-cmake-modules libkf5kio-dev libkf5widgetsaddons-dev libkf5filemetadata-dev libkf5crash-dev libglib2.0-dev libgtk2.0-dev libgdk-pixbuf2.0-dev libcanberra-dev libgsound-dev libgtk-3-dev libcairo2-dev libthunarx-3-dev libcanberra-gtk3-dev libnautilus-extension-dev libgtk-4-dev lcov
- name: Run CMake
run: cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_XFCE=ON -DBUILD_GTK3=ON -DBUILD_GTK4=ON -DBUILD_KF5=ON -DBUILD_TESTING=ON -DENABLE_COVERAGE=ON -DTRACKER_INSTALL_API_VERSION=3 -G Ninja
- name: Run Ninja
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
#if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install cmake ninja-build libcurl4-openssl-dev zlib1g-dev libpng-dev libjpeg-dev nettle-dev pkg-config libtinyxml2-dev gettext libseccomp-dev libzstd-dev liblz4-dev liblzo2-dev qtbase5-dev qttools5-dev-tools extra-cmake-modules libkf5kio-dev libkf5widgetsaddons-dev libkf5filemetadata-dev libkf5crash-dev libglib2.0-dev libgtk2.0-dev libgdk-pixbuf2.0-dev libcanberra-dev libgsound-dev libgtk-3-dev libcairo2-dev libthunarx-3-dev libcanberra-gtk3-dev libglib2.0-dev libgtk-3-dev libcairo2-dev libnautilus-extension-dev libgtk-4-dev
sudo apt-get install cmake ninja-build libcurl4-openssl-dev zlib1g-dev libpng-dev libjpeg-dev nettle-dev pkg-config libtinyxml2-dev gettext libseccomp-dev libfmt-dev libzstd-dev liblz4-dev liblzo2-dev qtbase5-dev qttools5-dev-tools extra-cmake-modules libkf5kio-dev libkf5widgetsaddons-dev libkf5filemetadata-dev libkf5crash-dev libglib2.0-dev libgtk2.0-dev libgdk-pixbuf2.0-dev libcanberra-dev libgsound-dev libgtk-3-dev libcairo2-dev libthunarx-3-dev libcanberra-gtk3-dev libglib2.0-dev libgtk-3-dev libcairo2-dev libnautilus-extension-dev libgtk-4-dev
- name: Build rom-properties (Release build)
run: |
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ INCLUDE(CheckTinyXML2)
INCLUDE(CheckZSTD)
INCLUDE(CheckLZ4)
INCLUDE(CheckLZO)
INCLUDE(CheckLibfmt)

# Reference: https://cmake.org/Wiki/RecipeAddUninstallTarget
########### Add uninstall target ###############
Expand Down Expand Up @@ -337,6 +338,9 @@ ENDIF(USE_INTERNAL_XML)
IF(BUILD_TESTING)
SET(EXTLIB_BUILD "${EXTLIB_BUILD}- Google Test\n")
ENDIF(BUILD_TESTING)
IF(USE_INTERNAL_FMT)
SET(EXTLIB_BUILD "${EXTLIB_BUILD}- libfmt\n")
ENDIF(USE_INTERNAL_FMT)

IF(BUILD_TRACKER_EXTRACTOR)
SET(TRACKER_API_DISPLAY "${TRACKER_INSTALL_API_VERSION}")
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
network functionality, e.g. downloading boxart and checking for updates,
is enabled. Defaults to ON, but can be disabled for high-security
environments.
* libfmt is now used for string formatting in most parts of rom-properties.
libfmt has faster string parsing than printf() and stringstream, and has
guaranteed type-safe format handling using C++ templates, whereas printf
can get tripped up because it uses C-style varargs.

## v2.4.1 (released 2024/11/12)

Expand Down
1 change: 1 addition & 0 deletions appveyor-dpkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ apt-get -y install \
libtinyxml2-dev \
gettext \
libseccomp-dev \
libfmt-dev \
\
libzstd-dev \
liblz4-dev \
Expand Down
61 changes: 61 additions & 0 deletions cmake/libs/CheckLibfmt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Check for libfmt.
# If libfmt isn't found, extlib/libfmt/ will be used instead.

IF(NOT USE_INTERNAL_FMT)
IF(Fmt_LIBRARY MATCHES "^fmt$" OR Fmt_LIBRARY MATCHES "^fmt")
# Internal libfmt was previously in use.
UNSET(Fmt_FOUND)
UNSET(HAVE_Fmt)
UNSET(Fmt_LIBRARY CACHE)
UNSET(Fmt_LIBRARIES CACHE)
ENDIF()

# Check for libfmt.
# - libfmt-6.2.0: Introduced the 'L' format specifier.
# - Previously, 'n' was available.
# - The 'L' specifier matches C++20 std::format().
# - libfmt-7.0.x: Has fixes for the 'L' format specifier; removed 'n'.
# - 'n' can be re-enabled with FMT_DEPRECATED_N_SPECIFIER.
# - libfmt-7.1.0: Has more fixes for the 'L' format specifier.
# - libfmt-8.0.0: Removes the 'n' format specifier entirely.
#
# Since we use the 'L' specifier, we will set a minimum of libfmt-7.1.0.
# Ubuntu 20.04 has libfmt-6.1.2; Ubuntu 22.04 has libfmt-8.1.1.
# Also, Ubuntu 20.04's libfmt is a static library. It was changed
# to a shared library sometime between 20.04 and 22.04.
FIND_PACKAGE(Fmt 7.1.0)
IF(Fmt_FOUND)
# Found system libfmt.
SET(HAVE_Fmt 1)
SET(Fmt_LIBRARY "fmt::fmt")
ELSE()
# System libfmt was not found.
MESSAGE(STATUS "Using the internal copy of libfmt since a system version was not found.")
SET(USE_INTERNAL_FMT ON CACHE BOOL "Use the internal copy of libfmt" FORCE)
ENDIF()
ELSE()
MESSAGE(STATUS "Using the internal copy of libfmt.")
ENDIF(NOT USE_INTERNAL_FMT)

IF(USE_INTERNAL_FMT)
# Using the internal libfmt library.
SET(Fmt_FOUND 1)
SET(HAVE_Fmt 1)
SET(Fmt_VERSION 11.1.2 CACHE INTERNAL "libfmt version" FORCE)
# FIXME: When was it changed from LIBRARY to LIBRARIES?
IF(WIN32 OR APPLE)
# Using DLLs on Windows and Mac OS X.
SET(USE_INTERNAL_FMT_DLL ON)
SET(Fmt_LIBRARY fmt::fmt CACHE INTERNAL "libfmt library" FORCE)
ELSE()
# Using static linking on other systems.
SET(USE_INTERNAL_FMT_DLL OFF)
SET(Fmt_LIBRARY fmt::fmt-header-only CACHE INTERNAL "libfmt library" FORCE)
ENDIF()
SET(Fmt_LIBRARIES ${Fmt_LIBRARY} CACHE INTERNAL "libfmt libraries" FORCE)
# FIXME: When was it changed from DIR to DIRS?
SET(Fmt_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/libfmt)
SET(Fmt_INCLUDE_DIRS ${Fmt_INCLUDE_DIR})
ELSE(USE_INTERNAL_FMT)
SET(USE_INTERNAL_FMT_DLL OFF)
ENDIF(USE_INTERNAL_FMT)
4 changes: 3 additions & 1 deletion cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ENDIF()

OPTION(BUILD_CLI "Build the `rpcli` command line program." ON)

# ZLIB, libpng, XML, zstd
# ZLIB, libpng, XML, zstd, libfmt
# Internal versions are always used on Windows.
OPTION(ENABLE_XML "Enable XML parsing for e.g. Windows manifests." ON)
OPTION(ENABLE_ZSTD "Enable ZSTD decompression. (Required for some unit tests.)" ON)
Expand All @@ -52,13 +52,15 @@ IF(WIN32)
SET(USE_INTERNAL_ZSTD ${ENABLE_ZSTD})
SET(USE_INTERNAL_LZ4 ${ENABLE_LZ4})
SET(USE_INTERNAL_LZO ${ENABLE_LZO})
SET(USE_INTERNAL_FMT ON)
ELSE(WIN32)
OPTION(USE_INTERNAL_ZLIB "Use the internal copy of zlib." OFF)
OPTION(USE_INTERNAL_PNG "Use the internal copy of libpng." OFF)
OPTION(USE_INTERNAL_XML "Use the internal copy of TinyXML2." OFF)
OPTION(USE_INTERNAL_ZSTD "Use the internal copy of zstd." OFF)
OPTION(USE_INTERNAL_LZ4 "Use the internal copy of LZ4." OFF)
OPTION(USE_INTERNAL_LZO "Use the internal copy of LZO." OFF)
OPTION(USE_INTERNAL_FMT "Use the internal copy of libfmt." OFF)
ENDIF()

# TODO: If APNG export is added, verify that system libpng
Expand Down
Loading

0 comments on commit 84251e8

Please sign in to comment.