Open ashley-b opened 1 year ago
Hi @ashley-b
Thanks for your question.
It seems that you are referencing the legacy CMake
helper, but you might be using the new one from conan.tools.cmake import CMake
(read https://docs.conan.io/en/1.59/reference/conanfile/tools.html), that doesn't have the get_version()
anymore.
Thanks for the quick response. Your absolute right, I am using the modern conan.tools.cmake imports.
The reason am ask is I want to write a check to see if I need a tool_requires for cmake if its too old. This seams like a common pattern for conancenter recipes
recipes/benchmark/all/conanfile.py:51: def _cmake_new_enough(self, required_version):
recipes/benchmark/all/conanfile.py:63: if Version(self.version) >= "1.7.1" and not self._cmake_new_enough("3.16.3"):
recipes/c-blosc2/all/conanfile.py:82: def _cmake_new_enough(self, required_version):
recipes/c-blosc2/all/conanfile.py:94: if Version(self.version) >= "2.4.1" and not self._cmake_new_enough("3.16.3"):
recipes/cppbenchmark/all/conanfile.py:68: def _cmake_new_enough(self, required_version):
recipes/cppbenchmark/all/conanfile.py:80: if not self._cmake_new_enough("3.20"):
recipes/cppserver/all/conanfile.py:72: def _cmake_new_enough(self, required_version):
recipes/cppserver/all/conanfile.py:84: if Version(self.version) >= "1.0.2.0" and not self._cmake_new_enough("3.20"):
recipes/cryptopp/all/conanfile.py:53: def _cmake_new_enough(self, required_version):
recipes/cryptopp/all/conanfile.py:65: if Version(self.version) >= "8.7.0" and not self._cmake_new_enough("3.20"):
recipes/cyclonedds/all/conanfile.py:88: def _cmake_new_enough(self, required_version):
recipes/cyclonedds/all/conanfile.py:100: if not self._cmake_new_enough("3.16"):
recipes/flatbuffers/all/conanfile.py:45: def _cmake_new_enough(self, required_version):
recipes/flatbuffers/all/conanfile.py:57: if Version(self.version) >= "2.0.7" and not self._cmake_new_enough("3.16"):
recipes/foonathan-lexy/all/conanfile.py:57: def _cmake_new_enough(self, required_version):
recipes/foonathan-lexy/all/conanfile.py:69: if not self._cmake_new_enough("3.18"):
recipes/glog/all/conanfile.py:61: def _cmake_new_enough(self, required_version):
recipes/glog/all/conanfile.py:73: if Version(self.version) >= "0.6.0" and not self._cmake_new_enough("3.16"):
recipes/googleapis/all/conanfile.py:71: def _cmake_new_enough(self):
recipes/googleapis/all/conanfile.py:90: if not self._cmake_new_enough:
recipes/h3/all/conanfile.py:49: def _cmake_new_enough(self, required_version):
recipes/h3/all/conanfile.py:61: if Version(self.version) >= "4.1.0" and not self._cmake_new_enough("3.20"):
recipes/hdf5/all/conanfile.py:98: def _cmake_new_enough(self, required_version):
recipes/hdf5/all/conanfile.py:118: if Version(self.version) >= "1.14.0" and not self._cmake_new_enough("3.18"):
recipes/libmysqlclient/all/conanfile.py:92: def _cmake_new_enough(self, required_version):
recipes/libmysqlclient/all/conanfile.py:104: if is_apple_os(self) and not self._cmake_new_enough("3.18"):
recipes/libsamplerate/all/conanfile.py:46: def _cmake_new_enough(self, required_version):
recipes/libsamplerate/all/conanfile.py:60: if not self._cmake_new_enough("3.17"):
recipes/libtorrent/all/conanfile.py:103: def _cmake_new_enough(self, required_version):
recipes/libtorrent/all/conanfile.py:115: if Version(self.version) >= "2.0.4" and not self._cmake_new_enough("3.16.0"):
recipes/qxlsx/all/conanfile.py:50: def _cmake_new_enough(self, required_version):
recipes/qxlsx/all/conanfile.py:62: if Version(self.version) >= "1.4.4" and not self._cmake_new_enough("3.16"):
recipes/screen_capture_lite/all/conanfile.py:82: def _cmake_new_enough(self, required_version):
recipes/screen_capture_lite/all/conanfile.py:94: if Version(self.version) >= "17.1.596" and not self._cmake_new_enough("3.16"):
recipes/sentry-native/all/conanfile.py:135: def _cmake_new_enough(self, required_version):
recipes/sentry-native/all/conanfile.py:147: if self.settings.os == "Windows" and not self._cmake_new_enough("3.16.4"):
recipes/spirv-tools/all/conanfile.py:102: def _cmake_new_enough(self, required_version):
recipes/spirv-tools/all/conanfile.py:116: if not self._cmake_new_enough("3.17.2"):
recipes/wavelet_buffer/all/conanfile.py:83: def _cmake_new_enough(self, required_version):
recipes/wavelet_buffer/all/conanfile.py:95: if not self._cmake_new_enough("3.16"):
Perhaps _cmake_new_enough should be a utility function to provided by conan ? or bring back get_version()
Actually, that pattern in ConanCenter will be removed.
Conan 2.0 provides a new mechanism, called [system_tools]
that allows simpler recipes and user control. The idea is that a recipe should "declare" what it needs, not that it should be checking any version to do things.
Hi @ashley-b, to give a little more insight into what @memsharded says:
We are trying to move away from the _cmake_new_enough
construct in CCI as there's a better approach available now:
tool_requires
to cmake with a version range for your minimum required version. Note that ever since https://github.com/conan-io/conan-center-index/pull/16503 CMake is no longer built by default, official binaries are downloaded instead.system_tool
(Docs here) to your installed CMake.This way, Conan will use your local version if it meets the specified range is, else fetch a binary from kitware :)
Thank you both for the detailed explanation.
Environment details
Steps to reproduce
This static method is documented here https://docs.conan.io/en/1.59/reference/build_helpers/cmake.html?highlight=get_version#get-version It is also mentioned here #5292
Logs