From 9ef1e13bcccd46c822ee813017601781bbe9a43d Mon Sep 17 00:00:00 2001 From: KWSys Upstream Date: Thu, 30 May 2019 09:29:16 -0400 Subject: KWSys 2019-05-30 (f892bacf) Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit f892bacf6c563b1f6fb843ffb623b434bc2ded4f (master). Upstream Shortlog ----------------- Zsolt Parragi (1): 887b1da5 Fixing issues when building with clang 8.0 on Windows --- CMakeLists.txt | 12 ++++++++++-- ProcessWin32.c | 23 ++++++++++++++++++----- SystemInformation.cxx | 9 ++++++++- SystemTools.cxx | 9 ++++++++- testConsoleBuf.cxx | 9 ++++++++- 5 files changed, 52 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 120b5de..79e813e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,14 @@ SET_PROPERTY(DIRECTORY if(KWSYS_CXX_STANDARD) set(CMAKE_CXX_STANDARD "${KWSYS_CXX_STANDARD}") elseif(NOT DEFINED CMAKE_CXX_STANDARD AND NOT DEFINED KWSYS_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 11) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC" + AND "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU" + ) + set(CMAKE_CXX_STANDARD 14) + else() + set(CMAKE_CXX_STANDARD 11) + endif() endif() # Select library components. @@ -1005,7 +1012,8 @@ ENDIF() ADD_DEFINITIONS("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}") # Disable deprecation warnings for standard C functions. -IF(MSVC OR (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel")) +IF(MSVC OR (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "Intel" OR + (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")))) ADD_DEFINITIONS( -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE diff --git a/ProcessWin32.c b/ProcessWin32.c index 2a2e737..68c5218 100644 --- a/ProcessWin32.c +++ b/ProcessWin32.c @@ -117,7 +117,6 @@ static kwsysProcessTime kwsysProcessTimeAdd(kwsysProcessTime in1, kwsysProcessTime in2); static kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1, kwsysProcessTime in2); -static void kwsysProcessSetExitException(kwsysProcess* cp, int code); static void kwsysProcessSetExitExceptionByIndex(kwsysProcess* cp, int code, int idx); static void kwsysProcessKillTree(int pid); @@ -358,13 +357,20 @@ kwsysProcess* kwsysProcess_New(void) # pragma warning(push) # ifdef __INTEL_COMPILER # pragma warning(disable : 1478) +# elif defined __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" # else # pragma warning(disable : 4996) # endif #endif GetVersionEx(&osv); #ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx -# pragma warning(pop) +# ifdef __clang__ +# pragma clang diagnostic pop +# else +# pragma warning(pop) +# endif #endif if (osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { /* Win9x no longer supported. */ @@ -2269,13 +2275,20 @@ static kwsysProcess_List* kwsysProcess_List_New(void) # pragma warning(push) # ifdef __INTEL_COMPILER # pragma warning(disable : 1478) +# elif defined __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" # else # pragma warning(disable : 4996) # endif #endif GetVersionEx(&osv); #ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx -# pragma warning(pop) +# ifdef __clang__ +# pragma clang diagnostic pop +# else +# pragma warning(pop) +# endif #endif self->NT4 = (osv.dwPlatformId == VER_PLATFORM_WIN32_NT && osv.dwMajorVersion < 5) ? 1 @@ -2659,8 +2672,8 @@ static int kwsysProcessesAdd(HANDLE hProcess, DWORD dwProcessid, newSize = kwsysProcesses.Size ? kwsysProcesses.Size * 2 : 4; /* Try allocating the new block of memory. */ - if (newArray = (kwsysProcessInstance*)malloc( - newSize * sizeof(kwsysProcessInstance))) { + if ((newArray = (kwsysProcessInstance*)malloc( + newSize * sizeof(kwsysProcessInstance)))) { /* Copy the old process handles to the new memory. */ if (kwsysProcesses.Count > 0) { memcpy(newArray, kwsysProcesses.Processes, diff --git a/SystemInformation.cxx b/SystemInformation.cxx index 7b697c4..7dc6cf4 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -5205,6 +5205,9 @@ bool SystemInformationImplementation::QueryOSInformation() # pragma warning(push) # ifdef __INTEL_COMPILER # pragma warning(disable : 1478) +# elif defined __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" # else # pragma warning(disable : 4996) # endif @@ -5217,7 +5220,11 @@ bool SystemInformationImplementation::QueryOSInformation() } } # ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx -# pragma warning(pop) +# ifdef __clang__ +# pragma clang diagnostic pop +# else +# pragma warning(pop) +# endif # endif switch (osvi.dwPlatformId) { diff --git a/SystemTools.cxx b/SystemTools.cxx index e756cdc..2135913 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -4366,6 +4366,9 @@ std::string SystemTools::GetOperatingSystemNameAndVersion() # pragma warning(push) # ifdef __INTEL_COMPILER # pragma warning(disable : 1478) +# elif defined __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" # else # pragma warning(disable : 4996) # endif @@ -4375,7 +4378,11 @@ std::string SystemTools::GetOperatingSystemNameAndVersion() return 0; } # ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx -# pragma warning(pop) +# ifdef __clang__ +# pragma clang diagnostic pop +# else +# pragma warning(pop) +# endif # endif switch (osvi.dwPlatformId) { diff --git a/testConsoleBuf.cxx b/testConsoleBuf.cxx index 1549440..b6ad118 100644 --- a/testConsoleBuf.cxx +++ b/testConsoleBuf.cxx @@ -499,6 +499,9 @@ static int testConsole() # pragma warning(push) # ifdef __INTEL_COMPILER # pragma warning(disable : 1478) +# elif defined __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" # else # pragma warning(disable : 4996) # endif @@ -506,7 +509,11 @@ static int testConsole() const bool isVistaOrGreater = LOBYTE(LOWORD(GetVersion())) >= HIBYTE(_WIN32_WINNT_VISTA); # ifdef KWSYS_WINDOWS_DEPRECATED_GetVersion -# pragma warning(pop) +# ifdef __clang__ +# pragma clang diagnostic pop +# else +# pragma warning(pop) +# endif # endif if (!isVistaOrGreater) { if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Console", 0, KEY_READ | KEY_WRITE, -- cgit v0.12