Skip to content

Commit cb75826

Browse files
committed
Add top-level CMake extensions target
ghstack-source-id: cfc4db1 ghstack-comment-id: 3099981300 Pull-Request: #12696
1 parent 3b31b31 commit cb75826

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

CMakeLists.txt

Lines changed: 25 additions & 3 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,10 +639,17 @@ if(EXECUTORCH_BUILD_EXTENSION_LLM)
632639
${ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG}
633640
)
634641
endif()
642+
list(APPEND _executorch_extensions tokenizers)
643+
endif()
644+
645+
if(EXECUTORCH_BUILD_EXTENSION_LLM_APPLE)
646+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/apple)
647+
list(APPEND _executorch_extensions extension_llm_apple)
635648
endif()
636649

637650
if(EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER)
638651
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/runner)
652+
list(APPEND _executorch_extensions extension_llm_runner)
639653
endif()
640654

641655
if(EXECUTORCH_BUILD_EXTENSION_LLM_APPLE)
@@ -650,10 +664,12 @@ if(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL)
650664
FILES_MATCHING
651665
PATTERN "*.h"
652666
)
667+
list(APPEND _executorch_extensions extension_runner_util)
653668
endif()
654669

655670
if(EXECUTORCH_BUILD_EXTENSION_TENSOR)
656671
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/tensor)
672+
list(APPEND _executorch_extensions extension_tensor)
657673
endif()
658674

659675
if(EXECUTORCH_BUILD_PTHREADPOOL AND EXECUTORCH_BUILD_CPUINFO)
@@ -756,6 +772,7 @@ endif()
756772

757773
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
758774
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/training)
775+
list(APPEND _executorch_extensions extension_training)
759776
endif()
760777

761778
if(EXECUTORCH_BUILD_KERNELS_LLM)
@@ -781,14 +798,19 @@ endif()
781798

782799

783800
# Top-level interface targets.
784-
add_library(executorch_backends INTERFACE)
785-
add_library(executorch::backends ALIAS executorch_backends)
786801

787802
# A target containing all configured backends.
803+
add_library(executorch_backends INTERFACE)
804+
add_library(executorch::backends ALIAS executorch_backends)
788805
target_link_libraries(executorch_backends INTERFACE ${_executorch_backends})
789806

807+
# A target containing all configured extensions.
808+
add_library(executorch_extensions INTERFACE)
809+
add_library(executorch::extensions ALIAS executorch_extensions)
810+
target_link_libraries(executorch_extensions INTERFACE ${_executorch_extensions})
811+
790812
install(
791-
TARGETS executorch_backends
813+
TARGETS executorch_backends executorch_extensions
792814
INCLUDES
793815
DESTINATION ${_common_include_directories}
794816
)

0 commit comments

Comments
 (0)