Skip to content

Commit

Permalink
Enforce minimum compiler versions and C++20 support
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jellespijker committed Dec 11, 2024
1 parent 8930838 commit 6de3ca4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 6de3ca4

Please sign in to comment.