I am trying to build Cura using conan
and a dependency fails to build because my version of cmake
is 3.20, but it wants 3.23. I can manually change it to 3.20 and it builds just fine, but conan
keeps resetting CMakeLists.txt
to its pre-modified state when I run this to build Cura:
## Build it
# conan install . --build=missing --update -o cura:devtools=True -g VirtualPythonEnv
...
CMake Error at CMakeLists.txt:3 (cmake_minimum_required):
CMake 3.23 or higher is required. You are running version 3.20.2
...
ConanException: Error 1 while executing cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="/home/ewheeler/.conan/data/arcus/5.3.0/_/_/build/7bb59b7dbf92ac7a06f25b01418f550161106450/build/Release/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/ewheeler/.conan/data/arcus/5.3.0/_/_/package/7bb59b7dbf92ac7a06f25b01418f550161106450" -DCMAKE_POLICY_DEFAULT_CMP0077="NEW" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/ewheeler/.conan/data/arcus/5.3.0/_/_/build/7bb59b7dbf92ac7a06f25b01418f550161106450/."
## Fix it
# vim /home/ewheeler/.conan/data/arcus/5.3.0/_/_/build/7bb59b7dbf92ac7a06f25b01418f550161106450/CMakeLists.txt
<fix it by changing 3.23 to 3.20 in CMakeLists.txt>
## Re-run the command that failed:
# cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="/home/ewheeler/.conan/data/arcus/5.3.0/_/_/build/7bb59b7dbf92ac7a06f25b01418f550161106450/build/Release/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/ewheeler/.conan/data/arcus/5.3.0/_/_/package/7bb59b7dbf92ac7a06f25b01418f550161106450" -DCMAKE_POLICY_DEFAULT_CMP0077="NEW" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/ewheeler/.conan/data/arcus/5.3.0/_/_/build/7bb59b7dbf92ac7a06f25b01418f550161106450/."
<cmake succeeds>
## re-run `conan install`, but the problem
## repeats because conan resets the build environment.
Question: How do can I get this to build?
xyproblem questions that would solve it:
cmake
ignore cmake_minimum_required
via environment variable?chattr +i
but it blows up during cleanupThis is my first experience with conan
, so any help would be appreciated.
nb, I would rather not install a newer version of cmake... (I rebuilt cmake 3.24 and conan
is continuing, but I'll leave SE question here in case someone has an answer for the next person.)
Can cmake ignore cmake_minimum_required via environment variable?
Up to my knowledge, CMake doesn't have that feature.
Can conan leave my changes alone, or pick up where it left off without reset?
Modifying files in the Conan cache is forbidden, and your changes can be indeed overwritten. Check the Conan guidelines
Conan is a package manager that wraps the build system. It is not Conan the one defining that CMake 3.23 is necessary, but the upstream project, that defined that in its own CMakeLists.txt
. Conan recipes can patch source code at package creation time, but that is done in the conanfile.py
recipe of the package, not from the consumers.
If the upstream project defines its minimum CMake as 3.23, it is strongly recommended to respect it, even if it seems it works with older versions, there always could be subtle unexpected differences.
In any case, this can be done defining in your myprofile.txt
:
include(default)
[tool_requires]
cmake/[>=3.23]
And then passing it as argument with -pr=myprofile
(not sure if easy to modify it within the Cura project).
Or adding those 2 lines in your default
profile. Conan will manage to download a newer cmake version and inject it to the dependencies, without changing your system one.