From 3a9fc04308c269a42debf14e52109e3af8ce4f81 Mon Sep 17 00:00:00 2001 From: jathu Date: Sat, 10 May 2025 17:28:19 -0700 Subject: [PATCH] move dependent options --- CMakeLists.txt | 28 +---------------------- tools/cmake/Utils.cmake | 11 --------- tools/cmake/preset/default.cmake | 38 ++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bae7732f881..ed154c6df04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,22 +128,6 @@ else() set(CMAKE_CXX_FLAGS_RELEASE "-O2 ${CMAKE_CXX_FLAGS_RELEASE}") endif() -# -# pthreadpool: build pthreadpool library. Disable on unsupported platforms -# -cmake_dependent_option( - EXECUTORCH_BUILD_PTHREADPOOL "Build pthreadpool library." ON - "NOT EXECUTORCH_BUILD_ARM_BAREMETAL" OFF -) - -# -# cpuinfo: build cpuinfo library. Disable on unsupported platforms -# -cmake_dependent_option( - EXECUTORCH_BUILD_CPUINFO "Build cpuinfo library." ON - "NOT EXECUTORCH_BUILD_ARM_BAREMETAL" OFF -) - add_subdirectory(third-party) if(EXECUTORCH_BUILD_EXTENSION_TRAINING) @@ -475,14 +459,6 @@ install( ) install(FILES tools/cmake/executorch-config.cmake DESTINATION lib/cmake/ExecuTorch) -# -# executor_runner: Host tool that demonstrates program execution. -# -cmake_dependent_option( - EXECUTORCH_BUILD_EXECUTOR_RUNNER "Build the executor_runner executable" ON - "NOT CMAKE_TOOLCHAIN_IOS" OFF -) - # Add googletest if any test targets should be built if(BUILD_TESTING) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/googletest) @@ -571,9 +547,7 @@ if(EXECUTORCH_BUILD_EXTENSION_TENSOR) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/tensor) endif() -if(EXECUTORCH_BUILD_PTHREADPOOL - AND EXECUTORCH_BUILD_CPUINFO -) +if(EXECUTORCH_BUILD_PTHREADPOOL AND EXECUTORCH_BUILD_CPUINFO) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/threadpool) endif() diff --git a/tools/cmake/Utils.cmake b/tools/cmake/Utils.cmake index 773ee1c578b..d588a983086 100644 --- a/tools/cmake/Utils.cmake +++ b/tools/cmake/Utils.cmake @@ -29,17 +29,6 @@ function(executorch_print_configuration_summary) message(STATUS " CMAKE_TOOLCHAIN_FILE : ${CMAKE_TOOLCHAIN_FILE}") message(STATUS " BUCK2 : ${BUCK2}") message(STATUS " PYTHON_EXECUTABLE : ${PYTHON_EXECUTABLE}") - message( - STATUS - " EXECUTORCH_BUILD_CPUINFO : ${EXECUTORCH_BUILD_CPUINFO}" - ) - message(STATUS " EXECUTORCH_BUILD_EXECUTOR_RUNNER : " - "${EXECUTORCH_BUILD_EXECUTOR_RUNNER}" - ) - message( - STATUS - " EXECUTORCH_BUILD_PTHREADPOOL : ${EXECUTORCH_BUILD_PTHREADPOOL}" - ) endfunction() # This is the funtion to use -Wl, --whole-archive to link static library NB: diff --git a/tools/cmake/preset/default.cmake b/tools/cmake/preset/default.cmake index 1fdd54976aa..7b6830bd3c8 100644 --- a/tools/cmake/preset/default.cmake +++ b/tools/cmake/preset/default.cmake @@ -205,6 +205,35 @@ define_overridable_option( BOOL ON ) +if(EXECUTORCH_BUILD_ARM_BAREMETAL) + set(_default_executorch_build_pthreadpool OFF) + set(_default_executorch_build_cpuinfo OFF) +else() + set(_default_executorch_build_pthreadpool ON) + set(_default_executorch_build_cpuinfo ON) +endif() +define_overridable_option( + EXECUTORCH_BUILD_PTHREADPOOL + "Build pthreadpool library." + BOOL ${_default_executorch_build_pthreadpool} +) +define_overridable_option( + EXECUTORCH_BUILD_CPUINFO + "Build cpuinfo library." + BOOL ${_default_executorch_build_cpuinfo} +) + +# TODO(jathu): move this to platform specific presets when created +set(_default_executorch_build_executor_runner ON) +if(APPLE AND "${SDK_NAME}" STREQUAL "iphoneos") + set(_default_executorch_build_executor_runner OFF) +endif() +define_overridable_option( + EXECUTORCH_BUILD_EXECUTOR_RUNNER + "Build the executor_runner executable" + BOOL ${_default_executorch_build_executor_runner} +) + # MARK: - Validations # At this point all the options should be configured with their final value. @@ -232,3 +261,12 @@ if(EXECUTORCH_ENABLE_EVENT_TRACER) message(FATAL_ERROR "Use of 'EXECUTORCH_ENABLE_EVENT_TRACER' requires 'EXECUTORCH_BUILD_DEVTOOLS' to be enabled.") endif() endif() + + +if(EXECUTORCH_BUILD_ARM_BAREMETAL) + if(EXECUTORCH_BUILD_PTHREADPOOL) + message(FATAL_ERROR "Cannot enable both EXECUTORCH_BUILD_PTHREADPOOL and EXECUTORCH_BUILD_ARM_BAREMETAL") + elseif(EXECUTORCH_BUILD_CPUINFO) + message(FATAL_ERROR "Cannot enable both EXECUTORCH_BUILD_CPUINFO and EXECUTORCH_BUILD_ARM_BAREMETAL") + endif() +endif()