From 6de3ca44b99aa8e7b1126af9c05b7071e4753c48 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Wed, 11 Dec 2024 17:03:02 +0100 Subject: [PATCH] Enforce minimum compiler versions and C++20 support Added checks to validate minimum compiler versions and enforce C++20 compatibility for the package. These include GCC 12, Clang 14, Apple Clang 13, MSVC 191, and Visual Studio 17. This ensures compatibility with the required C++ features, preventing builds with unsupported compilers. Contribute to NP-637 --- conanfile.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/conanfile.py b/conanfile.py index db466d48db..e4e08ec806 100644 --- a/conanfile.py +++ b/conanfile.py @@ -3,9 +3,11 @@ import os from conan import ConanFile +from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout from conan.tools.files import copy, mkdir, update_conandata +from conan.tools.microsoft import check_min_vs, is_msvc from conan.tools.scm import Version, Git required_conan_version = ">=2.7.0" @@ -41,6 +43,16 @@ class CuraEngineConan(ConanFile): "with_cura_resources": False, } + @property + def _compilers_minimum_version(self): + return { + "gcc": "12", + "clang": "14", + "apple-clang": "13", + "msvc": "191", + "visual_studio": "17", + } + def init(self): base = self.python_requires["sentrylibrary"].module.SentryLibrary self.options.update(base.options, base.default_options) @@ -87,6 +99,12 @@ def validate(self): if self.settings.compiler.get_safe("cppstd"): check_min_cppstd(self, 20) + check_min_vs(self, 191) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.") def build_requirements(self): self.test_requires("standardprojectsettings/[>=0.2.0]@ultimaker/stable")