Conan not respecting compiler.libcxx abi setting

Viewed 101

I have the following conan profile:

$ conan profile show default
Configuration for profile default:

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=11
compiler.cppstd=20
compiler.libcxx=libstdc++
build_type=Release
[options]
[conf]
[build_requires]
[env]

Note that compiler.libcxx is the old ABI (libstdc++) and not the new ABI (libstdc++11). This is intentional. Also I'm specifying cppstd=20.

I then made a custom conanfile for {fmt}, which tries to package up fmt 9.0. That looks like, in its entirety:

from conans import ConanFile, CMake, tools
from conan.tools.cmake import CMakeToolchain, cmake_layout

class ConanFmt(ConanFile):
    name = "fmt"
    version = "9.0.0"

    settings = "os", "compiler", "cppstd", "build_type", "arch"

    def source(self):
        git = tools.Git(folder="fmt")
        git.clone("https://github.com/fmtlib/fmt.git", "9.0.0", shallow=True)

    def layout(self):
        cmake_layout(self)

    def generate(self):
        tc = CMakeToolchain(self)
        tc.generate()

    def build(self):
        cmake = CMake(self)
        cmake.definitions["FMT_DOC"] = False
        cmake.definitions["FMT_TEST"] = False
        cmake.definitions["FMT_INSTALL"] = True
        cmake.definitions["CMAKE_EXPORT_COMPILE_COMMANDS"] = True
        cmake.configure(source_folder="fmt")
        cmake.build()

    def package(self):
        cmake = CMake(self)
        cmake.install()

    def package_info(self):
        self.cpp_info.libs = ["fmt"]

When I try to go ahead and package this up, like say:

$ conan create . demo/testing -s build_type=Release

This does actually go ahead and clone the {fmt} repo, and correctly build and package up the contents of the library.

Except that:

  • there is no _GLIBCXX_USE_CXX11_ABI definition set (despite what this page) says.
  • {fmt} was compiled with C++11, not C++20
  • ... but it was built with Release (-O3 -DNDEBUG)

Conan does appear to provide variables like CONAN_CMAKE_CXX_STANDARD=20, CONAN_STD_CXX_FLAG=-std=c++2a, and CONAN_LIBCXX=libstdc++. But {fmt}'s build doesn't actually use those, so that isn't very useful.

How do I actually get conan to propagate through these fields properly? Is that something that must be explicitly specified in the conanfile.py (even if it's in the profile)?

0 Answers
Related