Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set minimum version of fmt to 5.3.0 #1525

Merged
merged 1 commit into from
Apr 20, 2020

Conversation

Montellese
Copy link
Contributor

The used fmt::fmt target has been introduced with fmt 5.0.0.

Without this spdlog also picks up older versions of fmt like 4.0.0 on Ubuntu 18.04 through libfmt-dev or even older versions on Ubuntu 16.04 through libfmt3-dev. Compilation fails but the error message is not straight forward at all.

I'm not sure if the version should be higher depending on what features of fmt are used within spdlog.

@gabime
Copy link
Owner

gabime commented Apr 20, 2020

I don't think this would work for fmt 6.x.x versions (incompatible with 5 according to cmake)

@e-i-n-s
Copy link

e-i-n-s commented Apr 20, 2020

@gabime

I can confirm that it will work. I was confused, too :-)


My test using CMake version 3.16.3:

I used CMake to generate the CMake target of fmt:

cmake -G "Visual Studio 15 2017" <path to fmt repo> -DCMAKE_INSTALL_PREFIX=install
cmake --build . --target install

The generated <cmake install path>\lib\cmake\fmt\fmt-config-version.cmake contain the version:

set(PACKAGE_VERSION "6.2.1")

Now I'm able to consume this CMake target (Windows):

SET fmt_DIR=<cmake install path>\lib\cmake\fmt
cmake -G "Visual Studio 15 2017" <path to spdlog repo>  -DSPDLOG_FMT_EXTERNAL=On ..

Works fine with find_package(fmt 5.0.0 REQUIRED)

As a test I switched to find_package(fmt 7.0.0 REQUIRED). It returns a correct error message:

-- Build spdlog: 1.6.0
-- Build type: Release
CMake Error at CMakeLists.txt:191 (find_package) in the spdlog repository:
  Could not find a configuration file for package "fmt" that is compatible
  with requested version "7.0.0".

  The following configuration files were considered but not accepted:

    <cmake install path>/lib/cmake/fmt/fmt-config.cmake, version: 6.2.1

@gabime
Copy link
Owner

gabime commented Apr 20, 2020

This is indeed confusing. This is what cmake docs say:

When the [version] argument is given Config mode will only find a version of the package that claims compatibility with the requested version (format is major[.minor[.patch[.tweak]]]). If the EXACT option is given only a version of the package claiming an exact match of the requested version may be found. CMake does not establish any convention for the meaning of version numbers. Package version numbers are checked by “version” files provided by the packages themselves. For a candidate package configuration file .cmake the corresponding version file is located next to it and named either -version.cmake or Version.cmake. If no such version file is available then the configuration file is assumed to not be compatible with any requested version. A basic version file containing generic version matching code can be created using the CMakePackageConfigHelpers module. When a version file is found it is loaded to check the requested version number.

So I still not sure what this means :(

@Montellese
Copy link
Contributor Author

@gabime Yeah I didn't find any understandable description of how CMake handles these versions and how to apply rules like >= or <=.
In Kodi we are using fmt 6.1.2 and it works fine there.

According to one of our users spdlog is not compatible with fmt 5.1.0 so maybe we need a different version here. Do you have any idea?

@wsnipex
Copy link

wsnipex commented Apr 20, 2020

snip from fmt-config-version.cmake


set(PACKAGE_VERSION "6.1.2")

if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
  set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
  set(PACKAGE_VERSION_COMPATIBLE TRUE)
  if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
    set(PACKAGE_VERSION_EXACT TRUE)
  endif()
endif()

@gabime
Copy link
Owner

gabime commented Apr 20, 2020

@Montellese Not sure but 5.2.0 might be ok

@Montellese
Copy link
Contributor Author

I just went through the fmt releases starting with 5.1.0 and built spdlog 1.5.0 against it with the following results:

  • 5.1.0 doesn't compile
  • 5.2.0 doesn't compile
  • 5.2.1 doesn't compile
  • 5.3.0 compiles and all unit tests pass.
  • 6.0.0 compiles and all unit tests pass.
  • 6.1.0 compiles and all unit tests pass.

So I'm assuming that the minimum version is 5.3.0. I will change it to that.

The used fmt::fmt target has been introduced with fmt 5.0.0.
@gabime
Copy link
Owner

gabime commented Apr 20, 2020

Good to know.
Thanks for investigating!

@gabime gabime merged commit 2b326e9 into gabime:v1.x Apr 20, 2020
@gabime gabime changed the title Set minimum version of fmt to 5.0.0 Set minimum version of fmt to 5.3.0 Apr 20, 2020
@Montellese Montellese deleted the improvement/fmt_min_version branch April 20, 2020 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants