Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions build/executorch-config.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down
40 changes: 40 additions & 0 deletions build/executorch-wheel-config.cmake
Original file line number Diff line number Diff line change
@@ -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
# <site-packages>/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()
9 changes: 9 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading