link libatomic on systems without adequate builtin atomics
diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake
index fd70da7..710b34c 100644
--- a/cmake/libprotobuf.cmake
+++ b/cmake/libprotobuf.cmake
@@ -118,7 +118,10 @@
${libprotobuf_lite_files} ${libprotobuf_files} ${libprotobuf_includes} ${libprotobuf_rc_files})
target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT})
if(protobuf_WITH_ZLIB)
- target_link_libraries(libprotobuf ${ZLIB_LIBRARIES})
+ target_link_libraries(libprotobuf ${ZLIB_LIBRARIES})
+endif()
+if(protobuf_LINK_LIBATOMIC)
+ target_link_libraries(libprotobuf atomic)
endif()
target_include_directories(libprotobuf PUBLIC ${protobuf_source_dir}/src)
if(MSVC AND protobuf_BUILD_SHARED_LIBS)