diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt index 1afab9f446edd..2b3485c137d06 100644 --- a/caffe2/CMakeLists.txt +++ b/caffe2/CMakeLists.txt @@ -1142,7 +1142,7 @@ endif() endif() # XXX This ABI check cannot be run with arm-linux-androideabi-g++ - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(DEFINED GLIBCXX_USE_CXX11_ABI) message(STATUS "_GLIBCXX_USE_CXX11_ABI is already defined as a cmake variable") else() diff --git a/cmake/TorchConfig.cmake.in b/cmake/TorchConfig.cmake.in index 3bdc7a6b9caad..0d8b15bd14a8c 100644 --- a/cmake/TorchConfig.cmake.in +++ b/cmake/TorchConfig.cmake.in @@ -166,8 +166,8 @@ if(@USE_CUDA@) list(APPEND TORCH_LIBRARIES ${TORCH_CUDA_LIBRARIES}) endif() -# When we build libtorch with the old GCC ABI, dependent libraries must too. -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") +# When we build libtorch with the old libstdc++ ABI, dependent libraries must too. +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(TORCH_CXX_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=@GLIBCXX_USE_CXX11_ABI@") endif()