diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 85e8e40dfd..40773cd8fd 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -109,10 +109,11 @@ option(onnxruntime_USE_ROCM "Build with AMD GPU support" OFF) option(onnxruntime_DISABLE_CONTRIB_OPS "Disable contrib ops" OFF) option(onnxruntime_DISABLE_ML_OPS "Disable traditional ML ops" OFF) option(onnxruntime_DISABLE_SPARSE_TENSORS "Disable sparse tensors data types" OFF) +option(onnxruntime_MINIMAL_BUILD "Exclude as much as possible from the build. Support ORT format models. No support for ONNX format models." OFF) cmake_dependent_option(onnxruntime_DISABLE_RTTI "Disable RTTI" ON "onnxruntime_MINIMAL_BUILD;NOT onnxruntime_ENABLE_PYTHON" OFF) # For now onnxruntime_DISABLE_EXCEPTIONS will only work with onnxruntime_MINIMAL_BUILD, more changes (ONNX, non-CPU EP, ...) are required to run this standalone -option(onnxruntime_DISABLE_EXCEPTIONS "Disable exception handling. Requires onnxruntime_MINIMAL_BUILD currently." OFF) -option(onnxruntime_MINIMAL_BUILD "Exclude as much as possible from the build. Support ORT format models. No support for ONNX format models." OFF) +cmake_dependent_option(onnxruntime_DISABLE_EXCEPTIONS "Disable exception handling. Requires onnxruntime_MINIMAL_BUILD currently." ON "onnxruntime_MINIMAL_BUILD;NOT onnxruntime_ENABLE_PYTHON" OFF) + option(onnxruntime_EXTENDED_MINIMAL_BUILD "onnxruntime_MINIMAL_BUILD with support for execution providers that compile kernels." OFF) option(onnxruntime_MINIMAL_BUILD_CUSTOM_OPS "Add custom operator kernels support to a minimal build." OFF) option(onnxruntime_REDUCED_OPS_BUILD "Reduced set of kernels are registered in build via modification of the kernel registration source files." OFF) @@ -406,7 +407,7 @@ if (onnxruntime_DISABLE_EXTERNAL_INITIALIZERS) endif() if (onnxruntime_DISABLE_RTTI) - add_compile_definitions(ORT_NO_RTTI GOOGLE_PROTOBUF_NO_RTTI) + add_compile_definitions(ORT_NO_RTTI) if (MSVC) # Disable RTTI and turn usage of dynamic_cast and typeid into errors add_compile_options("$<$:/GR->" "$<$:/we4541>") @@ -428,6 +429,10 @@ if (onnxruntime_DISABLE_EXCEPTIONS) message(FATAL_ERROR "onnxruntime_MINIMAL_BUILD required for onnxruntime_DISABLE_EXCEPTIONS") endif() + if (onnxruntime_ENABLE_PYTHON) + # pybind11 highly depends on C++ exceptions. + message(FATAL_ERROR "onnxruntime_ENABLE_PYTHON must be disabled for onnxruntime_DISABLE_EXCEPTIONS") + endif() add_compile_definitions("ORT_NO_EXCEPTIONS") add_compile_definitions("MLAS_NO_EXCEPTION") add_compile_definitions("ONNX_NO_EXCEPTIONS") @@ -760,7 +765,7 @@ else() set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build with zlib support" FORCE) endif() if (onnxruntime_DISABLE_RTTI) - set(protobuf_DISABLE_RTTI OFF CACHE BOOL "Remove runtime type information in the binaries" FORCE) + set(protobuf_DISABLE_RTTI ON CACHE BOOL "Remove runtime type information in the binaries" FORCE) endif() add_subdirectory(${PROJECT_SOURCE_DIR}/external/protobuf/cmake EXCLUDE_FROM_ALL)