diff --git a/indra/CMakeLists.txt b/indra/CMakeLists.txt
index 62a8f3f003e8e0c19580eef1590c29d4e3302090..53e5d7b6a54e5ad31f5f85b6a98ba1dda4ad7fd8 100644
--- a/indra/CMakeLists.txt
+++ b/indra/CMakeLists.txt
@@ -15,6 +15,11 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
 include(Variables)
 include(BuildVersion)
 
+set(LEGACY_STDIO_LIBS)
+if (WINDOWS)
+      set(LEGACY_STDIO_LIBS legacy_stdio_definitions)
+endif (WINDOWS)
+
 if (NOT CMAKE_BUILD_TYPE)
   set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
       "Build type.  One of: Debug Release RelWithDebInfo" FORCE)
diff --git a/indra/cmake/LLAddBuildTest.cmake b/indra/cmake/LLAddBuildTest.cmake
index 0a20a2c0681cf366f55b87819839f839c82b311e..4932e9044f3949678df593c4758ca447bf251cba 100644
--- a/indra/cmake/LLAddBuildTest.cmake
+++ b/indra/cmake/LLAddBuildTest.cmake
@@ -200,6 +200,7 @@ FUNCTION(LL_ADD_INTEGRATION_TEST
     )
 
   SET(libraries
+    ${LEGACY_STDIO_LIBS}
     ${library_dependencies}
     ${BOOST_FIBER_LIBRARY}
     ${BOOST_CONTEXT_LIBRARY}
@@ -208,10 +209,6 @@ FUNCTION(LL_ADD_INTEGRATION_TEST
     ${PTHREAD_LIBRARY}
     )
 
-  if (WINDOWS)
-      list(INSERT libraries 0 legacy_stdio_definitions)
-  endif (WINDOWS)
-
   # Add test executable build target
   if(TEST_DEBUG)
     message(STATUS "ADD_EXECUTABLE(INTEGRATION_TEST_${testname} ${source_files})")
diff --git a/indra/integration_tests/llimage_libtest/CMakeLists.txt b/indra/integration_tests/llimage_libtest/CMakeLists.txt
index d9353f904c2c23588a1b22bdb1876702c0664eea..5787d4d600a6187cc5d49e7c1de7461f2484a60c 100644
--- a/indra/integration_tests/llimage_libtest/CMakeLists.txt
+++ b/indra/integration_tests/llimage_libtest/CMakeLists.txt
@@ -64,6 +64,7 @@ endif (DARWIN)
 # Libraries on which this application depends on
 # Sort by high-level to low-level
 target_link_libraries(llimage_libtest
+    ${LEGACY_STDIO_LIBS}
     ${LLCOMMON_LIBRARIES}
     ${LLVFS_LIBRARIES}
     ${LLMATH_LIBRARIES}
diff --git a/indra/integration_tests/llui_libtest/CMakeLists.txt b/indra/integration_tests/llui_libtest/CMakeLists.txt
index 34e34c7e470d632dfb7160aaee5c5d5e6047276a..1cec660eb06426fd1dbed99f18c32d48cb53b48b 100644
--- a/indra/integration_tests/llui_libtest/CMakeLists.txt
+++ b/indra/integration_tests/llui_libtest/CMakeLists.txt
@@ -75,6 +75,7 @@ endif (DARWIN)
 # Libraries on which this library depends, needed for Linux builds
 # Sort by high-level to low-level
 target_link_libraries(llui_libtest
+    ${LEGACY_STDIO_LIBS}
     llui
     llinventory
     llmessage
diff --git a/indra/llcorehttp/CMakeLists.txt b/indra/llcorehttp/CMakeLists.txt
index 9dbc6f447ec272f0fbe4d5e361a84e565ee609c0..9e9685f1cbb867d0900111ecac1adbee593bbddc 100644
--- a/indra/llcorehttp/CMakeLists.txt
+++ b/indra/llcorehttp/CMakeLists.txt
@@ -198,6 +198,7 @@ endif (DARWIN)
       )
 
   set(example_libs
+      ${LEGACY_STDIO_LIBS}
       ${LLCOREHTTP_LIBRARIES}
       ${WINDOWS_LIBRARIES}
       ${LLMESSAGE_LIBRARIES}
diff --git a/indra/llplugin/slplugin/CMakeLists.txt b/indra/llplugin/slplugin/CMakeLists.txt
index 33520ad64c25ba32900563e8d48dd14515ce9b7f..e4f64448c559bee55ac3f136d4a8be68fb3ae9f5 100644
--- a/indra/llplugin/slplugin/CMakeLists.txt
+++ b/indra/llplugin/slplugin/CMakeLists.txt
@@ -63,6 +63,7 @@ set_target_properties(SLPlugin
 endif ()
 
 target_link_libraries(SLPlugin
+  ${LEGACY_STDIO_LIBS}
   ${LLPLUGIN_LIBRARIES}
   ${LLMESSAGE_LIBRARIES}
   ${LLCOMMON_LIBRARIES}
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 2ad969a705b0404ba8fb52dfc52047ed0119d96c..0ba3b0756615e7eedfd581d2beca132d71544a1b 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -1977,11 +1977,8 @@ endif (WINDOWS)
 # dumped into the target binary and runtime lookup will find the most
 # modern version.
 
-if (WINDOWS)
-      list(INSERT PNG_PRELOAD_ARCHIVES 0 legacy_stdio_definitions)
-endif (WINDOWS)
-
 target_link_libraries(${VIEWER_BINARY_NAME}
+    ${LEGACY_STDIO_LIBS}
     ${PNG_PRELOAD_ARCHIVES}
     ${ZLIB_PRELOAD_ARCHIVES}
     ${URIPARSER_PRELOAD_ARCHIVES}
diff --git a/indra/test/CMakeLists.txt b/indra/test/CMakeLists.txt
index 4187076030a0f3a386380c31b609ade57a92570e..0f14862cbae39ca8fe4b21d4a919ca2f4f6322ee 100644
--- a/indra/test/CMakeLists.txt
+++ b/indra/test/CMakeLists.txt
@@ -83,6 +83,7 @@ list(APPEND test_SOURCE_FILES ${test_HEADER_FILES})
 add_executable(lltest ${test_SOURCE_FILES})
 
 target_link_libraries(lltest
+    ${LEGACY_STDIO_LIBS}
     ${LLDATABASE_LIBRARIES}
     ${LLINVENTORY_LIBRARIES}
     ${LLMESSAGE_LIBRARIES}
diff --git a/indra/win_crash_logger/CMakeLists.txt b/indra/win_crash_logger/CMakeLists.txt
index 1c3479bf69d15b9fdce30657ae5f0ea938ae1c10..1b038c26b58a34be16eb9c547771697493bdf5f7 100644
--- a/indra/win_crash_logger/CMakeLists.txt
+++ b/indra/win_crash_logger/CMakeLists.txt
@@ -72,7 +72,9 @@ find_library(DXGUID_LIBRARY dxguid ${DIRECTX_LIBRARY_DIR})
 
 add_executable(windows-crash-logger WIN32 ${win_crash_logger_SOURCE_FILES})
 
+
 target_link_libraries(windows-crash-logger
+    ${LEGACY_STDIO_LIBS}
     ${BREAKPAD_EXCEPTION_HANDLER_LIBRARIES}
     ${LLCRASHLOGGER_LIBRARIES}
     ${LLWINDOW_LIBRARIES}