Skip to content

Commit aa82b7d

Browse files
shoumikhinfacebook-github-bot
authored andcommitted
Add extension/data_loader targets to cmake build. (#521)
Summary: Pull Request resolved: #521 We need to be able to build a separate lib for data loaders. Reviewed By: cccclai Differential Revision: D49742389 fbshipit-source-id: 884e28244aa8c484e0b184c11643d578ee689b62
1 parent 7b945cc commit aa82b7d

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ option(REGISTER_QUANTIZED_OPS
9292
option(BUILD_SELECTIVE_BUILD_TEST
9393
"Whether to build binary for demo selective build" OFF)
9494

95-
option(EXECUTORCH_BUILD_SIZE_TEST
96-
"Whether to build size test" OFF)
95+
option(EXECUTORCH_BUILD_SIZE_TEST "Whether to build size test" OFF)
9796

9897
if(BUILD_SELECTIVE_BUILD_TEST)
9998
option(SELECT_ALL_OPS
@@ -290,7 +289,13 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
290289
target_compile_options(executor_runner PUBLIC ${_common_compile_options})
291290
endif()
292291

293-
# Add XNNPACK subdirectory
292+
option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
293+
"Build the extension/data_loader directory" OFF)
294+
if(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER)
295+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/data_loader)
296+
endif()
297+
298+
option(EXECUTORCH_BUILD_XNNPACK "Build the backends/xnnpack directory" OFF)
294299
if(EXECUTORCH_BUILD_XNNPACK)
295300
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/xnnpack)
296301
endif()

build/Utils.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ function(executorch_print_configuration_summary)
4040
)
4141
message(
4242
STATUS " REGISTER_EXAMPLE_CUSTOM_OPS : ${REGISTER_EXAMPLE_CUSTOM_OPS}")
43+
message(
44+
STATUS
45+
" EXECUTORCH_BUILD_EXTENSION_DATA_LOADER : ${EXECUTORCH_BUILD_EXTENSION_DATA_LOADER}"
46+
)
47+
message(STATUS " EXECUTORCH_BUILD_XNNPACK : ${EXECUTORCH_BUILD_XNNPACK}")
4348
endfunction()
4449

4550
# This is the funtion to use -Wl, --whole-archive to link static library NB:

build/cmake_deps.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,17 @@ deps = [
118118
"xnnpack_backend",
119119
"portable_kernels",
120120
]
121+
122+
[targets.extension_data_loader]
123+
buck_targets = [
124+
"//extension/data_loader:buffer_data_loader",
125+
"//extension/data_loader:file_data_loader",
126+
"//extension/data_loader:mmap_data_loader",
127+
"//extension/data_loader:shared_ptr_data_loader",
128+
]
129+
filters = [
130+
".cpp$",
131+
]
132+
deps = [
133+
"executorch",
134+
]

extension/data_loader/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 --first-comment-is-literal=True CMakeLists.txt
10+
# ~~~
11+
12+
cmake_minimum_required(VERSION 3.19)
13+
14+
# Source root directory for executorch.
15+
if(NOT EXECUTORCH_ROOT)
16+
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
17+
endif()
18+
19+
list(TRANSFORM _extension_data_loader__srcs PREPEND "${EXECUTORCH_ROOT}/")
20+
add_library(extension_data_loader ${_extension_data_loader__srcs})
21+
target_include_directories(extension_data_loader PUBLIC ${EXECUTORCH_ROOT}/..)

0 commit comments

Comments
 (0)