Conan: Visual Studio compiler.version and compiler.toolchain

Created on 13 Jul 2018  路  6Comments  路  Source: conan-io/conan

When dealing with visual studio (with 2015 and 2017 both in use) we have

  • compiler.version of 14 and 15
  • compiler.toolchain of v140 or v141

What what I understand, v140 vs v141 has an impact on the binaries that are produced (for example if you build with v141 it can use symbols in the v141 c++ standard lib that aren't in the v140, but the other way is fine). The 14 vs 15 only matters at build time (and so shouldn't matter for consumers).

So it seems like a slightly cleaner setup would be to have compiler.version of v140 or v141 and then have the Visual studio 14 or 15 be something that is passed to the cmake or msbuild calls (or just surmised as a newer version is always better, I think).

I may well be confused a bit, but I feel like I am finally getting a handle on it.

question

All 6 comments

Hi @drussel

Conan follows the CMake model, which specifies the VS version instead of the toolset version, then has another parameter to specify the toolset. If you check the settings.yml file:

compiler:
    sun-cc:

    gcc:

    Visual Studio:
        runtime: [MD, MT, MTd, MDd]
        version: ["8", "9", "10", "11", "12", "14", "15"]
        toolset: [None, v90, v100, v110, v110_xp, v120, v120_xp, v140, v140_xp, v140_clang_c2, LLVM-vs2014, LLVM-vs2014_xp, v141, v141_xp, v141_clang_c2]

So VS 15 defaults to v141, and VS 14 to v140. The toolset=None default value means, the default VS one, in general it is not necessary to specify it, only when you want to use other than the default.

But for Conan (unlike cmake) the compiler properties play the role of creating a signature for the package which needs to match to be considered compatible. And with visual studio in Conan, when compiler.toolset is specified and matching I think the compiler.version doesn't matter for consumers.

Yes, good point. Conan tries not to be smart, lets say it is as simple and not interfering as possible. This is the default behavior in general, as you have correctly realized.

But in this case, some logic is built-in (which can be easily opt-out). Please check the docs here: https://docs.conan.io/en/latest/reference/conanfile/methods.html#self-info-vs-toolset-compatible-self-info-vs-toolset-incompatible. Thanks!

Nice, I'll add that to our packages. Seems like it might be a reasonable default.

No, you don't need to add it. It is the default behavior, please try it and report otherwise.
Maybe it is not fully clear in the docs, the docs should be fixed. Am I missing something @lasote?

You are right I misread it. Maybe I'm misunderstanding why we were seeing rebuilds then. I'll investigate some more. Sorry.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

niosHD picture niosHD  路  3Comments

zlalanne picture zlalanne  路  3Comments

petermbauer picture petermbauer  路  3Comments

bobeff picture bobeff  路  3Comments

zomeck picture zomeck  路  3Comments