summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-06-15 14:02:38 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-06-15 14:02:56 (GMT)
commit65834d04a21c93e5eaaa7256e386aabd36699041 (patch)
treee5e310a47e080d273d4cb65d418949bdfbe78ce2
parenta0ba798e428af3cd2643c3f8905f351378239972 (diff)
parent871adefce97246ec42a157f62e39855b434c523d (diff)
downloadCMake-65834d04a21c93e5eaaa7256e386aabd36699041.zip
CMake-65834d04a21c93e5eaaa7256e386aabd36699041.tar.gz
CMake-65834d04a21c93e5eaaa7256e386aabd36699041.tar.bz2
Merge topic 'libuv-restore-fmode'
871adefc cmake: Fix default file translate mode when using libuv Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !963
-rw-r--r--Source/cmakemain.cxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 6e65955..c5a6836 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -27,6 +27,10 @@
#include <vector>
#ifdef CMAKE_USE_LIBUV
+#ifdef _WIN32
+#include <fcntl.h> /* _O_TEXT */
+#include <stdlib.h> /* _set_fmode, _fmode */
+#endif
#include "cm_uv.h"
#endif
@@ -168,6 +172,18 @@ int main(int ac, char const* const* av)
ac = args.argc();
av = args.argv();
+#if defined(CMAKE_USE_LIBUV) && defined(_WIN32)
+ // Perform libuv one-time initialization now, and then un-do its
+ // global _fmode setting so that using libuv does not change the
+ // default file text/binary mode. See libuv issue 840.
+ uv_loop_close(uv_default_loop());
+#ifdef _MSC_VER
+ _set_fmode(_O_TEXT);
+#else
+ _fmode = _O_TEXT;
+#endif
+#endif
+
cmSystemTools::EnableMSVCDebugHook();
cmSystemTools::FindCMakeResources(av[0]);
if (ac > 1) {