diff --git a/examples/heatTransfer/write/CMakeLists.txt b/examples/heatTransfer/write/CMakeLists.txt
index e9f9c3a12288109efa929192d4bb9a60b81c2fbb..a40186bb05e6d8225d73d5d58fea4fc380de47b6 100644
--- a/examples/heatTransfer/write/CMakeLists.txt
+++ b/examples/heatTransfer/write/CMakeLists.txt
@@ -5,6 +5,7 @@
 
 if(ADIOS2_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
+  find_package(Threads REQUIRED)
 
   add_executable(heatTransfer_write_adios2
     main.cpp
@@ -15,7 +16,8 @@ if(ADIOS2_HAVE_MPI)
   target_include_directories(heatTransfer_write_adios2
     PRIVATE ${MPI_C_INCLUDE_PATH}
   )
-  target_link_libraries(heatTransfer_write_adios2 adios2 ${MPI_C_LIBRARIES} pthread)
+  target_link_libraries(heatTransfer_write_adios2 adios2 ${MPI_C_LIBRARIES} 
+                        ${CMAKE_THREAD_LIBS_INIT})
   target_compile_definitions(heatTransfer_write_adios2 PRIVATE
    -DDEFAULT_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/config.xml)
 
@@ -33,7 +35,7 @@ if(ADIOS2_HAVE_MPI)
       PRIVATE ${MPI_C_INCLUDE_PATH}
     )
     target_link_libraries(heatTransfer_write_adios1
-      adios1::adios ${MPI_C_LIBRARIES} pthread
+      adios1::adios ${MPI_C_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}
     )
   endif()
 
@@ -51,7 +53,7 @@ if(ADIOS2_HAVE_MPI)
       PRIVATE ${MPI_C_INCLUDE_PATH} ${HDF5_C_INCLUDE_DIRS}
     )
     target_link_libraries(heatTransfer_write_hdf5
-      ${MPI_C_LIBRARIES} ${HDF5_C_LIBRARIES} pthread
+      ${MPI_C_LIBRARIES} ${HDF5_C_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}
     )
   endif()
 
@@ -70,7 +72,7 @@ if(ADIOS2_HAVE_MPI)
       PRIVATE ${MPI_C_INCLUDE_PATH} ${HDF5_C_INCLUDE_DIRS}
     )
     target_link_libraries(heatTransfer_write_ph5
-      ${MPI_C_LIBRARIES} ${HDF5_C_LIBRARIES} pthread
+      ${MPI_C_LIBRARIES} ${HDF5_C_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}
     )
   endif()
 
@@ -91,7 +93,8 @@ if(ADIOS2_HAVE_MPI)
     #target_link_libraries(heatTransfer_write_a2h5
     #  ${MPI_C_LIBRARIES} 
     #)
-    target_link_libraries(heatTransfer_write_a2h5 PUBLIC adios2 pthread)
+    target_link_libraries(heatTransfer_write_a2h5 PUBLIC adios2 
+                          ${CMAKE_THREAD_LIBS_INIT})
 
   endif()