Conan: [question] Is it possible to use the compiler name as a setting, but not its version?

Created on 7 May 2018  路  3Comments  路  Source: conan-io/conan

We are developing an application depending on a 3rd party prebuilt binary.
As our workflow may move toward Conan, currently using 1.2 on OSX and Windows, we packaged it following the doc. Yet we realized that when we use compiler in the settings list, not only a change in compiler name (gcc, clang, ...) will make the package "not found", but also a change in its version.

We would like to actually use the same prebuilt binary for the few version of our given compilers that our build supports. Is it possible with Conan current settings system?

  • [x] I've read the CONTRIBUTING guide.
  • [x] I've specified the Conan version, operating system version and any tool that can be relevant.
  • [x] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.
question

All 3 comments

Yes, the correct way to define custom logic for that kind of behavior is in the package_id() method. Not removing the setting, because it is still needed as an input, but re-defining the mapping to compatible versions. Something like:

def package_id(self):
     # if we want to have the same binary for all gcc 4.X versions
     if self.settings.compiler == "gcc" and str(self.settings.compiler.version) in ["4.8", "4.9"]:
          self.info.settings.compiler.version="4.X"  # NOTE the "self.info"

Please have a look at this section: http://docs.conan.io/en/latest/creating_packages/define_abi_compatibility.html#defining-a-custom-package-id, and tell me if you have further questions. Thanks!

Thank you very much for you help, that is exactly on point and solves our problem!

Great. Closing it then, but feel free to open a new one or comment if further questions about this issue. Thanks!

Was this page helpful?
0 / 5 - 0 ratings