diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c447093f9f..7a43d53c3e 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1228,7 +1228,7 @@ function(onnxruntime_add_shared_library_module target_name) endif() onnxruntime_configure_target(${target_name}) - if (onnxruntime_target_platform STREQUAL "x86" AND NOT onnxruntime_BUILD_WEBASSEMBLY) + if (MSVC AND onnxruntime_target_platform STREQUAL "x86" AND NOT onnxruntime_BUILD_WEBASSEMBLY) target_link_options(${target_name} PRIVATE /SAFESEH) endif() endfunction() @@ -1236,7 +1236,7 @@ endfunction() function(onnxruntime_add_executable target_name) add_executable(${target_name} ${ARGN}) onnxruntime_configure_target(${target_name}) - if (onnxruntime_target_platform STREQUAL "x86" AND NOT onnxruntime_BUILD_WEBASSEMBLY) + if (MSVC AND onnxruntime_target_platform STREQUAL "x86" AND NOT onnxruntime_BUILD_WEBASSEMBLY) target_link_options(${target_name} PRIVATE /SAFESEH) endif() endfunction()