39
39
# ~~~
40
40
# cmake-format -i CMakeLists.txt
41
41
# ~~~
42
- # It should also be cmake-lint clean.
42
+ # It should also be checked with a linter via
43
+ # ~~~
44
+ # cmake-lint CMakeLists.txt
45
+ # ~~~
43
46
#
44
47
45
48
cmake_minimum_required (VERSION 3.24 )
46
49
project (executorch )
47
50
48
- # MARK: - Start EXECUTORCH_H12025_BUILD_MIGRATION --------------------------------------------------
51
+ # MARK: - Start EXECUTORCH_H12025_BUILD_MIGRATION
49
52
50
53
include (${PROJECT_SOURCE_DIR} /tools/cmake/common/preset.cmake )
51
54
include (${PROJECT_SOURCE_DIR} /tools/cmake/Utils.cmake )
@@ -82,24 +85,25 @@ include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/default.cmake)
82
85
# Print all the configs that were called with announce_configured_options.
83
86
print_configured_options ()
84
87
85
- # MARK: - End EXECUTORCH_H12025_BUILD_MIGRATION ----------------------------------------------------
88
+ # MARK: - End EXECUTORCH_H12025_BUILD_MIGRATION
86
89
87
90
set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
88
91
89
- # Setup RPATH.
90
- # See https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
92
+ # Setup RPATH. See
93
+ # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
91
94
# Use separate rpaths during build and install phases
92
95
set (CMAKE_SKIP_BUILD_RPATH OFF )
93
96
# Don't use the install-rpath during the build phase
94
97
set (CMAKE_BUILD_WITH_INSTALL_RPATH ON )
95
98
# Automatically add all linked folders that are NOT in the build directory to
96
99
# 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.
100
+ # TODO: Doesn't work for us right now because we are
101
+ # not installing .so's into the correct locations. For example we have
102
+ # libcustom_ops_aot_lib.so depending on _portable_lib.so, which was eventually
103
+ # put under <site-packages>/executorch/extension/pybindings/ but this rpath is
104
+ # not automatically added because at build time it seems `portable_lib` is being
105
+ # built under the same directory, so no extra rpath is being added. To properly
106
+ # fix this we need to install `portable_lib` into the correct path.
103
107
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH ON )
104
108
# ------------------------------ OPTIONS -------------------------------------
105
109
# WARNING: Please don't add example specific options in this CMakeLists.txt.
@@ -177,7 +181,7 @@ endif()
177
181
178
182
if (NOT DEFINED FXDIV_SOURCE_DIR )
179
183
set (ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG
180
- ${CMAKE_POSITION_INDEPENDENT_CODE}
184
+ ${CMAKE_POSITION_INDEPENDENT_CODE}
181
185
)
182
186
set (FXDIV_SOURCE_DIR "backends/xnnpack/third-party/FXdiv" )
183
187
add_subdirectory ("${FXDIV_SOURCE_DIR} " )
@@ -276,7 +280,10 @@ if(NOT "${_repo_dir_name}" STREQUAL "executorch")
276
280
"fix for this restriction."
277
281
)
278
282
endif ()
279
- set (_common_include_directories ${CMAKE_CURRENT_SOURCE_DIR} /.. ${CMAKE_CURRENT_SOURCE_DIR} /runtime/core/portable_type/c10 )
283
+ set (_common_include_directories
284
+ ${CMAKE_CURRENT_SOURCE_DIR} /..
285
+ ${CMAKE_CURRENT_SOURCE_DIR} /runtime/core/portable_type/c10
286
+ )
280
287
281
288
#
282
289
# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
@@ -310,9 +317,9 @@ endif()
310
317
# Detect if an Android toolchain is set.
311
318
if (CMAKE_TOOLCHAIN_FILE MATCHES ".*android\. toolchain\. cmake$" )
312
319
set (CMAKE_TOOLCHAIN_ANDROID ON )
313
- if (NOT ANDROID_PLATFORM )
314
- set (ANDROID_PLATFORM android-30 )
315
- endif ()
320
+ if (NOT ANDROID_PLATFORM )
321
+ set (ANDROID_PLATFORM android-30 )
322
+ endif ()
316
323
else ()
317
324
set (CMAKE_TOOLCHAIN_ANDROID OFF )
318
325
endif ()
@@ -334,7 +341,6 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
334
341
endif ()
335
342
endif ()
336
343
337
-
338
344
#
339
345
# program_schema: Generated .h files from schema/*.fbs inputs
340
346
#
@@ -376,7 +382,9 @@ endif()
376
382
target_include_directories (
377
383
executorch_core PUBLIC ${_common_include_directories}
378
384
)
379
- target_compile_definitions (executorch_core PUBLIC C10_USING_CUSTOM_GENERATED_MACROS )
385
+ target_compile_definitions (
386
+ executorch_core PUBLIC C10_USING_CUSTOM_GENERATED_MACROS
387
+ )
380
388
target_compile_options (executorch_core PUBLIC ${_common_compile_options} )
381
389
if (MAX_KERNEL_NUM )
382
390
target_compile_definitions (
@@ -386,9 +394,7 @@ endif()
386
394
387
395
if (EXECUTORCH_BUILD_PYBIND AND APPLE )
388
396
# shared version
389
- add_library (
390
- executorch_core_shared SHARED ${_executorch_core__srcs}
391
- )
397
+ add_library (executorch_core_shared SHARED ${_executorch_core__srcs} )
392
398
target_link_libraries (executorch_core_shared PRIVATE program_schema )
393
399
if (DL_LIBRARY_EXISTS )
394
400
# For dladdr()
@@ -397,7 +403,9 @@ if(EXECUTORCH_BUILD_PYBIND AND APPLE)
397
403
target_include_directories (
398
404
executorch_core_shared PUBLIC ${_common_include_directories}
399
405
)
400
- target_compile_definitions (executorch_core_shared PUBLIC C10_USING_CUSTOM_GENERATED_MACROS )
406
+ target_compile_definitions (
407
+ executorch_core_shared PUBLIC C10_USING_CUSTOM_GENERATED_MACROS
408
+ )
401
409
target_compile_options (
402
410
executorch_core_shared PUBLIC ${_common_compile_options}
403
411
)
@@ -430,9 +438,8 @@ target_link_options_shared_lib(executorch)
430
438
# operators necessary for the models that will run.
431
439
#
432
440
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.
441
+ # find pytorch lib here to make it available to all sub-directories. Find it
442
+ # before including portable so that optimized_portable_kernels can use it.
436
443
find_package_torch_headers ()
437
444
endif ()
438
445
@@ -458,19 +465,50 @@ endif()
458
465
459
466
# Install `executorch` library as well as `executorch-config.cmake` under
460
467
# ${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" )
468
+ install (
469
+ DIRECTORY runtime/core/
470
+ DESTINATION include /executorch/runtime/core
471
+ FILES_MATCHING
472
+ PATTERN "*.h"
473
+ )
474
+ install (
475
+ DIRECTORY runtime/kernel/
476
+ DESTINATION include /executorch/runtime/kernel
477
+ FILES_MATCHING
478
+ PATTERN "*.h"
479
+ )
480
+ install (
481
+ DIRECTORY runtime/platform/
482
+ DESTINATION include /executorch/runtime/platform
483
+ FILES_MATCHING
484
+ PATTERN "*.h"
485
+ )
486
+ install (
487
+ DIRECTORY extension/kernel_util/
488
+ DESTINATION include /executorch/extension/kernel_util
489
+ FILES_MATCHING
490
+ PATTERN "*.h"
491
+ )
492
+ install (
493
+ DIRECTORY extension/tensor/
494
+ DESTINATION include /executorch/extension/tensor
495
+ FILES_MATCHING
496
+ PATTERN "*.h"
497
+ )
498
+ install (
499
+ DIRECTORY extension/threadpool/
500
+ DESTINATION include /executorch/extension/threadpool
501
+ FILES_MATCHING
502
+ PATTERN "*.h"
503
+ )
467
504
install (
468
505
TARGETS executorch executorch_core
469
- DESTINATION lib
470
506
INCLUDES
471
507
DESTINATION ${_common_include_directories}
472
508
)
473
- install (FILES tools/cmake/executorch-config.cmake DESTINATION lib/cmake/ExecuTorch )
509
+ install (FILES tools/cmake/executorch-config.cmake
510
+ DESTINATION lib/cmake/ExecuTorch
511
+ )
474
512
475
513
if (EXECUTORCH_BUILD_ARM_BAREMETAL )
476
514
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/arm )
@@ -608,17 +646,14 @@ if(EXECUTORCH_BUILD_PYBIND)
608
646
endif ()
609
647
610
648
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
649
+ # need to explicitly specify XNNPACK and microkernels-prod here otherwise
650
+ # uses XNNPACK and microkernel-prod symbols from libtorch_cpu
613
651
list (APPEND _dep_libs xnnpack_backend XNNPACK microkernels-prod )
614
652
endif ()
615
653
616
654
# compile options for pybind
617
- set (_pybind_compile_options
618
- -Wno-deprecated-declarations
619
- -fPIC
620
- -frtti
621
- -fexceptions
655
+ set (_pybind_compile_options -Wno-deprecated-declarations -fPIC -frtti
656
+ -fexceptions
622
657
)
623
658
624
659
# util lib
0 commit comments