1# Copyright (c) Meta Platforms, Inc. and affiliates. 2# All rights reserved. 3# 4# This source code is licensed under the BSD-style license found in the 5# LICENSE file in the root directory of this source tree. 6 7# Please this file formatted by running: 8# ~~~ 9# cmake-format -i CMakeLists.txt 10# ~~~ 11 12cmake_minimum_required(VERSION 3.19) 13 14# Source root directory for executorch. 15if(NOT EXECUTORCH_ROOT) 16 set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) 17endif() 18 19list(TRANSFORM _extension_module__srcs PREPEND "${EXECUTORCH_ROOT}/") 20if(CMAKE_TOOLCHAIN_IOS 21 OR CMAKE_TOOLCHAIN_ANDROID 22 OR APPLE 23) 24 # Building a share library on iOS requires code signing On Android we see 25 # duplicated registration when using shared lib 26 add_library(extension_module STATIC ${_extension_module__srcs}) 27else() 28 add_library(extension_module SHARED ${_extension_module__srcs}) 29endif() 30target_link_libraries(extension_module PRIVATE executorch extension_data_loader) 31target_include_directories(extension_module PUBLIC ${EXECUTORCH_ROOT}/..) 32target_compile_options( 33 extension_module PUBLIC -Wno-deprecated-declarations -fPIC 34) 35 36# Module extension built as a static library. TODO(gjcomer) Remove this target 37# after cleaning up CMake targets. 38add_library(extension_module_static STATIC ${_extension_module__srcs}) 39target_link_libraries( 40 extension_module_static PRIVATE executorch extension_data_loader 41) 42target_include_directories(extension_module_static PUBLIC ${EXECUTORCH_ROOT}/..) 43target_compile_options( 44 extension_module_static PUBLIC -Wno-deprecated-declarations -fPIC 45) 46 47# Install libraries 48install( 49 TARGETS extension_module extension_module_static 50 DESTINATION lib 51 INCLUDES 52 DESTINATION ${_common_include_directories} 53) 54