Issue
I've just started using Conan package manager. Do you know is it possible to somehow call cmake with presets from conanfile.py? The current implementation is the following:
...
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
...
I've managed to call CMakePresets.json by the following code (but it seems hacky - I don't like it).
...
def cmake_configure(self)
if self.settings.os == "Linux":
self.run("cmake --preset=linux .")
elif self.settings.os == "Macos":
self.run("cmake --preset=macos .")
elif self.settings.os == "Windows":
self.run("cmake --preset=windows .")
else:
raise ConanInvalidConfiguration("Unsupported OS")
def build(self):
self.cmake_configure()
self.run("cmake --build .")
...
Thank you in advance
Solution
Conan maintains backward compatibility with older CMake versions. Even for Conan 2.0, the community has reached a consensus (https://github.com/conan-io/tribe/pull/4) that CMake 3.15 is the base to support, that means that Conan should work by default with CMake 3.15 (or newer). If Conan used cmake presets, which is cmake>=3.19, then that wouldn't be satisfied. At some point, Conan will add some tools to manage presets, but at the moment there is nothing built-in.
However, using presets, might not be necessary, as CMakeToolchain will generate a conan_toolchain.cmake
file that can help with the integration (the CMake generator is still necessary to be passed in command line).
Answered By - drodri