diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index bfb1827d7c5e..c0772c33f6e5 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 4be2f51a96eb..7c9831f0194d 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>")