conan-io / conan

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

[feature] Add the ability to choose -isystem vs -I #17140

Closed LucidDistress closed 1 month ago

LucidDistress commented 1 month ago

What is your suggestion?

I saw this issue come up in version 1.0, and it looks like there was a feature included to opt out of using -isystem for includes. But I do not see anything in 2.0 for that. Years ago, I managed to get Ada and CMake to cooperate with a lot of headaches, but it was a requirement we have at my current company. Now we are trying to integrate the whole baseline into conan and the first ada library I tried to package failed to find an "include" file (.ads) even though I could very clearly see it in the build command after -isystem. I finally tried to run the command manually and changed the -isystem to -I and it worked. I am not sure if Ada just doesn't like -isystem or what, but I need the option to remove it.

Have you read the CONTRIBUTING guide?

LucidDistress commented 1 month ago

I was finally able to find a global override for this in cmake. Sucks that I can't do it a little more targeted, but at least it fixes my issue.

memsharded commented 1 month ago

Hi @LucidDistress

Thanks for your suggestion.

The problem with this is that Conan doesn't really chose what approach to use, if -isystem or -I and that belongs mostly to CMake or specific build systems, in the consumer side, so not something that can be implemented natively in Conan.

I guess the CMake solution you found is the NO_SYSTEM_FROM_IMPORTED one? https://cmake.org/cmake/help/v3.8/prop_tgt/NO_SYSTEM_FROM_IMPORTED.html

If that is true, then maybe you are looking for the capability of adding extra variables with the conf tools.cmake.cmaketoolchain:extra_variables? You can define NO_SYSTEM_FROM_IMPORTED directly from your profile, to inject into every package using CMakeToolchain. The conf can also be scoped per-package, like mypkg/*:tools.cmake.cmaketoolchain:extra_variables= in your profile

Extra variables can also be defined in recipes with toolchain.cache_variables["VAR"] =, you can do it in the generate() method too.

Please let me know if this helps.

memsharded commented 1 month ago

Any further question or comment here? Thanks for your feedback.

LucidDistress commented 1 month ago

That is exactly what I ended up finding. I was able to scope it to that particular Ada library and it worked great. I'm just glad I managed to get an Ada library to work in Conan because we have a lot of ada toanage unfortunately. Thank you for the suggestions and explanations.

memsharded commented 1 month ago

Happy to help!