Skip to content

Format CMakeLists.txt files about to be changed in EXPORT PR #12463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ set(CMAKE_SKIP_BUILD_RPATH OFF)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
# Automatically add all linked folders that are NOT in the build directory to
# the rpath (per library?)
# TODO: Doesn't work for us right now because we are
# not installing .so's into the correct locations. For example we have
# libcustom_ops_aot_lib.so depending on _portable_lib.so, which was eventually
# put under <site-packages>/executorch/extension/pybindings/ but this rpath is
# not automatically added because at build time it seems `portable_lib` is being
#
# TODO: Doesn't work for us right now because we are not installing .so's into
# the correct locations. For example we have libcustom_ops_aot_lib.so depending
# on _portable_lib.so, which was eventually put under
# <site-packages>/executorch/extension/pybindings/ but this rpath is not
# automatically added because at build time it seems `portable_lib` is being
# built under the same directory, so no extra rpath is being added. To properly
# fix this we need to install `portable_lib` into the correct path.
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
Expand Down Expand Up @@ -321,8 +322,9 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
" -fprofile-instr-generate -fcoverage-mapping"
)
else()
message(FATAL_ERROR
"Code coverage for compiler ${CMAKE_CXX_COMPILER_ID} is unsupported"
message(
FATAL_ERROR
"Code coverage for compiler ${CMAKE_CXX_COMPILER_ID} is unsupported"
)
endif()
endif()
Expand Down Expand Up @@ -633,8 +635,8 @@ if(EXECUTORCH_BUILD_PYBIND)
endif()

if(EXECUTORCH_BUILD_XNNPACK)
# need to explicitly specify XNNPACK and xnnpack-microkernels-prod here otherwise
# uses XNNPACK and microkernel-prod symbols from libtorch_cpu
# need to explicitly specify XNNPACK and xnnpack-microkernels-prod here
# otherwise uses XNNPACK and microkernel-prod symbols from libtorch_cpu
list(APPEND _dep_libs xnnpack_backend XNNPACK xnnpack-microkernels-prod)
endif()

Expand Down
66 changes: 31 additions & 35 deletions backends/apple/coreml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ if(APPLE)
endif()

add_library(coreml_util ${UTIL_SOURCES})
target_include_directories(coreml_util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/util)
target_include_directories(
coreml_util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/util
)
if(APPLE)
target_link_libraries(coreml_util PRIVATE ${FOUNDATION_FRAMEWORK})
endif()
Expand All @@ -119,21 +121,25 @@ install(

# CoreML inmemoryfs

set(
INMEMORYFS_SOURCES
runtime/inmemoryfs/inmemory_filesystem.cpp
runtime/inmemoryfs/memory_buffer.cpp
runtime/inmemoryfs/memory_stream.cpp
runtime/inmemoryfs/reversed_memory_stream.cpp
set(INMEMORYFS_SOURCES
runtime/inmemoryfs/inmemory_filesystem.cpp
runtime/inmemoryfs/memory_buffer.cpp runtime/inmemoryfs/memory_stream.cpp
runtime/inmemoryfs/reversed_memory_stream.cpp
)
if(APPLE)
list(APPEND INMEMORYFS_SOURCES runtime/inmemoryfs/inmemory_filesystem_utils.mm)
list(APPEND INMEMORYFS_SOURCES
runtime/inmemoryfs/inmemory_filesystem_utils.mm
)
endif()

add_library(coreml_inmemoryfs ${INMEMORYFS_SOURCES})
target_include_directories(coreml_inmemoryfs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/inmemoryfs)
target_include_directories(
coreml_inmemoryfs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/inmemoryfs
)
if(APPLE)
target_link_libraries(coreml_inmemoryfs PRIVATE coreml_util ${FOUNDATION_FRAMEWORK})
target_link_libraries(
coreml_inmemoryfs PRIVATE coreml_util ${FOUNDATION_FRAMEWORK}
)
endif()
target_compile_options(coreml_inmemoryfs PUBLIC -fPIC)

Expand All @@ -148,17 +154,12 @@ install(

if(EXECUTORCH_BUILD_PYBIND)
pybind11_add_module(
executorchcoreml
SHARED
runtime/inmemoryfs/inmemory_filesystem_py.cpp
runtime/inmemoryfs/inmemory_filesystem_utils.cpp
executorchcoreml SHARED runtime/inmemoryfs/inmemory_filesystem_py.cpp
runtime/inmemoryfs/inmemory_filesystem_utils.cpp
)
target_link_libraries(
executorchcoreml
PRIVATE
coreml_util
coreml_inmemoryfs
nlohmann_json::nlohmann_json
executorchcoreml PRIVATE coreml_util coreml_inmemoryfs
nlohmann_json::nlohmann_json
)
target_compile_options(executorchcoreml PUBLIC -fPIC)
endif()
Expand All @@ -179,8 +180,12 @@ if(APPLE)
coremldelegate PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/runtime/delegate
)
target_include_directories(coremldelegate PRIVATE ${PROJECT_SOURCE_DIR}/..)
target_include_directories(coremldelegate PRIVATE ${PROJECT_SOURCE_DIR}/runtime/core/portable_type/c10)
target_compile_definitions(coremldelegate PRIVATE C10_USING_CUSTOM_GENERATED_MACROS)
target_include_directories(
coremldelegate PRIVATE ${PROJECT_SOURCE_DIR}/runtime/core/portable_type/c10
)
target_compile_definitions(
coremldelegate PRIVATE C10_USING_CUSTOM_GENERATED_MACROS
)

if(EXECUTORCH_BUILD_DEVTOOLS)
target_sources(coremldelegate PRIVATE ${SDK_SOURCES} ${PROTOBUF_SOURCES})
Expand All @@ -200,13 +205,9 @@ if(APPLE)

target_link_libraries(
coremldelegate
PUBLIC coreml_util
coreml_inmemoryfs
PRIVATE executorch_core
${ACCELERATE_FRAMEWORK}
${COREML_FRAMEWORK}
${FOUNDATION_FRAMEWORK}
${SQLITE_LIBRARY}
PUBLIC coreml_util coreml_inmemoryfs
PRIVATE executorch_core ${ACCELERATE_FRAMEWORK} ${COREML_FRAMEWORK}
${FOUNDATION_FRAMEWORK} ${SQLITE_LIBRARY}
)

target_link_options_shared_lib(coremldelegate)
Expand All @@ -218,13 +219,8 @@ if(APPLE)
endif()

target_compile_options(
coremldelegate
PRIVATE
-fobjc-arc
-fno-exceptions
-x objective-c++
-Wno-null-character
-Wno-receiver-expr
coremldelegate PRIVATE -fobjc-arc -fno-exceptions -x objective-c++
-Wno-null-character -Wno-receiver-expr
)

if(EXECUTORCH_BUILD_DEVTOOLS)
Expand Down
10 changes: 3 additions & 7 deletions backends/mediatek/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@ include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/runtime/include)
# targets
add_library(neuron_backend SHARED)
target_compile_options(neuron_backend PRIVATE "-frtti" "-fexceptions")
target_link_libraries(neuron_backend
PRIVATE
executorch_core
portable_ops_lib
portable_kernels
android
log
target_link_libraries(
neuron_backend PRIVATE executorch_core portable_ops_lib portable_kernels
android log
)
target_sources(
neuron_backend
Expand Down
40 changes: 26 additions & 14 deletions backends/qualcomm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
endif()

include_directories(
BEFORE ${_common_include_directories} ${QNN_SDK_ROOT}/include/QNN
BEFORE
${_common_include_directories}
${QNN_SDK_ROOT}/include/QNN
${QNN_SDK_ROOT}/share/QNN/converter/jni
${EXECUTORCH_SOURCE_DIR}/third-party/flatbuffers/include
${EXECUTORCH_SOURCE_DIR}/runtime/core/portable_type/c10
)

set(_qnn_schema__srcs
backends/qualcomm/serialization/qc_compiler_spec.fbs
)
set(_qnn_schema__srcs backends/qualcomm/serialization/qc_compiler_spec.fbs)
set(_qnn_schema__include_dir "${CMAKE_BINARY_DIR}/schema/include")
# Paths to headers generated from the .fbs files.
set(_qnn_schema__outputs)
Expand Down Expand Up @@ -145,22 +145,24 @@ add_library(utils STATIC)
target_link_libraries(qcir_utils PRIVATE qcir)
target_link_libraries(wrappers PRIVATE qnn_executorch_logging)
target_link_libraries(
qnn_implementation PRIVATE qnn_function_interface qnn_executorch_logging ${CMAKE_DL_LIBS}
qnn_implementation PRIVATE qnn_function_interface qnn_executorch_logging
${CMAKE_DL_LIBS}
)
target_link_libraries(
qnn_sys_implementation PRIVATE qnn_sys_function_interface qnn_executorch_logging ${CMAKE_DL_LIBS}
qnn_sys_implementation PRIVATE qnn_sys_function_interface
qnn_executorch_logging ${CMAKE_DL_LIBS}
)
target_link_libraries(qnn_executorch_logging PRIVATE qnn_schema)
target_link_libraries(qnn_profiler PRIVATE qnn_executorch_logging)
target_link_libraries(qnn_logger PRIVATE qnn_implementation ${android_log})
target_link_libraries(qnn_backend PRIVATE qnn_implementation qnn_logger qnn_op_package_manager)
target_link_libraries(qnn_custom_protocol PRIVATE qnn_logger)
target_link_libraries(
qnn_device PRIVATE qnn_executorch_logging qnn_implementation qnn_logger
qnn_backend PRIVATE qnn_implementation qnn_logger qnn_op_package_manager
)
target_link_libraries(qnn_custom_protocol PRIVATE qnn_logger)
target_link_libraries(
qnn_backend_cache PRIVATE qnn_sys_implementation
qnn_device PRIVATE qnn_executorch_logging qnn_implementation qnn_logger
)
target_link_libraries(qnn_backend_cache PRIVATE qnn_sys_implementation)
target_link_libraries(
qnn_context PRIVATE qnn_implementation qnn_logger qnn_backend qnn_device
qnn_backend_cache
Expand All @@ -174,14 +176,24 @@ target_link_libraries(
)

target_link_libraries(
qnn_factory PRIVATE qnn_schema qnn_backend qnn_device qnn_context qnn_graph
qnn_mem_manager qnn_custom_protocol
qnn_factory
PRIVATE qnn_schema
qnn_backend
qnn_device
qnn_context
qnn_graph
qnn_mem_manager
qnn_custom_protocol
)

target_link_libraries(qnn_dlc_manager PRIVATE qnn_factory qnn_backend qnn_device qnn_context qnn_graph qnn_mem_manager)
target_link_libraries(
qnn_dlc_manager PRIVATE qnn_factory qnn_backend qnn_device qnn_context
qnn_graph qnn_mem_manager
)

target_link_libraries(
qnn_manager PRIVATE qnn_factory wrappers qnn_schema utils shared_buffer qnn_dlc_manager
qnn_manager PRIVATE qnn_factory wrappers qnn_schema utils shared_buffer
qnn_dlc_manager
)
target_link_libraries(
qnn_executorch_backend PRIVATE qnn_executorch_header qnn_schema qnn_manager
Expand Down
3 changes: 2 additions & 1 deletion backends/vulkan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ add_custom_command(
OUTPUT ${GENERATED_HEADER}
COMMAND
flatc --cpp --cpp-std c++11 --scoped-enums -o
"${SCHEMA_INCLUDE_DIR}/executorch/backends/vulkan/serialization/" ${_vulkan_schema__srcs}
"${SCHEMA_INCLUDE_DIR}/executorch/backends/vulkan/serialization/"
${_vulkan_schema__srcs}
WORKING_DIRECTORY ${EXECUTORCH_ROOT}
DEPENDS flatc
COMMENT "Generating vulkan_schema headers"
Expand Down
4 changes: 3 additions & 1 deletion configurations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)

# optimized_native_cpu_ops_lib: Register optimized op kernels into the runtime
if(TARGET optimized_portable_kernels)
set(_optimized_native_cpu_ops_lib_portable_kernels_lib optimized_portable_kernels)
set(_optimized_native_cpu_ops_lib_portable_kernels_lib
optimized_portable_kernels
)
else()
set(_optimized_native_cpu_ops_lib_portable_kernels_lib portable_kernels)
endif()
Expand Down
13 changes: 6 additions & 7 deletions extension/llm/custom_ops/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ target_include_directories(
)
target_link_libraries(custom_ops PUBLIC ${custom_ops_libs} executorch_core)

target_compile_options(
custom_ops PUBLIC ${_common_compile_options}
)
target_compile_options(custom_ops PUBLIC ${_common_compile_options})

install(TARGETS custom_ops DESTINATION lib)

Expand Down Expand Up @@ -117,7 +115,9 @@ if(EXECUTORCH_BUILD_KERNELS_LLM_AOT)
else()
# If no portable_lib, custom_ops_aot_lib still gives the ability to use the
# ops in PyTorch
target_link_libraries(custom_ops_aot_lib PUBLIC executorch_core kernels_util_all_deps)
target_link_libraries(
custom_ops_aot_lib PUBLIC executorch_core kernels_util_all_deps
)
endif()

target_link_libraries(
Expand All @@ -130,9 +130,8 @@ if(EXECUTORCH_BUILD_KERNELS_LLM_AOT)
target_link_libraries(custom_ops_aot_lib PUBLIC pthreadpool cpuinfo)
endif()
target_compile_options(
custom_ops_aot_lib
PUBLIC -Wno-deprecated-declarations -fPIC -frtti -fexceptions
${_common_compile_options}
custom_ops_aot_lib PUBLIC -Wno-deprecated-declarations -fPIC -frtti
-fexceptions ${_common_compile_options}
)

install(TARGETS custom_ops_aot_lib
Expand Down
8 changes: 6 additions & 2 deletions extension/module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ if(CMAKE_TOOLCHAIN_IOS
else()
add_library(extension_module SHARED ${_extension_module__srcs})
endif()
target_link_libraries(extension_module PRIVATE executorch_core extension_data_loader extension_flat_tensor)
target_link_libraries(
extension_module PRIVATE executorch_core extension_data_loader
extension_flat_tensor
)
target_include_directories(extension_module PUBLIC ${EXECUTORCH_ROOT}/..)
target_compile_options(
extension_module PUBLIC -Wno-deprecated-declarations -fPIC
Expand All @@ -37,7 +40,8 @@ target_compile_options(
# after cleaning up CMake targets.
add_library(extension_module_static STATIC ${_extension_module__srcs})
target_link_libraries(
extension_module_static PRIVATE executorch_core extension_data_loader extension_flat_tensor
extension_module_static PRIVATE executorch_core extension_data_loader
extension_flat_tensor
)
target_include_directories(extension_module_static PUBLIC ${EXECUTORCH_ROOT}/..)
target_compile_options(
Expand Down
Loading
Loading