11from conan import ConanFile
22from conan .tools .build import check_min_cppstd
3+ from conan .tools .scm import Version
34from conan .tools .cmake import CMake , CMakeDeps , CMakeToolchain , cmake_layout
4- from conan .tools .files import (
5- apply_conandata_patches ,
6- copy ,
7- export_conandata_patches ,
8- get ,
9- rm ,
10- rmdir ,
11- )
5+ from conan .tools .files import copy , get , rm , rmdir
6+ from conan .errors import ConanInvalidConfiguration
7+
128import os
139
1410
@@ -26,7 +22,7 @@ class ChronCppConan(ConanFile):
2622 license = "Unlicense"
2723 url = "https://github.com/conan-io/conan-center-index"
2824 homepage = "https://github.com/BestITUserEUW/chron-cpp"
29- topics = "chron"
25+ topics = ( "chron" ,)
3026 package_type = "library"
3127 settings = "os" , "arch" , "compiler" , "build_type"
3228 options = {
@@ -40,26 +36,33 @@ class ChronCppConan(ConanFile):
4036 # In case having config_options() or configure() method, the logic should be moved to the specific methods.
4137 implements = ["auto_shared_fpic" ]
4238
43- # no exports_sources attribute, but export_sources(self) method instead
44- def export_sources (self ):
45- export_conandata_patches (self )
46-
4739 def configure (self ):
4840 if self .options .shared :
4941 self .options .rm_safe ("fPIC" )
5042
5143 def layout (self ):
52- cmake_layout (self )
44+ cmake_layout (self , src_folder = "." )
5345
5446 def validate (self ):
55- check_min_cppstd (self , 20 )
47+ if self .settings .compiler .get_safe ("cppstd" ):
48+ check_min_cppstd (self , self ._min_cppstd )
49+
50+ minimum_version = self ._compilers_minimum_version .get (
51+ str (self .settings .compiler ), False
52+ )
53+ if (
54+ minimum_version
55+ and Version (self .settings .compiler .version ) < minimum_version
56+ ):
57+ raise ConanInvalidConfiguration (
58+ f"{ self .ref } requires C++{ self ._min_cppstd } , which your compiler does not support."
59+ )
5660
5761 def build_requirements (self ):
5862 self .tool_requires ("cmake/[>=3.24]" )
5963
6064 def source (self ):
6165 get (self , ** self .conan_data ["sources" ][self .version ], strip_root = True )
62- apply_conandata_patches (self )
6366
6467 def generate (self ):
6568 deps = CMakeDeps (self )
@@ -94,3 +97,16 @@ def package_info(self):
9497 self .cpp_info .libs = ["chron-cpp" ]
9598 self .cpp_info .set_property ("cmake_file_name" , "chron-cpp" )
9699 self .cpp_info .set_property ("cmake_target_name" , "oryx::chron-cpp" )
100+
101+ @property
102+ def _compilers_minimum_version (self ):
103+ return {
104+ "gcc" : "13" ,
105+ "clang" : "16" ,
106+ "apple-clang" : "15" ,
107+ "msvc" : "192" ,
108+ }
109+
110+ @property
111+ def _min_cppstd (self ):
112+ return "20"
0 commit comments