Skip to content

Commit 09e2097

Browse files
committed
Used cmake-format on CMakeLists.txt
1 parent e84c319 commit 09e2097

File tree

1 file changed

+73
-40
lines changed

1 file changed

+73
-40
lines changed

CMakeLists.txt

Lines changed: 73 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
cmake_minimum_required(VERSION 3.24)
4646
project(executorch)
4747

48-
# MARK: - Start EXECUTORCH_H12025_BUILD_MIGRATION --------------------------------------------------
48+
# MARK: - Start EXECUTORCH_H12025_BUILD_MIGRATION
49+
# --------------------------------------------------
4950

5051
include(${PROJECT_SOURCE_DIR}/tools/cmake/common/preset.cmake)
5152
include(${PROJECT_SOURCE_DIR}/tools/cmake/Utils.cmake)
@@ -82,24 +83,25 @@ include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/default.cmake)
8283
# Print all the configs that were called with announce_configured_options.
8384
print_configured_options()
8485

85-
# MARK: - End EXECUTORCH_H12025_BUILD_MIGRATION ----------------------------------------------------
86+
# MARK: - End EXECUTORCH_H12025_BUILD_MIGRATION
87+
# ----------------------------------------------------
8688

8789
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
8890

89-
# Setup RPATH.
90-
# See https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
91+
# Setup RPATH. See
92+
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
9193
# Use separate rpaths during build and install phases
9294
set(CMAKE_SKIP_BUILD_RPATH OFF)
9395
# Don't use the install-rpath during the build phase
9496
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
9597
# Automatically add all linked folders that are NOT in the build directory to
96-
# the rpath (per library?)
97-
# TODO: Doesn't work for us right now because we are not installing .so's into the
98-
# correct locations. For example we have libcustom_ops_aot_lib.so depending on
99-
# _portable_lib.so, which was eventually put under <site-packages>/executorch/extension/pybindings/
100-
# but this rpath is not automatically added because at build time it seems `portable_lib`
101-
# is being built under the same directory, so no extra rpath is being added. To
102-
# properly fix this we need to install `portable_lib` into the correct path.
98+
# the rpath (per library?) TODO: Doesn't work for us right now because we are
99+
# not installing .so's into the correct locations. For example we have
100+
# libcustom_ops_aot_lib.so depending on _portable_lib.so, which was eventually
101+
# put under <site-packages>/executorch/extension/pybindings/ but this rpath is
102+
# not automatically added because at build time it seems `portable_lib` is being
103+
# built under the same directory, so no extra rpath is being added. To properly
104+
# fix this we need to install `portable_lib` into the correct path.
103105
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
104106
# ------------------------------ OPTIONS -------------------------------------
105107
# WARNING: Please don't add example specific options in this CMakeLists.txt.
@@ -177,7 +179,7 @@ endif()
177179

178180
if(NOT DEFINED FXDIV_SOURCE_DIR)
179181
set(ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG
180-
${CMAKE_POSITION_INDEPENDENT_CODE}
182+
${CMAKE_POSITION_INDEPENDENT_CODE}
181183
)
182184
set(FXDIV_SOURCE_DIR "backends/xnnpack/third-party/FXdiv")
183185
add_subdirectory("${FXDIV_SOURCE_DIR}")
@@ -276,7 +278,10 @@ if(NOT "${_repo_dir_name}" STREQUAL "executorch")
276278
"fix for this restriction."
277279
)
278280
endif()
279-
set(_common_include_directories ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/runtime/core/portable_type/c10)
281+
set(_common_include_directories
282+
${CMAKE_CURRENT_SOURCE_DIR}/..
283+
${CMAKE_CURRENT_SOURCE_DIR}/runtime/core/portable_type/c10
284+
)
280285

281286
#
282287
# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
@@ -310,9 +315,9 @@ endif()
310315
# Detect if an Android toolchain is set.
311316
if(CMAKE_TOOLCHAIN_FILE MATCHES ".*android\.toolchain\.cmake$")
312317
set(CMAKE_TOOLCHAIN_ANDROID ON)
313-
if(NOT ANDROID_PLATFORM)
314-
set(ANDROID_PLATFORM android-30)
315-
endif()
318+
if(NOT ANDROID_PLATFORM)
319+
set(ANDROID_PLATFORM android-30)
320+
endif()
316321
else()
317322
set(CMAKE_TOOLCHAIN_ANDROID OFF)
318323
endif()
@@ -334,7 +339,6 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
334339
endif()
335340
endif()
336341

337-
338342
#
339343
# program_schema: Generated .h files from schema/*.fbs inputs
340344
#
@@ -376,7 +380,9 @@ endif()
376380
target_include_directories(
377381
executorch_core PUBLIC ${_common_include_directories}
378382
)
379-
target_compile_definitions(executorch_core PUBLIC C10_USING_CUSTOM_GENERATED_MACROS)
383+
target_compile_definitions(
384+
executorch_core PUBLIC C10_USING_CUSTOM_GENERATED_MACROS
385+
)
380386
target_compile_options(executorch_core PUBLIC ${_common_compile_options})
381387
if(MAX_KERNEL_NUM)
382388
target_compile_definitions(
@@ -386,9 +392,7 @@ endif()
386392

387393
if(EXECUTORCH_BUILD_PYBIND AND APPLE)
388394
# shared version
389-
add_library(
390-
executorch_core_shared SHARED ${_executorch_core__srcs}
391-
)
395+
add_library(executorch_core_shared SHARED ${_executorch_core__srcs})
392396
target_link_libraries(executorch_core_shared PRIVATE program_schema)
393397
if(DL_LIBRARY_EXISTS)
394398
# For dladdr()
@@ -397,7 +401,9 @@ if(EXECUTORCH_BUILD_PYBIND AND APPLE)
397401
target_include_directories(
398402
executorch_core_shared PUBLIC ${_common_include_directories}
399403
)
400-
target_compile_definitions(executorch_core_shared PUBLIC C10_USING_CUSTOM_GENERATED_MACROS)
404+
target_compile_definitions(
405+
executorch_core_shared PUBLIC C10_USING_CUSTOM_GENERATED_MACROS
406+
)
401407
target_compile_options(
402408
executorch_core_shared PUBLIC ${_common_compile_options}
403409
)
@@ -430,9 +436,8 @@ target_link_options_shared_lib(executorch)
430436
# operators necessary for the models that will run.
431437
#
432438
if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
433-
# find pytorch lib here to make it available to all
434-
# sub-directories. Find it before including portable so that
435-
# optimized_portable_kernels can use it.
439+
# find pytorch lib here to make it available to all sub-directories. Find it
440+
# before including portable so that optimized_portable_kernels can use it.
436441
find_package_torch_headers()
437442
endif()
438443

@@ -458,19 +463,50 @@ endif()
458463

459464
# Install `executorch` library as well as `executorch-config.cmake` under
460465
# ${CMAKE_INSTALL_PREFIX}/
461-
install(DIRECTORY runtime/core/ DESTINATION include/executorch/runtime/core FILES_MATCHING PATTERN "*.h")
462-
install(DIRECTORY runtime/kernel/ DESTINATION include/executorch/runtime/kernel FILES_MATCHING PATTERN "*.h")
463-
install(DIRECTORY runtime/platform/ DESTINATION include/executorch/runtime/platform FILES_MATCHING PATTERN "*.h")
464-
install(DIRECTORY extension/kernel_util/ DESTINATION include/executorch/extension/kernel_util FILES_MATCHING PATTERN "*.h")
465-
install(DIRECTORY extension/tensor/ DESTINATION include/executorch/extension/tensor FILES_MATCHING PATTERN "*.h")
466-
install(DIRECTORY extension/threadpool/ DESTINATION include/executorch/extension/threadpool FILES_MATCHING PATTERN "*.h")
466+
install(
467+
DIRECTORY runtime/core/
468+
DESTINATION include/executorch/runtime/core
469+
FILES_MATCHING
470+
PATTERN "*.h"
471+
)
472+
install(
473+
DIRECTORY runtime/kernel/
474+
DESTINATION include/executorch/runtime/kernel
475+
FILES_MATCHING
476+
PATTERN "*.h"
477+
)
478+
install(
479+
DIRECTORY runtime/platform/
480+
DESTINATION include/executorch/runtime/platform
481+
FILES_MATCHING
482+
PATTERN "*.h"
483+
)
484+
install(
485+
DIRECTORY extension/kernel_util/
486+
DESTINATION include/executorch/extension/kernel_util
487+
FILES_MATCHING
488+
PATTERN "*.h"
489+
)
490+
install(
491+
DIRECTORY extension/tensor/
492+
DESTINATION include/executorch/extension/tensor
493+
FILES_MATCHING
494+
PATTERN "*.h"
495+
)
496+
install(
497+
DIRECTORY extension/threadpool/
498+
DESTINATION include/executorch/extension/threadpool
499+
FILES_MATCHING
500+
PATTERN "*.h"
501+
)
467502
install(
468503
TARGETS executorch executorch_core
469-
DESTINATION lib
470504
INCLUDES
471505
DESTINATION ${_common_include_directories}
472506
)
473-
install(FILES tools/cmake/executorch-config.cmake DESTINATION lib/cmake/ExecuTorch)
507+
install(FILES tools/cmake/executorch-config.cmake
508+
DESTINATION lib/cmake/ExecuTorch
509+
)
474510

475511
if(EXECUTORCH_BUILD_ARM_BAREMETAL)
476512
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
@@ -608,17 +644,14 @@ if(EXECUTORCH_BUILD_PYBIND)
608644
endif()
609645

610646
if(EXECUTORCH_BUILD_XNNPACK)
611-
# need to explicitly specify XNNPACK and microkernels-prod
612-
# here otherwise uses XNNPACK and microkernel-prod symbols from libtorch_cpu
647+
# need to explicitly specify XNNPACK and microkernels-prod here otherwise
648+
# uses XNNPACK and microkernel-prod symbols from libtorch_cpu
613649
list(APPEND _dep_libs xnnpack_backend XNNPACK microkernels-prod)
614650
endif()
615651

616652
# compile options for pybind
617-
set(_pybind_compile_options
618-
-Wno-deprecated-declarations
619-
-fPIC
620-
-frtti
621-
-fexceptions
653+
set(_pybind_compile_options -Wno-deprecated-declarations -fPIC -frtti
654+
-fexceptions
622655
)
623656

624657
# util lib

0 commit comments

Comments
 (0)