Skip to content

Commit ce9da63

Browse files
authored
Add top-level CMake extensions target (#12696)
Add a top level extensions CMake target, which includes all configured extensions. I validate this change by building a simple runner using the executorch_extensions target and verifying that it was able to build and run using the module and tensor extension. Once the changes land in ExecuTorch, this will be long-term validated in executorch-examples CI. This is done in the context of top-level CMake targets, tracked in #12293.
1 parent f7e72ee commit ce9da63

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

CMakeLists.txt

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,9 @@ add_library(executorch_no_prim_ops ALIAS executorch_core)
383383
# A list of all configured backends.
384384
set(_executorch_backends "")
385385

386+
# A list of all configured extensions.
387+
set(_executorch_extensions "")
388+
386389
target_link_libraries(executorch_core PRIVATE program_schema)
387390
if(ANDROID)
388391
target_link_libraries(executorch_core PUBLIC log)
@@ -579,6 +582,7 @@ endif()
579582

580583
if(EXECUTORCH_BUILD_EXTENSION_APPLE)
581584
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/apple)
585+
list(APPEND _executorch_extensions apple_extension)
582586
endif()
583587

584588
if(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER)
@@ -589,6 +593,7 @@ if(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER)
589593
FILES_MATCHING
590594
PATTERN "*.h"
591595
)
596+
list(APPEND _executorch_extensions extension_data_loader)
592597
endif()
593598

594599
if(EXECUTORCH_BUILD_EXTENSION_EVALUE_UTIL)
@@ -603,6 +608,7 @@ endif()
603608

604609
if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
605610
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/flat_tensor)
611+
list(APPEND _executorch_extensions extension_flat_tensor)
606612
endif()
607613

608614
if(EXECUTORCH_BUILD_EXTENSION_MODULE)
@@ -613,6 +619,7 @@ if(EXECUTORCH_BUILD_EXTENSION_MODULE)
613619
FILES_MATCHING
614620
PATTERN "*.h"
615621
)
622+
list(APPEND _executorch_extensions extension_module_static)
616623
endif()
617624

618625
if(EXECUTORCH_BUILD_EXTENSION_LLM)
@@ -632,14 +639,17 @@ if(EXECUTORCH_BUILD_EXTENSION_LLM)
632639
${ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG}
633640
)
634641
endif()
642+
list(APPEND _executorch_extensions tokenizers)
635643
endif()
636644

637645
if(EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER)
638646
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/runner)
647+
list(APPEND _executorch_extensions extension_llm_runner)
639648
endif()
640649

641650
if(EXECUTORCH_BUILD_EXTENSION_LLM_APPLE)
642651
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/apple)
652+
list(APPEND _executorch_extensions extension_llm_apple)
643653
endif()
644654

645655
if(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL)
@@ -650,10 +660,12 @@ if(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL)
650660
FILES_MATCHING
651661
PATTERN "*.h"
652662
)
663+
list(APPEND _executorch_extensions extension_runner_util)
653664
endif()
654665

655666
if(EXECUTORCH_BUILD_EXTENSION_TENSOR)
656667
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/tensor)
668+
list(APPEND _executorch_extensions extension_tensor)
657669
endif()
658670

659671
if(EXECUTORCH_BUILD_PTHREADPOOL AND EXECUTORCH_BUILD_CPUINFO)
@@ -756,6 +768,7 @@ endif()
756768

757769
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
758770
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/training)
771+
list(APPEND _executorch_extensions extension_training)
759772
endif()
760773

761774
if(EXECUTORCH_BUILD_KERNELS_LLM)
@@ -778,25 +791,22 @@ if(EXECUTORCH_BUILD_VGF)
778791
list(APPEND _executorch_backends vgf_backend)
779792
endif()
780793

781-
782794
# Top-level interface targets.
783-
add_library(executorch_backends INTERFACE)
784-
add_library(executorch::backends ALIAS executorch_backends)
785795

786796
# A target containing all configured backends.
797+
add_library(executorch_backends INTERFACE)
798+
add_library(executorch::backends ALIAS executorch_backends)
787799
target_link_libraries(executorch_backends INTERFACE ${_executorch_backends})
788800

789-
install(
790-
TARGETS executorch_backends
791-
INCLUDES
792-
DESTINATION ${_common_include_directories}
793-
)
801+
# A target containing all configured extensions.
802+
add_library(executorch_extensions INTERFACE)
803+
add_library(executorch::extensions ALIAS executorch_extensions)
804+
target_link_libraries(executorch_extensions INTERFACE ${_executorch_extensions})
794805

795806
if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
796807
# Baseline libraries that executor_runner will link against.
797808
set(_executor_runner_libs executorch extension_evalue_util
798-
extension_runner_util gflags
799-
executorch_backends
809+
extension_runner_util gflags executorch_backends
800810
)
801811

802812
if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)

0 commit comments

Comments
 (0)