1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

KWSys 2025-03-01 (1d82baee)

Code extracted from:

    https://gitlab.kitware.com/utils/kwsys.git

at commit 1d82baee88db598a77d9b1a07f7a5fb9b1860f83 (master).

Upstream Shortlog
-----------------

leha-bot (1):
      1079929c Status: Fix encoding of error strings on Windows
This commit is contained in:
KWSys Upstream
2025-03-01 10:05:10 -05:00
committed by Brad King
parent 7cd4048b3a
commit 25ea535aba
2 changed files with 9 additions and 4 deletions

View File

@@ -173,6 +173,9 @@ if(KWSYS_USE_Process)
set(KWSYS_USE_System 1)
set(KWSYS_USE_Encoding 1)
endif()
if(KWSYS_USE_Status)
set(KWSYS_USE_Encoding 1)
endif()
if(KWSYS_USE_SystemInformation)
set(KWSYS_USE_Process 1)
endif()

View File

@@ -2,10 +2,12 @@
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#include "kwsysPrivate.h"
#include KWSYS_HEADER(Status.hxx)
#include KWSYS_HEADER(Encoding.hxx)
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
# include "Encoding.hxx.in"
# include "Status.hxx.in"
#endif
@@ -43,13 +45,13 @@ std::string Status::GetString() const
break;
#ifdef _WIN32
case Kind::Windows: {
LPSTR message = NULL;
DWORD size = FormatMessageA(
LPWSTR message = NULL;
DWORD size = FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, this->Windows_, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&message, 0, NULL);
err = std::string(message, size);
(LPWSTR)&message, 0, NULL);
err = kwsys::Encoding::ToNarrow(message);
LocalFree(message);
} break;
#endif