cmake-conan
cmake-conan copied to clipboard
Add '_get_conan_version()' function.
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 Studioincompiler. - In Conan 2.X, we need to use
msvcincompiler. (becauseVisual Studiois removed insettings.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()
@czoido Please check it. Thank you.
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 There's a typo on README.md in this merged PR.

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