Tidy up uses of Windows.h by adding WindowsWrapper.hpp

This header brings in the Win32 API header, with some small modifications
applied to prevent clashes with our code. This means those modifications
don't need to be made in each place that we bring in Windows.h

Change-Id: Ie817c7a167eccbe1ac6a49d3fc940eef8b2f534d
Signed-off-by: Robert Hughes <robert.hughes@arm.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 88e813a..8f8060a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -73,6 +73,7 @@
     src/armnnUtils/TensorIOUtils.hpp
     src/armnnUtils/TensorUtils.cpp
     src/armnnUtils/Transpose.cpp
+    src/armnnUtils/WindowsWrapper.hpp
     )
 
 add_library_ex(armnnUtils STATIC ${armnnUtils_sources})
@@ -255,6 +256,7 @@
     profiling/common/include/ProfilingException.hpp
     profiling/common/include/SocketConnectionException.hpp
     profiling/common/include/Constants.hpp
+    profiling/common/include/NetworkSockets.hpp
     profiling/common/src/NetworkSockets.cpp
     src/armnn/layers/LayerCloneBase.hpp
     src/armnn/layers/LayerWithParameters.hpp
@@ -1076,6 +1078,7 @@
 
     target_include_directories(GatordMock PRIVATE profiling/common/include
                                                   profiling/server/src/basePipeServer
+                                                  src/armnnUtils
                                                   src/profiling
                                                   src/timelineDecoder)
 
diff --git a/cmake/GlobalConfig.cmake b/cmake/GlobalConfig.cmake
index 4e20cc7..6aa6321 100644
--- a/cmake/GlobalConfig.cmake
+++ b/cmake/GlobalConfig.cmake
@@ -68,7 +68,7 @@
 elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
 	# Disable C4996 (use of deprecated identifier) due to https://developercommunity.visualstudio.com/content/problem/252574/deprecated-compilation-warning-for-virtual-overrid.html
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /wd4996")
-    add_definitions(-DNOMINMAX=1 -DNO_STRICT=1)
+    add_definitions(-DNO_STRICT=1)
 endif()
 if("${CMAKE_SYSTEM_NAME}" STREQUAL Android)
     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -llog")
diff --git a/profiling/common/include/NetworkSockets.hpp b/profiling/common/include/NetworkSockets.hpp
index 7750764..de20ff1 100644
--- a/profiling/common/include/NetworkSockets.hpp
+++ b/profiling/common/include/NetworkSockets.hpp
@@ -16,6 +16,7 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #elif defined(_MSC_VER)
+#include <WindowsWrapper.hpp>
 #include <winsock2.h>
 #include <afunix.h>
 #endif
diff --git a/profiling/server/src/basePipeServer/CMakeLists.txt b/profiling/server/src/basePipeServer/CMakeLists.txt
index a2567ce..56ef454 100644
--- a/profiling/server/src/basePipeServer/CMakeLists.txt
+++ b/profiling/server/src/basePipeServer/CMakeLists.txt
@@ -24,6 +24,8 @@
     set_target_properties(armnnBasePipeServer PROPERTIES VERSION ${GENERIC_LIB_VERSION}
                           SOVERSION ${GENERIC_LIB_SOVERSION})
 
+    target_include_directories(armnnBasePipeServer PRIVATE ${PROJECT_SOURCE_DIR}/src/armnnUtils)
+
     target_link_libraries(armnnBasePipeServer armnn)
     if ("${CMAKE_SYSTEM_NAME}" STREQUAL Windows)
         target_link_libraries(armnnBasePipeServer Ws2_32.lib)
diff --git a/src/armnn/Logging.cpp b/src/armnn/Logging.cpp
index a3ca7ce..6db4afa 100644
--- a/src/armnn/Logging.cpp
+++ b/src/armnn/Logging.cpp
@@ -9,11 +9,7 @@
 #include <armnn/utility/Assert.hpp>
 
 #if defined(_MSC_VER)
-#ifndef NOMINMAX
-#define NOMINMAX // Prevent definition of min/max macros that interfere with std::min/max
-#endif
-#include <Windows.h>
-#undef TIME_MS  // Windows.h defines this but we don't need it and it interferes with our definition in Instrument.hpp
+#include <WindowsWrapper.hpp>
 #endif
 
 #if defined(__ANDROID__)
diff --git a/src/armnn/test/UnitTests.cpp b/src/armnn/test/UnitTests.cpp
index 071bff0..d66a847 100644
--- a/src/armnn/test/UnitTests.cpp
+++ b/src/armnn/test/UnitTests.cpp
@@ -24,7 +24,7 @@
 #include <boost/iostreams/filtering_stream.hpp>
 #include <boost/iostreams/tee.hpp>
 #include <iostream>
-#include <Windows.h>
+#include <WindowsWrapper.hpp>
 
 using namespace boost::iostreams;
 using namespace std;
diff --git a/src/armnnUtils/Filesystem.cpp b/src/armnnUtils/Filesystem.cpp
index 6c8175b..886d7da 100644
--- a/src/armnnUtils/Filesystem.cpp
+++ b/src/armnnUtils/Filesystem.cpp
@@ -9,8 +9,7 @@
 #include <sys/stat.h>
 #include <stdio.h>
 #elif defined(_MSC_VER)
-#define WIN32_LEAN_AND_MEAN
-#include <Windows.h>
+#include "WindowsWrapper.hpp"
 #endif
 
 namespace armnnUtils
diff --git a/src/armnnUtils/Processes.cpp b/src/armnnUtils/Processes.cpp
index 0e43e8c..6c216cf 100644
--- a/src/armnnUtils/Processes.cpp
+++ b/src/armnnUtils/Processes.cpp
@@ -8,8 +8,7 @@
 #if defined(__unix__)
 #include <unistd.h>
 #elif defined(_MSC_VER)
-#define WIN32_LEAN_AND_MEAN
-#include <Windows.h>
+#include "WindowsWrapper.hpp"
 #endif
 
 namespace armnnUtils
diff --git a/src/armnnUtils/WindowsWrapper.hpp b/src/armnnUtils/WindowsWrapper.hpp
new file mode 100644
index 0000000..7f02cb1
--- /dev/null
+++ b/src/armnnUtils/WindowsWrapper.hpp
@@ -0,0 +1,17 @@
+//
+// Copyright © 2020 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+// This header brings in the Win32 API header, with some small modifications applied to prevent clashes with our code.
+
+#if defined(_MSC_VER)
+
+#define NOMINMAX    // Prevent definition of min/max macros that interfere with std::min/max
+#define WIN32_LEAN_AND_MEAN
+#include <Windows.h>
+// Windows.h defines some names that we don't need and interfere with some of our definition
+#undef TIME_MS      // Instrument.hpp
+#undef CreateEvent  // ITimelineDecoder.hpp
+
+#endif