1-
21# Copyright (c) Meta Platforms, Inc. and affiliates.
32# All rights reserved.
43#
1615#
1716# This will define the following variables:
1817#
19- # EXECUTORCH_FOUND -- True if the system has the ExecuTorch library
20- # EXECUTORCH_INCLUDE_DIRS -- The include directories for ExecuTorch
21- # EXECUTORCH_LIBRARIES -- Libraries to link against
18+ # EXECUTORCH_FOUND -- True if the system has the ExecuTorch library
19+ # EXECUTORCH_INCLUDE_DIRS -- The include directories for ExecuTorch
20+ # EXECUTORCH_LIBRARIES -- Libraries to link against
2221#
23- # The actual values for these variables will be different from what executorch-config.cmake
24- # in executorch pip package gives, but we wanted to keep the contract of exposing these
25- # CMake variables.
22+ # The actual values for these variables will be different from what
23+ # executorch-config.cmake in executorch pip package gives, but we wanted to keep
24+ # the contract of exposing these CMake variables.
2625
2726cmake_minimum_required (VERSION 3.19)
2827
2928set (_root "${CMAKE_CURRENT_LIST_DIR} /../../.." )
3029set (required_lib_list executorch executorch_core portable_kernels)
3130set (EXECUTORCH_LIBRARIES)
32- set (EXECUTORCH_INCLUDE_DIRS ${_root} /include ${_root} /include /executorch/runtime/core/portable_type/c10 ${_root} /lib)
31+ set (EXECUTORCH_INCLUDE_DIRS
32+ ${_root} /include ${_root} /include /executorch/runtime/core/portable_type/c10
33+ ${_root} /lib
34+ )
3335foreach (lib ${required_lib_list} )
3436 set (lib_var "LIB_${lib} " )
3537 add_library (${lib} STATIC IMPORTED )
@@ -40,7 +42,12 @@ foreach(lib ${required_lib_list})
4042 )
4143 set_target_properties (${lib} PROPERTIES IMPORTED_LOCATION "${${lib_var} }" )
4244 target_compile_definitions (${lib} INTERFACE C10_USING_CUSTOM_GENERATED_MACROS)
43- target_include_directories (${lib} INTERFACE ${_root} /include ${_root} /include /executorch/runtime/core/portable_type/c10 ${_root} /lib)
45+ target_include_directories (
46+ ${lib}
47+ INTERFACE ${_root} /include
48+ ${_root} /include /executorch/runtime/core/portable_type/c10
49+ ${_root} /lib
50+ )
4451 list (APPEND EXECUTORCH_LIBRARIES ${lib} )
4552endforeach ()
4653
@@ -82,6 +89,7 @@ set(lib_list
8289 pthreadpool
8390 vulkan_backend
8491 optimized_kernels
92+ optimized_portable_kernels
8593 cpublas
8694 eigen_blas
8795 optimized_ops_lib
@@ -111,7 +119,12 @@ foreach(lib ${lib_list})
111119 add_library (${lib} STATIC IMPORTED )
112120 endif ()
113121 set_target_properties (${lib} PROPERTIES IMPORTED_LOCATION "${${lib_var} }" )
114- target_include_directories (${lib} INTERFACE ${_root} /include ${_root} /include /executorch/runtime/core/portable_type/c10 ${_root} /lib)
122+ target_include_directories (
123+ ${lib}
124+ INTERFACE ${_root} /include
125+ ${_root} /include /executorch/runtime/core/portable_type/c10
126+ ${_root} /lib
127+ )
115128 list (APPEND EXECUTORCH_LIBRARIES ${lib} )
116129 endif ()
117130endforeach ()
@@ -120,7 +133,28 @@ endforeach()
120133# target_compile_options/target_compile_definitions for everything.
121134if (TARGET cpublas)
122135 set_target_properties (
123- cpublas PROPERTIES INTERFACE_LINK_LIBRARIES extension_threadpool
136+ cpublas PROPERTIES INTERFACE_LINK_LIBRARIES
137+ "extension_threadpool;eigen_blas"
138+ )
139+ endif ()
140+ if (TARGET optimized_kernels)
141+ set_target_properties (
142+ optimized_kernels PROPERTIES INTERFACE_LINK_LIBRARIES
143+ "executorch_core;cpublas;extension_threadpool"
124144 )
125145endif ()
126- target_compile_definitions (extension_threadpool INTERFACE ET_USE_THREADPOOL)
146+ if (TARGET optimized_native_cpu_ops_lib)
147+ if (TARGET optimized_portable_kernels)
148+ set (_maybe_optimized_portable_kernels_lib optimized_portable_kernels)
149+ else ()
150+ set (_maybe_optimized_portable_kernels_lib portable_kernels)
151+ endif ()
152+ set_target_properties (
153+ optimized_native_cpu_ops_lib
154+ PROPERTIES INTERFACE_LINK_LIBRARIES
155+ "optimized_kernels;${_maybe_optimized_portable_kernels_lib} "
156+ )
157+ endif ()
158+ if (TARGET extension_threadpool)
159+ target_compile_definitions (extension_threadpool INTERFACE ET_USE_THREADPOOL)
160+ endif ()
0 commit comments