diff --git a/build/executorch-config.cmake b/build/executorch-config.cmake index 4376c9e5e77..028bf54a637 100644 --- a/build/executorch-config.cmake +++ b/build/executorch-config.cmake @@ -1,3 +1,4 @@ + # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # @@ -13,7 +14,7 @@ cmake_minimum_required(VERSION 3.19) set(_root "${CMAKE_CURRENT_LIST_DIR}/../..") -set(required_lib_list executorch executorch_no_prim_ops portable_kernels) +set(required_lib_list executorch executorch_core portable_kernels) foreach(lib ${required_lib_list}) set(lib_var "LIB_${lib}") add_library(${lib} STATIC IMPORTED) @@ -26,7 +27,7 @@ foreach(lib ${required_lib_list}) target_include_directories(${lib} INTERFACE ${_root}) endforeach() -target_link_libraries(executorch INTERFACE executorch_no_prim_ops) +target_link_libraries(executorch INTERFACE executorch_core) if(CMAKE_BUILD_TYPE MATCHES "Debug") set(FLATCCRT_LIB flatccrt_d) @@ -48,8 +49,13 @@ set(lib_list extension_runner_util extension_tensor extension_threadpool + extension_training xnnpack_backend + # Start XNNPACK Lib Deps XNNPACK + microkernels-prod + kleidiai + # End XNNPACK Lib Deps cpuinfo pthreadpool vulkan_backend diff --git a/build/executorch-wheel-config.cmake b/build/executorch-wheel-config.cmake new file mode 100644 index 00000000000..c0ef7be1b05 --- /dev/null +++ b/build/executorch-wheel-config.cmake @@ -0,0 +1,40 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +# Config defining how CMake should find ExecuTorch package. CMake will search +# for this file and find ExecuTorch package if it is installed. Typical usage +# is: +# +# find_package(executorch REQUIRED) +# ------- +# +# Finds the ExecuTorch library +# +# This will define the following variables: +# +# EXECUTORCH_FOUND -- True if the system has the ExecuTorch library +# EXECUTORCH_INCLUDE_DIRS -- The include directories for ExecuTorch +# EXECUTORCH_LIBRARIES -- Libraries to link against +# +cmake_minimum_required(VERSION 3.19) + +# Find prebuilt _portable_lib.so. This file should be installed under +# /executorch/share/cmake +find_library(_portable_lib_LIBRARY _portable_lib.so PATHS "${CMAKE_CURRENT_LIST_DIR}/../../extension/pybindings/") +set(EXECUTORCH_LIBRARIES) +set(EXECUTORCH_FOUND OFF) +if(_portable_lib_LIBRARY) + set(EXECUTORCH_FOUND ON) + message(STATUS "ExecuTorch portable library is found at ${_portable_lib_LIBRARY}") + list(APPEND EXECUTORCH_LIBRARIES _portable_lib) + add_library(_portable_lib STATIC IMPORTED) + set(EXECUTORCH_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/include) + set_target_properties(_portable_lib PROPERTIES + IMPORTED_LOCATION "${_portable_lib_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${EXECUTORCH_INCLUDE_DIRS}" + CXX_STANDARD 17 + ) +endif() diff --git a/setup.py b/setup.py index f6adb4f86c3..884a7ad1a57 100644 --- a/setup.py +++ b/setup.py @@ -423,6 +423,11 @@ def run(self): "devtools/bundled_program/schema/scalar_type.fbs", "devtools/bundled_program/serialize/scalar_type.fbs", ), + # Install executorch-wheel-config.cmake to pip package. + ( + "build/executorch-wheel-config.cmake", + "share/cmake/executorch-config.cmake", + ), ] for src, dst in src_to_dst: dst = os.path.join(dst_root, dst) @@ -663,6 +668,10 @@ def get_ext_modules() -> List[Extension]: return ext_modules +# Override extension suffix to be ".so", skipping package info such as +# "cpython-311-darwin" +os.environ["SETUPTOOLS_EXT_SUFFIX"] = ".so" + setup( version=Version.string(), # TODO(dbort): Could use py_modules to restrict the set of modules we