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.

[bug] Conan 1.48.0 breaks CMakeDeps / CMakeToolchain

See original GitHub issue

Environment Details

  • Operating System+version: Ubuntu 20.04
  • Compiler+version: GCC 9
  • Conan version: 1.48.0
  • Python version: 3.8.10
  • CMake version: 3.22.2

Steps to reproduce

conanfile.txt:

[requires]
fmt/8.1.1

[generators]
CMakeDeps
CMakeToolchain

CMakeLists.txt:

cmake_minimum_required(VERSION 3.16)
project(reproduction)

find_package(fmt REQUIRED)

add_executable(reproduction)
target_link_libraries(reproduction PRIVATE fmt::fmt)
target_sources(reproduction PRIVATE main.cpp)

main.cpp:

#include <fmt/format.h>

int main() {}

Logs (Executed commands with output)

$ mkdir build && cd build
$ conan install .. -pr:b=default
Configuration (profile_host):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=9
os=Linux
os_build=Linux
[options]
*:fPIC=True
*:shared=False
[build_requires]
[env]

Configuration (profile_build):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=9
os=Linux
os_build=Linux
[options]
*:fPIC=True
*:shared=False
[build_requires]
[env]

conanfile.txt: Installing package
Requirements
    fmt/8.1.1 from 'conan-center' - Cache
Packages
    fmt/8.1.1:4eb2d280e3273c9ab04b4c51b456b2a272ff6fc3 - Cache

Installing (downloading, building) binaries...
fmt/8.1.1: Already installed!
conanfile.txt: Generator 'CMakeToolchain' calling 'generate()'
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: Generator 'CMakeDeps' calling 'generate()'
conanfile.txt: Aggregating env generators
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo
$ cmake .. --toolchain=conan_toolchain.cmake
-- Using Conan toolchain: /root/repro/build/conan_toolchain.cmake
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Target declared 'fmt::fmt'
-- Configuring done
-- Generating done
-- Build files have been written to: /root/repro/build
$ VERBOSE=1 make
/usr/local/lib/python3.8/dist-packages/cmake/data/bin/cmake -S/root/repro -B/root/repro/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/lib/python3.8/dist-packages/cmake/data/bin/cmake -E cmake_progress_start /root/repro/build/CMakeFiles /root/repro/build//CMakeFiles/progress.marks
make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/root/repro/build'
make  -f CMakeFiles/reproduction.dir/build.make CMakeFiles/reproduction.dir/depend
make[2]: Entering directory '/root/repro/build'
cd /root/repro/build && /usr/local/lib/python3.8/dist-packages/cmake/data/bin/cmake -E cmake_depends "Unix Makefiles" /root/repro /root/repro /root/repro/build /root/repro/build /root/repro/build/CMakeFiles/reproduction.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/root/repro/build'
make  -f CMakeFiles/reproduction.dir/build.make CMakeFiles/reproduction.dir/build
make[2]: Entering directory '/root/repro/build'
[ 50%] Building CXX object CMakeFiles/reproduction.dir/main.cpp.o
/usr/bin/c++   -m64 -MD -MT CMakeFiles/reproduction.dir/main.cpp.o -MF CMakeFiles/reproduction.dir/main.cpp.o.d -o CMakeFiles/reproduction.dir/main.cpp.o -c /root/repro/main.cpp
/root/repro/main.cpp:2:10: fatal error: fmt/format.h: No such file or directory
    2 | #include <fmt/format.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/reproduction.dir/build.make:76: CMakeFiles/reproduction.dir/main.cpp.o] Error 1
make[2]: Leaving directory '/root/repro/build'
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/reproduction.dir/all] Error 2
make[1]: Leaving directory '/root/repro/build'
make: *** [Makefile:91: all] Error 2

Other

It can be seen that the include path to the package is not added to the build command.

Can be reproduced with other packages (I also tried nlohmann_json/3.10.5).

The issue is not present with conan 1.47.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
memshardedcommented, May 6, 2022

@memsharded Do we also have to enforce CMAKE_BUILD_TYPE when CMake is called with CMakeToolchain + CMake helper? In source code, CMake helper comments claim that only --config Release is passed for multi-config generators, but what about single-config generators?

In single-config generators, CMake is passing -DCMAKE_BUILD_TYPE, extracted from the CMakePresets.json file. It is more idiomatic than having it defined in the toolchain.cmake file.

1reaction
ghostcommented, May 4, 2022

@memsharded Thanks for helping me out! I really appreciate it. Good luck!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warn for CMakeDeps without -DCMAKE_BUILD_TYPE as it ...
Warn for CMakeDeps without -DCMAKE_BUILD_TYPE as it doesn't found headers # ... [bug] Conan 1.48.0 breaks CMakeDeps / CMakeToolchain #11167.
Read more >
Changelog — conan 1.48.2 documentation
Conan 1.48 shouldn't break any existing 1.0 recipe or command line invocation. ... Bugfix: The CMakeDeps generator now uses the property cmake_build_modules ...
Read more >
c++ - conan + cmake generators : include directories not found ...
I am using conan version 1.48.0 with cmake 3.21.1 on ubuntu 20.04 ... Why does the conan doc tell me to use CMakeDeps...
Read more >
conan-io/conan 1.48.0 on GitHub - NewReleases.io
Docs:; Feature: The CMakeToolchain generator will create (if missing) a CMakeUserPresets.json if the CMakeLists.txt file is found in the ...
Read more >
conan Changelog - pyup.io
Fix: Raise a clear error if ``settings.compiler`` is not defined for ... Bugfix: The `CMakeDeps` generator was not working properly when the consumer...
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