cmake-conan icon indicating copy to clipboard operation
cmake-conan copied to clipboard

Add '_get_conan_version()' function.

Open hwhsu1231 opened this issue 3 years ago • 1 comments

Add _get_conan_version() function to aquire the current Conan version.

Since some of settings are introduced in Conan 2.X but not in Conan 1.X or some of them are deprecated in Conan 2.X, for example when using MSVC compiler,

  • In Conan 1.X, we may use Visual Studio in compiler.
  • In Conan 2.X, we need to use msvc in compiler. (because Visual Studio is removed in settings.yml)

Therefore, I think conan-cmake needs a mechanism to determine whether it is using Conan 1.X or Conan 2.X.

The following is an example usage of _get_conan_version() function.

_get_conan_version(_CONAN_VERSION)
if(_CONAN_VERSION VERSION_GREATER_EQUAL 2.0.0)
    # For Conan 2.X
else()
    # For Conan 1.X
endif()

hwhsu1231 avatar Sep 24 '22 15:09 hwhsu1231

@czoido Please check it. Thank you.

hwhsu1231 avatar Sep 24 '22 15:09 hwhsu1231

Hi @hwhsu1231,

Thanks a lot for the contribution, I think that the feature is valid, but let me do some refactors and add a test and the docs. I changed the name to conan_version and also called that inside conan_check to reuse the functionality, also added a test.

czoido avatar Oct 26 '22 09:10 czoido

@czoido There's a typo on README.md in this merged PR.

image

hwhsu1231 avatar Oct 26 '22 10:10 hwhsu1231

Oh, sorry, thanks a lot, I'll fix it

czoido avatar Oct 26 '22 10:10 czoido