conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.31k stars 986 forks source link

[question] Is there a way to set CMAKE_CXX_FLAGS_${config}_INIT ? #17179

Closed VA-GS closed 1 month ago

VA-GS commented 1 month ago

What is your question?

Hello, I am able to pass compilation flags to my dependencies with tools.build:cxxflags but is there a way to request Conan to clear CMAKE_CXX_FLAGS_INIT ?

In my case, I am passing -O3 in tools.build:cxxflags for my rel_with_dbg mode and found out that the compilation flags still contain the -O2 from CMAKE_CXX_FLAGS_INIT too.

memsharded commented 1 month ago

Hi @VA-GS

Thanks for your question.

You can define arbitrary CMake variables with conf tools.cmake.cmaketoolchain:extra_variables

You can also inject full user cmake files with conf tools.cmake.cmaketoolchain:user_toolchain

Please check them and let us know if this helps.

VA-GS commented 1 month ago

Thanks! It is only in v2 ? I am still on v1.

memsharded commented 1 month ago

The user_toolchain is available in Conan 1.X I think, but extra_variables is modern Conan 2.X only

VA-GS commented 1 month ago

user_toolchain works for my use-case, thanks!

memsharded commented 1 month ago

Ok, closing the ticket as resolved then, thanks for the feedback!