-
Notifications
You must be signed in to change notification settings - Fork 359
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
[question] Issue with extra_cxxflags
not initializing CMAKE_CXX_FLAGS_INIT
in Ninja Multi-Config CMake projects since Conan 2.1.0
#3660
Comments
Hi @solarispika Thanks for your detailed report. I think this is expected behavior for multi-config setups.
This is indeed the recommended flow, for multi-config setups it is necessary to If you really want the independent flow, why using |
Hi @memsharded Thank you for the detailed explanation. I appreciate you taking the time to clarify the expected behavior and the rationale behind it. To provide some context, our project was initially a Visual Studio solution, and we later migrated it to Ninja for better performance while retaining the multi-config aspect, leading to the Ninja Multi-Config setup. Initially, we followed the With your explanation, I now understand that the Based on your response, I have a couple of suggestions/questions:
I appreciate your guidance on this issue and welcome any further suggestions or recommendations you may have. |
Yes, we can add some clarifications to the docs regarding this.
The problem with this is false positives. There are some things, depending on the CACHE status that might work fine, and printing warnings might annoy some users that are ok with their usage.
We have worked hard to make sure that the build system integrations are as transparent as possible, in this regard, the "canonical" flow could be The |
Hi @memsharded Thank you for the comprehensive explanation. |
This question can be closed |
Thanks for the feedback! I was further trying yesterday in code to see if there could be any possibility, but the way CMake caches and processes the CMAKE_CXX_FLAGS makes this impossible. I'll move this to the |
What is your question?
I have a Ninja Multi-Config CMake project whose Conan recipe has a
build()
method that configures and builds the project. Before Conan 2.1.0, I could build the project for different configurations using the following commands:conan build -s:h build_type=Release
conan build -s:h build_type=Debug
These commands could be run in any order, and the second command would work correctly.
However, after upgrading to Conan 2.1.0, the second command fails due to missing C++ flags. Upon investigation, I found that the commit conan-io/conan@7d93ccc, introduced by conan-io/conan#15654, changed the behavior of
extra_cxxflags
.Instead of initializing
CMAKE_CXX_FLAGS_INIT
, theextra_cxxflags
now initializeCMAKE_CXX_FLAGS_<CONFIG>_INIT
. This means that when my recipe'sbuild()
method immediately configures CMake, it only sets up the flags for the first build configuration, and the subsequent configurations do not have access to the desired flags.My project sets up
extra_cxxflags
in theconanfile.py
and expects to use it across all configurations. According to the CMake documentation,CMAKE_<LANG>_FLAGS
is supposed to be used for "Language-wide flags for language used when building for all configurations," and "The flags in this variable will be passed before those in the per-configurationCMAKE_<LANG>_FLAGS_<CONFIG>
variable." Furthermore,CMAKE_<LANG>_FLAGS
is initialized byCMAKE_<LANG>_FLAGS_INIT
.My question is: How can I achieve the same behavior as before Conan 2.1.0 with CMakeToolchain and Ninja Multi-Config? Is there a way to set
CMAKE_CXX_FLAGS_INIT
or equivalent flags that apply to all configurations in a Ninja Multi-Config CMake project when using Conan?I have tried using
conan install
instead ofconan build
, and manually configuring CMake afterwards, which seems to work correctly. However, I would like to understand if there is a better solution that allows me to useconan build
and have the desired flags applied across all configurations.Any guidance or suggestions would be appreciated.
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: