Skip to content
Open
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
30 changes: 12 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -446,18 +446,21 @@ if(EXECUTORCH_BUILD_PYBIND AND APPLE)
endif()

#
# executorch: Primary runtime library with primitive operators.
# prim_ops_lib: Primary runtime library with primitive operators.
#
# Provides the Program and Method interfaces, along with primitive operators.
# Does not contain portable kernels or other full operators. Does not contain
# any backends.
#
add_library(executorch ${_executorch__srcs})
target_link_libraries(executorch PRIVATE executorch_core)
target_include_directories(executorch PUBLIC ${_common_include_directories})
target_compile_definitions(executorch PUBLIC C10_USING_CUSTOM_GENERATED_MACROS)
target_compile_options(executorch PUBLIC ${_common_compile_options})
executorch_target_link_options_shared_lib(executorch)
add_library(prim_ops_lib ${_executorch__srcs})
target_link_libraries(prim_ops_lib PRIVATE executorch_core)
target_include_directories(prim_ops_lib PUBLIC ${_common_include_directories})
target_compile_definitions(prim_ops_lib PUBLIC C10_USING_CUSTOM_GENERATED_MACROS)
target_compile_options(prim_ops_lib PUBLIC ${_common_compile_options})
target_link_options_shared_lib(prim_ops_lib)

# Legacy alias for backward compatibility during transition
add_library(executorch ALIAS prim_ops_lib)

#
# portable_ops_lib: A library to register core ATen ops using portable kernels,
Expand Down Expand Up @@ -528,9 +531,9 @@ install(
FILES_MATCHING
PATTERN "*.h"
)
# ...existing code...
install(
TARGETS executorch executorch_core
EXPORT ExecuTorchTargets
TARGETS prim_ops_lib executorch_core
INCLUDES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
Expand Down Expand Up @@ -990,12 +993,3 @@ if(EXECUTORCH_BUILD_ANDROID_JNI)
endif()

include(Test.cmake)

install(
EXPORT ExecuTorchTargets
FILE ExecuTorchTargets.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ExecuTorch
)

# Print all the configs that were called with announce_configured_options.
print_configured_options()
5 changes: 2 additions & 3 deletions backends/cadence/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ if(EXECUTORCH_CADENCE_CPU_RUNNER)
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)

set(_common_compile_options -Wno-deprecated-declarations -fPIC)

# Find prebuilt libraries. executorch package should contain portable_ops_lib,
# etdump, bundled_program.
find_package(executorch CONFIG REQUIRED)
executorch_target_link_options_shared_lib(executorch)
executorch_target_link_options_shared_lib(portable_ops_lib)
# Note: target_link_options_shared_lib(prim_ops_lib) is now called automatically in executorch-config.cmake


target_include_directories(
executorch INTERFACE ${_common_include_directories}
Expand Down
64 changes: 62 additions & 2 deletions examples/arm/executor_runner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,68 @@ add_corstone_subdirectory(${SYSTEM_CONFIG} ${ETHOS_SDK_PATH})
configure_timing_adapters(${SYSTEM_CONFIG} ${MEMORY_MODE})

# Dependencies from the ExecuTorch build
find_package(
executorch REQUIRED HINTS "${ET_BUILD_DIR_PATH}/lib/cmake/ExecuTorch"
add_library(executorch STATIC IMPORTED)
set_property(
TARGET executorch PROPERTY IMPORTED_LOCATION
"${ET_BUILD_DIR_PATH}/libexecutorch.a"
)

add_library(executorch_core STATIC IMPORTED)
set_property(
TARGET executorch_core
PROPERTY IMPORTED_LOCATION "${ET_BUILD_DIR_PATH}/libexecutorch_core.a"
)
target_link_libraries(executorch INTERFACE executorch_core)

add_library(executorch_delegate_ethos_u STATIC IMPORTED)
set_property(
TARGET executorch_delegate_ethos_u
PROPERTY IMPORTED_LOCATION
"${ET_BUILD_DIR_PATH}/backends/arm/libexecutorch_delegate_ethos_u.a"
)

add_library(portable_ops_lib STATIC IMPORTED)
set_property(
TARGET portable_ops_lib
PROPERTY IMPORTED_LOCATION
"${ET_BUILD_DIR_PATH}/examples/arm/libarm_portable_ops_lib.a"
)
add_library(portable_kernels STATIC IMPORTED)
set_property(
TARGET portable_kernels
PROPERTY IMPORTED_LOCATION
"${ET_BUILD_DIR_PATH}/kernels/portable/libportable_kernels.a"
)
add_library(quantized_ops_lib STATIC IMPORTED)
set_property(
TARGET quantized_ops_lib
PROPERTY IMPORTED_LOCATION
"${ET_BUILD_DIR_PATH}/kernels/quantized/libquantized_ops_lib.a"
)
add_library(quantized_kernels STATIC IMPORTED)
set_property(
TARGET quantized_kernels
PROPERTY IMPORTED_LOCATION
"${ET_BUILD_DIR_PATH}/kernels/quantized/libquantized_kernels.a"
)
add_library(cortex_m_ops_lib STATIC IMPORTED)
set_property(
TARGET cortex_m_ops_lib
PROPERTY IMPORTED_LOCATION
"${ET_BUILD_DIR_PATH}/backends/cortex_m/libcortex_m_ops_lib.a"
)
add_library(cortex_m_kernels STATIC IMPORTED)
set_property(
TARGET cortex_m_kernels
PROPERTY IMPORTED_LOCATION
"${ET_BUILD_DIR_PATH}/backends/cortex_m/libcortex_m_kernels.a"
)
add_library(extension_runner_util STATIC IMPORTED)
set_property(
TARGET extension_runner_util
PROPERTY
IMPORTED_LOCATION
"${ET_BUILD_DIR_PATH}/extension/runner_util/libextension_runner_util.a"
)

# Convert pte to header
Expand Down
2 changes: 0 additions & 2 deletions examples/devtools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ set(_common_include_directories ${EXECUTORCH_ROOT}/..)
# Find prebuilt libraries. executorch package should contain portable_ops_lib,
# etdump, bundled_program.
find_package(executorch CONFIG REQUIRED)
executorch_target_link_options_shared_lib(executorch)
executorch_target_link_options_shared_lib(portable_ops_lib)

target_include_directories(executorch INTERFACE ${_common_include_directories})

Expand Down
8 changes: 2 additions & 6 deletions examples/models/llama/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,8 @@ find_package(gflags REQUIRED)
# llama_main: test binary to run llama, with tokenizer and sampler integrated
#

# find `executorch` libraries. CMAKE_PREFIX_PATH would work for host
# compilation, but CMAKE_FIND_ROOT_PATH appears to be necessary for
# cross-compiling (e.g., to Android) to work as well.
list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../../..)
find_package(executorch CONFIG REQUIRED FIND_ROOT_PATH_BOTH)
executorch_target_link_options_shared_lib(executorch)
set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../lib/cmake/ExecuTorch)
find_package(executorch CONFIG REQUIRED)

# llama_runner library
add_subdirectory(runner)
Expand Down
5 changes: 2 additions & 3 deletions examples/models/llava/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ find_package(gflags REQUIRED)
#

# find `executorch` libraries Same as for gflags
list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../../..)
find_package(executorch CONFIG REQUIRED FIND_ROOT_PATH_BOTH)
executorch_target_link_options_shared_lib(executorch)
set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../lib/cmake/ExecuTorch)
find_package(executorch CONFIG REQUIRED)

# llava_runner library
add_subdirectory(runner)
Expand Down
1 change: 0 additions & 1 deletion examples/models/yolo12/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ set(_common_include_directories ${EXECUTORCH_ROOT}/..)

# find `executorch` libraries Same as for gflags
find_package(executorch CONFIG REQUIRED PATHS ${EXECUTORCH_ROOT}/cmake-out)
executorch_target_link_options_shared_lib(executorch)

add_subdirectory(${EXECUTORCH_ROOT}/third-party/gflags gflags)
set(link_libraries gflags)
Expand Down
4 changes: 3 additions & 1 deletion extension/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ set_target_properties(
"${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/libs/android.${ANDROID_ABI}/libfbjni.so"
)

executorch_target_link_options_shared_lib(executorch)

set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../lib/cmake/ExecuTorch)
find_package(executorch CONFIG REQUIRED)

add_library(
executorch_jni SHARED jni/jni_layer.cpp jni/log.cpp jni/jni_layer_runtime.cpp
Expand Down
71 changes: 69 additions & 2 deletions tools/cmake/executorch-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,19 @@ foreach(lib ${required_lib_list})
endif()
list(APPEND EXECUTORCH_LIBRARIES ${lib})
endforeach()

# If we reach here, ET required libraries are found.
target_link_libraries(executorch INTERFACE executorch_core)
target_link_options_shared_lib(prim_ops_lib)

set(EXECUTORCH_FOUND ON)

include("${CMAKE_CURRENT_LIST_DIR}/ExecuTorchTargets.cmake")
target_link_libraries(executorch INTERFACE executorch_core)

# ...existing code...

# Move target_link_options_shared_lib(prim_ops_lib) to line 177 (after all target_link_libraries for executorch)
target_link_options_shared_lib(prim_ops_lib)

set(optional_lib_list
flatccrt
Expand Down Expand Up @@ -88,7 +98,64 @@ set(optional_lib_list
torchao_kernels_aarch64
)

foreach(lib ${optional_lib_list})
# TODO: investigate use of install(EXPORT) to cleanly handle
# target_compile_options/target_compile_definitions for everything.
if(TARGET cpublas)
set_target_properties(
cpublas PROPERTIES INTERFACE_LINK_LIBRARIES
"extension_threadpool;eigen_blas"
)
endif()
if(TARGET optimized_kernels)
set_target_properties(
optimized_kernels PROPERTIES INTERFACE_LINK_LIBRARIES
"executorch_core;cpublas;extension_threadpool"
)
endif()

if(TARGET coremldelegate)
set_target_properties(
coremldelegate PROPERTIES INTERFACE_LINK_LIBRARIES
"coreml_inmemoryfs;coreml_util"
)
endif()

if(TARGET etdump)
set_target_properties(etdump PROPERTIES INTERFACE_LINK_LIBRARIES "flatccrt;executorch")
endif()

if(TARGET optimized_native_cpu_ops_lib)
if(TARGET optimized_portable_kernels)
set(_maybe_optimized_portable_kernels_lib optimized_portable_kernels)
else()
set(_maybe_optimized_portable_kernels_lib portable_kernels)
endif()
set_target_properties(
optimized_native_cpu_ops_lib
PROPERTIES INTERFACE_LINK_LIBRARIES
"optimized_kernels;${_maybe_optimized_portable_kernels_lib}"
)
endif()
if(TARGET extension_threadpool)
target_compile_definitions(extension_threadpool INTERFACE ET_USE_THREADPOOL)
set_target_properties(
extension_threadpool PROPERTIES INTERFACE_LINK_LIBRARIES
"cpuinfo;pthreadpool"
)
endif()

# target_link_options_shared_lib(prim_ops_lib) is now called automatically in executorch-config.cmake
target_link_options_shared_lib(prim_ops_lib)

set(shared_lib_list
# executorch -- size tests fail due to regression if we include this and I'm not sure it's needed.
optimized_native_cpu_ops_lib
portable_ops_lib
quantized_ops_lib
xnnpack_backend
vulkan_backend
quantized_ops_aot_lib)
foreach(lib ${shared_lib_list})
if(TARGET ${lib})
list(APPEND EXECUTORCH_LIBRARIES ${lib})
else()
Expand Down
Loading