[question] How to disable the stdlib flag set by CMakeToolchain?
Hi!
We are building a macOS project where we compile a custom c++ standard library (derived from libc++). The path to this custom libc++ is provided as an explicit linker argument (edit: along the -nostdinc++ flag).
Sadly, this conflicts with the conan_toolchain.cmake generated by CMakeToolchain generator. This file contains: string(APPEND CONAN_CXX_FLAGS " -stdlib=libc++")
With XCode 15, this flag is tagged as an "unused argument" at link time (which fails the compilation when enabling warnings as errors).
Since compiler.libcxx setting is mandatory on apple-clang compiler, how can we prevent the toolchain file from adding this flag?
Hi @Adnn
Thanks for your question.
There are 2 different aspects here. The first one is the possibility of modeling a custom libcxx, something discussed in https://github.com/conan-io/conan/issues/15620, if you want to track that ticket.
Then, you comment that it is mandatory to define libcxx in apple-clang. Have you considered adding the null possibility in the settings.yml file?
libcxx: [null, libstdc++, libc++]
I think this would allow to let the libcxx undefined and the flag will not be added.
If we are talking about disabling the respective CMakeToolchain block that sets that flag, it should be possible with::
- The block is the
libcxxblock - The blocks to be used can be defined with
tools.cmake.cmaketoolchain:enabled_blocksconf. It might be a bit inconvenient to have to list all blocks exceptlibcxx, the conf was designed with the opposite case in mind, the possibility of selecting just a very few blocks.
Please let us know if this helps.
Hi @memsharded,
Thank you for your detailed response. For the moment I am really looking at the second aspect: I would like to prevent the linker flag to be appended, so our custom stdlib is picked-up without generating any warning.
A follow-up question regarding modification of settings.yml: is it intended to be user edited? (I never really thought about that). Is it distributed with conan config install command? (If we were to go this way, the same version of settings would need to be distributed to all developers and to CI machines).
A follow-up question regarding modification of settings.yml: is it intended to be user edited? (I never really thought about that). Is it distributed with conan config install command? (If we were to go this way, the same version of settings would need to be distributed to all developers and to CI machines).
In Conan 2 there is even a settings_user.yml that is intended to add new values to existing ones, making easier the maintenance when Conan new versions add something to the settings.yml. Yes, it is quite a common practice, so we made this possibility and documented it in https://docs.conan.io/2/reference/config_files/settings.html#customizing-settings for general customization and in https://docs.conan.io/2/examples/config_files/settings/settings_user.html for settings_user.yml specifically.
Yes, both the settings.yml and the settings_user.yml can be distributed with conan config install or conan config install-pkg, and that would be indeed the recommended approach for custom settings.
Following up on this, was the settings_user.yml good to customize the compiler.libcxx and allow it being undefined (or a custom value)? Any further question or issue? Thanks for the feedback.
Hi @memsharded
Sorry for letting this hanging. Sadly we never fully addressed this issue, and I since moved away from this project.
I am afraid this issue is stale on my end, and it can be closed.
No problem, lets close it then at the moment, if this comes up again please comment or create a new ticket for it. Thanks for the feedback!