| 
50 | 50 | cmake_minimum_required(VERSION 3.29)  | 
51 | 51 | project(executorch)  | 
52 | 52 | 
 
  | 
 | 53 | +set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR})  | 
 | 54 | + | 
53 | 55 | include(${PROJECT_SOURCE_DIR}/tools/cmake/common/preset.cmake)  | 
 | 56 | +include(${PROJECT_SOURCE_DIR}/tools/cmake/Codegen.cmake)  | 
54 | 57 | include(${PROJECT_SOURCE_DIR}/tools/cmake/Utils.cmake)  | 
55 | 58 | include(CMakeDependentOption)  | 
56 | 59 | include(ExternalProject)  | 
@@ -123,8 +126,6 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)  | 
123 | 126 | # Instead please use `find_package(executorch REQUIRED)` in the example  | 
124 | 127 | # directory and add a new executable in the example `CMakeLists.txt`.  | 
125 | 128 | 
 
  | 
126 |  | -set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR})  | 
127 |  | - | 
128 | 129 | if(NOT EXECUTORCH_ENABLE_LOGGING)  | 
129 | 130 |   # Avoid pulling in the logging strings, which can be large. Note that this  | 
130 | 131 |   # will set the compiler flag for all targets in this directory, and for all  | 
@@ -278,29 +279,6 @@ if(EXECUTORCH_BUILD_PTHREADPOOL)  | 
278 | 279 |   )  | 
279 | 280 | endif()  | 
280 | 281 | 
 
  | 
281 |  | -if(EXECUTORCH_BUILD_KERNELS_TORCHAO)  | 
282 |  | -  set(TORCHAO_BUILD_ATEN_OPS OFF)  | 
283 |  | -  set(TORCHAO_BUILD_EXECUTORCH_OPS ON)  | 
284 |  | -  set(TORCHAO_BUILD_CPU_AARCH64 ON)  | 
285 |  | -  set(TORCHAO_ENABLE_ARM_NEON_DOT ON)  | 
286 |  | - | 
287 |  | -  list(  | 
288 |  | -    APPEND  | 
289 |  | -    TORCHAO_INCLUDE_DIRS  | 
290 |  | -    ${EXECUTORCH_ROOT}/backends/xnnpack/third-party/pthreadpool/include  | 
291 |  | -    ${EXECUTORCH_ROOT}/backends/xnnpack/third-party/cpuinfo/include  | 
292 |  | -    ${EXECUTORCH_ROOT}/third-party/ao  | 
293 |  | -  )  | 
294 |  | - | 
295 |  | -  set(EXECUTORCH_INCLUDE_DIRS ${TORCHAO_INCLUDE_DIRS})  | 
296 |  | - | 
297 |  | -  add_subdirectory(  | 
298 |  | -    ${CMAKE_CURRENT_SOURCE_DIR}/third-party/ao/torchao/experimental  | 
299 |  | -  )  | 
300 |  | -  executorch_target_link_options_shared_lib(torchao_ops_executorch)  | 
301 |  | -  list(APPEND _executorch_kernels torchao_ops_executorch)  | 
302 |  | -endif()  | 
303 |  | - | 
304 | 282 | if(EXECUTORCH_BUILD_TESTS)  | 
305 | 283 |   set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)  | 
306 | 284 |   include(CTest)  | 
@@ -343,6 +321,7 @@ if(NOT EXECUTORCH_SRCS_FILE)  | 
343 | 321 |   message(STATUS "executorch: Generating source lists")  | 
344 | 322 |   set(EXECUTORCH_SRCS_FILE "${CMAKE_CURRENT_BINARY_DIR}/executorch_srcs.cmake")  | 
345 | 323 |   extract_sources(${EXECUTORCH_SRCS_FILE})  | 
 | 324 | +  executorch_validate_build_variables()  | 
346 | 325 | endif()  | 
347 | 326 | 
 
  | 
348 | 327 | # This file defines the `_<target>__srcs` variables used below.  | 
@@ -705,6 +684,65 @@ if(EXECUTORCH_BUILD_PTHREADPOOL AND EXECUTORCH_BUILD_CPUINFO)  | 
705 | 684 |   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/threadpool)  | 
706 | 685 | endif()  | 
707 | 686 | 
 
  | 
 | 687 | +if(EXECUTORCH_BUILD_KERNELS_TORCHAO)  | 
 | 688 | +  if(NOT TARGET cpuinfo)  | 
 | 689 | +    message(  | 
 | 690 | +      FATAL_ERROR  | 
 | 691 | +        "EXECUTORCH_BUILD_KERNELS_TORCHAO requires EXECUTORCH_BUILD_CPUINFO be set ON"  | 
 | 692 | +    )  | 
 | 693 | +  endif()  | 
 | 694 | +  if(NOT TARGET pthreadpool)  | 
 | 695 | +    message(  | 
 | 696 | +      FATAL_ERROR  | 
 | 697 | +        "EXECUTORCH_BUILD_KERNELS_TORCHAO requires EXECUTORCH_BUILD_PTHREADPOOL be set ON"  | 
 | 698 | +    )  | 
 | 699 | +  endif()  | 
 | 700 | + | 
 | 701 | +  # Configure TorchAO kernels  | 
 | 702 | +  set(TORCHAO_BUILD_ATEN_OPS OFF)  | 
 | 703 | +  set(TORCHAO_BUILD_EXECUTORCH_OPS ON)  | 
 | 704 | +  set(TORCHAO_BUILD_CPU_AARCH64 ON)  | 
 | 705 | +  set(TORCHAO_ENABLE_ARM_NEON_DOT ON)  | 
 | 706 | +  set(TORCHAO_BUILD_KLEIDIAI ON)  | 
 | 707 | + | 
 | 708 | +  # TorchAO kernels look for EXECUTORCH_INCLUDE_DIRS  | 
 | 709 | +  if(DEFINED EXECUTORCH_INCLUDE_DIRS)  | 
 | 710 | +    message(FATAL_ERROR "EXECUTORCH_INCLUDE_DIRS is already defined")  | 
 | 711 | +  endif()  | 
 | 712 | +  set(EXECUTORCH_INCLUDE_DIRS  | 
 | 713 | +      ${EXECUTORCH_ROOT}/backends/xnnpack/third-party/pthreadpool/include  | 
 | 714 | +      ${EXECUTORCH_ROOT}/backends/xnnpack/third-party/cpuinfo/include  | 
 | 715 | +  )  | 
 | 716 | +  add_subdirectory(  | 
 | 717 | +    ${CMAKE_CURRENT_SOURCE_DIR}/third-party/ao/torchao/experimental  | 
 | 718 | +  )  | 
 | 719 | +  unset(EXECUTORCH_INCLUDE_DIRS)  | 
 | 720 | + | 
 | 721 | +  executorch_target_link_options_shared_lib(torchao_ops_executorch)  | 
 | 722 | +  list(APPEND _executorch_kernels torchao_ops_executorch)  | 
 | 723 | + | 
 | 724 | +  install(  | 
 | 725 | +    TARGETS torchao_ops_executorch torchao_kernels_aarch64  | 
 | 726 | +    EXPORT ExecuTorchTargets  | 
 | 727 | +    DESTINATION lib  | 
 | 728 | +    INCLUDES  | 
 | 729 | +    DESTINATION ${_common_include_directories}  | 
 | 730 | +  )  | 
 | 731 | +  # If using KleidiAI and XNNPACK has not installed it already, install it  | 
 | 732 | +  if(TORCHAO_BUILD_KLEIDIAI AND NOT (EXECUTORCH_BUILD_XNNPACK  | 
 | 733 | +                                     AND EXECUTORCH_XNNPACK_ENABLE_KLEIDI)  | 
 | 734 | +  )  | 
 | 735 | +    install(  | 
 | 736 | +      TARGETS kleidiai  | 
 | 737 | +      EXPORT ExecuTorchTargets  | 
 | 738 | +      DESTINATION lib  | 
 | 739 | +      INCLUDES  | 
 | 740 | +      DESTINATION ${_common_include_directories}  | 
 | 741 | +    )  | 
 | 742 | +  endif()  | 
 | 743 | + | 
 | 744 | +endif()  | 
 | 745 | + | 
708 | 746 | if(EXECUTORCH_BUILD_PYBIND)  | 
709 | 747 | 
 
  | 
710 | 748 |   # Add codegen tools subdirectory for selective_build pybind module  | 
 | 
0 commit comments