From da6406bade7f2479c7526ea6bfad061a830fe727 Mon Sep 17 00:00:00 2001 From: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:45:52 -0700 Subject: [PATCH] Enable OBJC/OBJCXX for all projects if necessary --- cmake/CMakeLists.txt | 16 ++++++++++++++++ cmake/onnxruntime_objectivec.cmake | 14 -------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index bfb1827d7c5ec..c0772c33f6e5d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -489,6 +489,22 @@ if (onnxruntime_BUILD_CSHARP) endif() endif() +if (onnxruntime_BUILD_OBJC) + check_language(OBJC) + if(CMAKE_OBJC_COMPILER) + enable_language(OBJC) + else() + message(FATAL_ERROR "Objective-C is not supported.") + endif() + + check_language(OBJCXX) + if(CMAKE_OBJCXX_COMPILER) + enable_language(OBJCXX) + else() + message(FATAL_ERROR "Objective-C++ is not supported.") + endif() +endif() + if (NOT WIN32) #TODO: On Linux we may try https://github.com/microsoft/TraceLogging.git if (onnxruntime_ENABLE_INSTRUMENT) diff --git a/cmake/onnxruntime_objectivec.cmake b/cmake/onnxruntime_objectivec.cmake index 4be2f51a96ebc..7c9831f0194d0 100644 --- a/cmake/onnxruntime_objectivec.cmake +++ b/cmake/onnxruntime_objectivec.cmake @@ -9,20 +9,6 @@ if(NOT onnxruntime_BUILD_SHARED_LIB) message(FATAL_ERROR "The Objective-C API requires onnxruntime_BUILD_SHARED_LIB to be enabled.") endif() -check_language(OBJC) -if(CMAKE_OBJC_COMPILER) - enable_language(OBJC) -else() - message(FATAL_ERROR "Objective-C is not supported.") -endif() - -check_language(OBJCXX) -if(CMAKE_OBJCXX_COMPILER) - enable_language(OBJCXX) -else() - message(FATAL_ERROR "Objective-C++ is not supported.") -endif() - add_compile_options( "$<$:-Wall>" "$<$:-Wextra>")