22from conan .errors import ConanInvalidConfiguration
33from conan .tools .cmake import CMake , CMakeDeps , CMakeToolchain , cmake_layout
44from conan .tools .files import copy , get , replace_in_file
5- from conan .tools .microsoft import check_min_vs
5+ from conan .tools .microsoft import check_min_vs , is_msvc
66from conan .tools .scm import Version
77import os
88
@@ -44,12 +44,18 @@ def export_sources(self):
4444 def layout (self ):
4545 cmake_layout (self , src_folder = "src" )
4646
47+ @property
48+ def _with_kleidiai (self ):
49+ return Version (self .version ) >= "cci.20241203" and "arm" in str (self .settings .arch ) and not is_msvc (self )
50+
4751 def requirements (self ):
4852 self .requires ("cpuinfo/[>=cci.20231129]" )
4953 self .requires ("fp16/cci.20210320" )
5054 # https://github.com/google/XNNPACK/blob/ed5f9c0562e016a08b274a4579de5ef500fec134/include/xnnpack.h#L15
5155 self .requires ("pthreadpool/cci.20231129" , transitive_headers = True )
5256 self .requires ("fxdiv/cci.20200417" )
57+ if self ._with_kleidiai :
58+ self .requires ("kleidiai/1.18.0" )
5359
5460 def validate (self ):
5561 check_min_vs (self , 192 )
@@ -85,9 +91,8 @@ def generate(self):
8591 tc .variables ["CMAKE_SKIP_INSTALL_ALL_DEPENDENCY" ] = True
8692 # To export symbols for shared msvc
8793 tc .variables ["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS" ] = True
88- # TODO Support?
8994 if Version (self .version ) >= "cci.20241203" :
90- tc .cache_variables ["XNNPACK_ENABLE_KLEIDIAI" ] = False
95+ tc .cache_variables ["XNNPACK_ENABLE_KLEIDIAI" ] = self . _with_kleidiai
9196 tc .generate ()
9297
9398 deps = CMakeDeps (self )
@@ -101,6 +106,7 @@ def generate(self):
101106 deps .set_property ("pthreadpool" , "cmake_target_name" , "pthreadpool" )
102107 deps .set_property ("fp16" , "cmake_target_name" , "fp16" )
103108 deps .set_property ("fxdiv" , "cmake_target_name" , "fxdiv" )
109+ deps .set_property ("kleidiai" , "cmake_target_name" , "kleidiai" )
104110 deps .generate ()
105111
106112 def _patch_sources (self ):
@@ -126,7 +132,6 @@ def package(self):
126132 cmake .install ()
127133
128134 def package_info (self ):
129- # TODO: XNN_LOG_LEVEL definition?
130135 self .cpp_info .components ["xnnpack" ].libs = ["XNNPACK" ]
131136 self .cpp_info .components ["xnnpack" ].requires = [
132137 "fxdiv::fxdiv" ,
@@ -141,6 +146,10 @@ def package_info(self):
141146 "fxdiv::fxdiv" ,
142147 ]
143148 self .cpp_info .components ["xnnpack" ].requires .append ("microkernels-prod" )
149+ if self ._with_kleidiai :
150+ self .cpp_info .components ["microkernels-prod" ].requires .append ("kleidiai::kleidiai" )
151+ self .cpp_info .components ["xnnpack" ].requires .append ("kleidiai::kleidiai" )
152+
144153 if self .settings .os in ["Linux" , "FreeBSD" ]:
145154 self .cpp_info .components ["microkernels-prod" ].system_libs = ["m" ]
146155
0 commit comments