45
45
cmake_minimum_required (VERSION 3.24 )
46
46
project (executorch )
47
47
48
- # MARK: - Start EXECUTORCH_H12025_BUILD_MIGRATION --------------------------------------------------
48
+ # MARK: - Start EXECUTORCH_H12025_BUILD_MIGRATION
49
+ # --------------------------------------------------
49
50
50
51
include (${PROJECT_SOURCE_DIR} /tools/cmake/common/preset.cmake )
51
52
include (${PROJECT_SOURCE_DIR} /tools/cmake/Utils.cmake )
@@ -82,24 +83,25 @@ include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/default.cmake)
82
83
# Print all the configs that were called with announce_configured_options.
83
84
print_configured_options ()
84
85
85
- # MARK: - End EXECUTORCH_H12025_BUILD_MIGRATION ----------------------------------------------------
86
+ # MARK: - End EXECUTORCH_H12025_BUILD_MIGRATION
87
+ # ----------------------------------------------------
86
88
87
89
set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
88
90
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
91
93
# Use separate rpaths during build and install phases
92
94
set (CMAKE_SKIP_BUILD_RPATH OFF )
93
95
# Don't use the install-rpath during the build phase
94
96
set (CMAKE_BUILD_WITH_INSTALL_RPATH ON )
95
97
# 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.
103
105
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH ON )
104
106
# ------------------------------ OPTIONS -------------------------------------
105
107
# WARNING: Please don't add example specific options in this CMakeLists.txt.
@@ -177,7 +179,7 @@ endif()
177
179
178
180
if (NOT DEFINED FXDIV_SOURCE_DIR )
179
181
set (ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG
180
- ${CMAKE_POSITION_INDEPENDENT_CODE}
182
+ ${CMAKE_POSITION_INDEPENDENT_CODE}
181
183
)
182
184
set (FXDIV_SOURCE_DIR "backends/xnnpack/third-party/FXdiv" )
183
185
add_subdirectory ("${FXDIV_SOURCE_DIR} " )
@@ -276,7 +278,10 @@ if(NOT "${_repo_dir_name}" STREQUAL "executorch")
276
278
"fix for this restriction."
277
279
)
278
280
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
+ )
280
285
281
286
#
282
287
# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
@@ -310,9 +315,9 @@ endif()
310
315
# Detect if an Android toolchain is set.
311
316
if (CMAKE_TOOLCHAIN_FILE MATCHES ".*android\. toolchain\. cmake$" )
312
317
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 ()
316
321
else ()
317
322
set (CMAKE_TOOLCHAIN_ANDROID OFF )
318
323
endif ()
@@ -334,7 +339,6 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
334
339
endif ()
335
340
endif ()
336
341
337
-
338
342
#
339
343
# program_schema: Generated .h files from schema/*.fbs inputs
340
344
#
@@ -376,7 +380,9 @@ endif()
376
380
target_include_directories (
377
381
executorch_core PUBLIC ${_common_include_directories}
378
382
)
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
+ )
380
386
target_compile_options (executorch_core PUBLIC ${_common_compile_options} )
381
387
if (MAX_KERNEL_NUM )
382
388
target_compile_definitions (
@@ -386,9 +392,7 @@ endif()
386
392
387
393
if (EXECUTORCH_BUILD_PYBIND AND APPLE )
388
394
# shared version
389
- add_library (
390
- executorch_core_shared SHARED ${_executorch_core__srcs}
391
- )
395
+ add_library (executorch_core_shared SHARED ${_executorch_core__srcs} )
392
396
target_link_libraries (executorch_core_shared PRIVATE program_schema )
393
397
if (DL_LIBRARY_EXISTS )
394
398
# For dladdr()
@@ -397,7 +401,9 @@ if(EXECUTORCH_BUILD_PYBIND AND APPLE)
397
401
target_include_directories (
398
402
executorch_core_shared PUBLIC ${_common_include_directories}
399
403
)
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
+ )
401
407
target_compile_options (
402
408
executorch_core_shared PUBLIC ${_common_compile_options}
403
409
)
@@ -430,9 +436,8 @@ target_link_options_shared_lib(executorch)
430
436
# operators necessary for the models that will run.
431
437
#
432
438
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.
436
441
find_package_torch_headers ()
437
442
endif ()
438
443
@@ -458,19 +463,50 @@ endif()
458
463
459
464
# Install `executorch` library as well as `executorch-config.cmake` under
460
465
# ${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
+ )
467
502
install (
468
503
TARGETS executorch executorch_core
469
- DESTINATION lib
470
504
INCLUDES
471
505
DESTINATION ${_common_include_directories}
472
506
)
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
+ )
474
510
475
511
if (EXECUTORCH_BUILD_ARM_BAREMETAL )
476
512
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/arm )
@@ -608,17 +644,14 @@ if(EXECUTORCH_BUILD_PYBIND)
608
644
endif ()
609
645
610
646
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
613
649
list (APPEND _dep_libs xnnpack_backend XNNPACK microkernels-prod )
614
650
endif ()
615
651
616
652
# 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
622
655
)
623
656
624
657
# util lib
0 commit comments