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# 8# Simple CMake build system for size_test demo. 9# 10# ### Editing this file ### 11# 12# This file should be formatted with 13# ~~~ 14# cmake-format -i CMakeLists.txt 15# ~~~ 16# It should also be cmake-lint clean. 17# 18 19cmake_minimum_required(VERSION 3.19) 20project(size_test) 21 22set(CMAKE_CXX_STANDARD 17) 23 24set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..) 25 26include(${EXECUTORCH_ROOT}/build/Utils.cmake) 27 28# Find prebuilt executorch library 29find_package(executorch CONFIG REQUIRED) 30 31# Let files say "include <executorch/path/to/header.h>". 32set(_common_include_directories ${EXECUTORCH_ROOT}/..) 33target_include_directories(executorch INTERFACE ${_common_include_directories}) 34 35# 36# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}. 37# 38set(EXECUTORCH_SRCS_FILE "${CMAKE_CURRENT_BINARY_DIR}/../executorch_srcs.cmake") 39 40extract_sources(${EXECUTORCH_SRCS_FILE}) 41 42include(${EXECUTORCH_SRCS_FILE}) 43 44# Since extract_sources.py is not returning absolute values, we need to patch 45# the source paths. 46list(TRANSFORM _size_test__srcs PREPEND "${EXECUTORCH_ROOT}/") 47 48# 49# size_test: minimal binary with no ops and no delegate backend 50# 51# TODO(larryliu0820): Add EXECUTORCH_BUILD_EXECUTABLES to not build executable 52# when we cross compile to ios 53add_executable(size_test ${_size_test__srcs}) 54target_link_libraries(size_test executorch) 55if(CMAKE_BUILD_TYPE EQUAL "Release") 56 target_link_options(size_test PRIVATE "LINKER:--gc-sections") 57endif() 58 59# 60# size_test_all_ops: binary with portable ops and no delegate backend 61# 62add_executable(size_test_all_ops ${_size_test__srcs}) 63target_link_options_shared_lib(portable_ops_lib) 64target_link_libraries( 65 size_test_all_ops executorch portable_ops_lib portable_kernels 66) 67if(CMAKE_BUILD_TYPE EQUAL "Release") 68 target_link_options(size_test_all_ops PRIVATE "LINKER:--gc-sections") 69endif() 70 71# Print all summary 72executorch_print_configuration_summary() 73