Skip to content

Enforce required cmake flags as explicit requirements #11457

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .ci/scripts/build-qnn-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ set_up_aot() {
-DQNN_SDK_ROOT=${QNN_SDK_ROOT} \
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
-DPYTHON_EXECUTABLE=python3
Expand Down
1 change: 1 addition & 0 deletions .ci/scripts/test_llama_torchao_lowbit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ cmake -DPYTHON_EXECUTABLE=python \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
-DEXECUTORCH_BUILD_XNNPACK=OFF \
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
Expand Down
1 change: 1 addition & 0 deletions .ci/scripts/test_llava.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ EXECUTORCH_COMMON_CMAKE_ARGS=" \
-DEXECUTORCH_ENABLE_LOGGING=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
Expand Down
1 change: 1 addition & 0 deletions .ci/scripts/test_phi_3_mini.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cmake_install_executorch_libraries() {
-DEXECUTORCH_ENABLE_LOGGING=1 \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
-DEXECUTORCH_BUILD_XNNPACK=ON \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ jobs:
-DEXECUTORCH_ENABLE_LOGGING=1 \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
-DEXECUTORCH_BUILD_XNNPACK=ON \
Expand Down
28 changes: 1 addition & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,37 +152,11 @@ else()
endif()

if(EXECUTORCH_BUILD_TESTS)
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
include(CTest)
endif()

add_subdirectory(third-party)

if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
set(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
endif()

if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
endif()

if(EXECUTORCH_BUILD_EXTENSION_MODULE)
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
endif()

if(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT)
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
set(EXECUTORCH_BUILD_KERNELS_CUSTOM ON)
endif()

if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
set(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)
endif()

if(NOT DEFINED FXDIV_SOURCE_DIR)
set(ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG
${CMAKE_POSITION_INDEPENDENT_CODE}
Expand Down Expand Up @@ -336,7 +310,7 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
" -fprofile-instr-generate -fcoverage-mapping"
)
else()
message(ERROR
message(FATAL_ERROR
"Code coverage for compiler ${CMAKE_CXX_COMPILER_ID} is unsupported"
)
endif()
Expand Down
4 changes: 4 additions & 0 deletions backends/qualcomm/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ if [ "$BUILD_AARCH64" = true ]; then
-DEXECUTORCH_BUILD_QNN=ON \
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
-DQNN_SDK_ROOT=$QNN_SDK_ROOT \
Expand Down Expand Up @@ -127,6 +129,8 @@ if [ "$BUILD_X86_64" = true ]; then
-DEXECUTORCH_BUILD_QNN=ON \
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
Expand Down
3 changes: 2 additions & 1 deletion examples/models/phi-3-mini/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_BUILD_TYPE Release)

# Set options for executorch build.
option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER "" ON)
option(EXECUTORCH_BUILD_EXTENSION_MODULE "" ON)
option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER "" ON)
option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR "" ON)
option(EXECUTORCH_BUILD_EXTENSION_TENSOR "" ON)
option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED "" ON)
option(EXECUTORCH_BUILD_XNNPACK "" ON)
Expand Down
1 change: 1 addition & 0 deletions scripts/build_android_library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ build_android_native_library() {
-DEXECUTORCH_BUILD_XNNPACK=ON \
-DEXECUTORCH_XNNPACK_SHARED_WORKSPACE=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
Expand Down
1 change: 1 addition & 0 deletions tools/cmake/preset/apple_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set_overridable_option(EXECUTORCH_XNNPACK_SHARED_WORKSPACE ON)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_APPLE ON)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
set_overridable_option(EXECUTORCH_BUILD_KERNELS_CUSTOM ON)
set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)
Expand Down
72 changes: 64 additions & 8 deletions tools/cmake/preset/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,72 @@ define_overridable_option(
"Enable weights cache to cache and manage all packed weights"
BOOL OFF
)
define_overridable_option(
EXECUTORCH_USE_CPP_CODE_COVERAGE
"Build with code coverage enabled"
BOOL OFF
)

# MARK: - Validations
# ------------------------------------------------------------------------------
# Validations
#
# At this point all the options should be configured with their final value.
# ------------------------------------------------------------------------------

check_required_options_on(
IF_ON
EXECUTORCH_ENABLE_EVENT_TRACER
REQUIRES
EXECUTORCH_BUILD_DEVTOOLS
)

check_required_options_on(
IF_ON
EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR
REQUIRES
EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
)

check_required_options_on(
IF_ON
EXECUTORCH_BUILD_EXTENSION_MODULE
REQUIRES
EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR
)

check_required_options_on(
IF_ON
EXECUTORCH_BUILD_KERNELS_CUSTOM
REQUIRES
EXECUTORCH_BUILD_KERNELS_OPTIMIZED
)

check_required_options_on(
IF_ON
EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT
REQUIRES
EXECUTORCH_BUILD_EXTENSION_TENSOR
EXECUTORCH_BUILD_KERNELS_CUSTOM
)

check_required_options_on(
IF_ON
EXECUTORCH_BUILD_EXTENSION_TRAINING
REQUIRES
EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR
EXECUTORCH_BUILD_EXTENSION_MODULE
EXECUTORCH_BUILD_EXTENSION_TENSOR
)

check_required_options_on(
IF_ON
EXECUTORCH_BUILD_TESTS
REQUIRES
EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR
)


if(NOT EXISTS ${EXECUTORCH_PAL_DEFAULT_FILE_PATH})
message(FATAL_ERROR "PAL default implementation (EXECUTORCH_PAL_DEFAULT=${EXECUTORCH_PAL_DEFAULT}) file not found: ${EXECUTORCH_PAL_DEFAULT_FILE_PATH}. Choices: posix, minimal, android")
Expand All @@ -299,13 +362,6 @@ else()
endif()


if(EXECUTORCH_ENABLE_EVENT_TRACER)
if(NOT EXECUTORCH_BUILD_DEVTOOLS)
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")
Expand Down
2 changes: 2 additions & 0 deletions tools/cmake/preset/pybind.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ set_overridable_option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON)
set_overridable_option(EXECUTORCH_BUILD_KERNELS_CUSTOM ON)
set_overridable_option(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT ON)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)


if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
Expand Down
Loading