question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[package] fmt/6.1.2 find_package(fmt REQUIRED) in cmake fails

See original GitHub issue

find_package(fmt) doesn’t work with the fmtlib from conan-center. This seems to be a deliberate choice in the recipe (no cmake_find_package generator) but is fairly inconvenient.

Package and Environment Details (include every applicable attribute)

  • Package Name/Version: fmt/6.1.2 (but applies to every version as far as tested)
  • Operating System+version: Windows 10 (system independent)
  • Compiler+version: VS2019 (again, independent)
  • no Docker image
  • Conan version: 1.21.1
  • Python version: Python 3.7.4

Conan profile (output of conan profile show default or conan profile show <profile> if custom profile is in use)

C:\>"C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\scripts\conan" profile show default
Configuration for profile default:

[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
build_type=Release
[options]
[build_requires]
[env]

Steps to reproduce (Include if Applicable)

CMakeLists.txt:

include(cmake/conan.cmake) # latest from github
conan_cmake_run(REQUIRES
    fmt/6.1.2

    BASIC_SETUP
    CMAKE_TARGETS
    OPTIONS
    BUILD missing)
find_package(fmt REQUIRED)

Logs (Include/Attach if Applicable)

[cmake] CMake Error at CMakeLists.txt:9 (find_package):
[cmake]   By not providing "Findfmt.cmake" in CMAKE_MODULE_PATH this project has
[cmake]   asked CMake to find a package configuration file provided by "fmt", but
[cmake]   CMake did not find one.
[cmake] 
[cmake]   Could not find a package configuration file provided by "fmt" with any of
[cmake]   the following names:
[cmake] 
[cmake]     fmtConfig.cmake
[cmake]     fmt-config.cmake
[cmake] 
[cmake]   Add the installation prefix of "fmt" to CMAKE_PREFIX_PATH or set "fmt_DIR"
[cmake]   to a directory containing one of the above files.  If "fmt" provides a
[cmake]   separate development package or SDK, be sure it has been installed.**

I prefer using find_package() and then using the usual fmt::fmt target over simply using ${CONAN_LIBS} because it is more explicit and because it allows me to use the same CMakeLists.txt whether I’m using conan or not.

I’d appreciate if this functionality could be reinstated.

Edit: I removed a part about removing cmake etc. Instead, going by the FAQ, it seems that the generator cmake_find_package should be added to the recipe https://github.com/conan-io/conan-center-index/blob/25f0751b56e7c95bd0e8b23326c88adaf825f945/recipes/fmt/all/conanfile.py

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
czoidocommented, Feb 5, 2020

Hi @TobiSchluter Starting in Conan 1.22 we are setting the IMPORTED TARGETS as GLOBAL so at least you will not have to set_target_properties yourself: https://github.com/conan-io/conan/pull/6438

1reaction
danimtbcommented, Feb 5, 2020

Indeed, that is a current limitation of the model that has been discussed previously and it is known as components https://github.com/conan-io/conan/issues/5090. The feature is not developed yet but is a strong topic on the community especially regarding the CMake targets where the implications are evident. You can read more about it on that thread and comment on anything you want. As it is commonly said: We are working on it! 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation or example of C++ API in irods - Google Groups
I wonder where to find a detailed explaination or illustration of usage of irods C++ Client API(aka, rc_xxxx api from #include <rodsClient.h>).
Read more >
CMake add fmt library - c++ - Stack Overflow
I tried some approaches (such as direct copy of approach from gtest) to include FMT into my project, but failed. I want CMake...
Read more >
Why is it that package managers are unnecessarily hard? : r/cpp
[requires] sdl/2.24.0 fmt/9.1.0 [generators] CMakeDeps ... But when I try to compile, it fails to compile and I get the error:
Read more >
{fmt} Formatting & Printing Library - {fmt} - hacking C++
Example-based introduction to the {fmt} library that offers a fast(er) and safe(r) alternative to iostreams/stdio using a Python-inspired formatting syntax.
Read more >
Usage — fmt 6.1.2 documentation
mkdir build # Create a directory to hold the build output. cd build cmake .. # Generate native build scripts. where <path/to/fmt> is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found