Skip to content

Commit

Permalink
Print built/system information
Browse files Browse the repository at this point in the history
  • Loading branch information
gkv311 committed Jan 4, 2025
1 parent 10a16fd commit fdb0edf
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ find_package (OpenGL REQUIRED)

set (USED_SRCFILES "wglinfo.cpp")
set (USED_RCFILE "")
set (USED_MANFILES "")
if (WIN32)
set (USED_RCFILE "wglinfo.rc")
set (USED_MANFILES "wglinfo.manifest")
endif()

# main project target
add_executable (${PROJECT_NAME}
${USED_SRCFILES} ${USED_RCFILE}
${USED_SRCFILES} ${USED_RCFILE} ${USED_MANFILES}
)
if (WIN32)
target_link_libraries (${PROJECT_NAME} PRIVATE gdi32 user32)
Expand Down
74 changes: 74 additions & 0 deletions wglinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,81 @@ static int actual_main (int theNbArgs, const char** theArgVec)
return 0;
}

//! Returns the CPU architecture used to build the program (may not match the system).
static const char* getArchString()
{
#if defined(__amd64) || defined(__x86_64) || defined(_M_AMD64)
return "x86_64";
#elif defined(__i386) || defined(_M_IX86) || defined(__X86__)|| defined(_X86_)
return "x86";
#elif defined(__aarch64__) && defined(__LP64__)
return "AArch64 64-bit";
#elif defined(__arm__) || defined(__arm64__)
#if defined(__ARM_ARCH_7A__)
return "ARMv7-A 32-bit";
#elif defined(__ARM_ARCH_7R__)
return "ARMv7-R 32-bit";
#elif defined(__ARM_ARCH_7M__)
return "ARMv7-M 32-bit";
#elif defined(__LP64__)
return "ARM 64-bit";
#else
return "ARM 32-bit";
#endif
#else
return "UNKNOWN";
#endif
}

//! Print build and system information.
static void printSystemInfo()
{
std::cout << "wglinfo " << getArchString() << " (built with ";
#if defined(__INTEL_COMPILER)
std::cout << "Intel " << __INTEL_COMPILER << "";
#elif defined(__BORLANDC__)
std::cout << "Borland C++";
#elif defined(__clang__)
std::cout << "Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
#elif defined(_MSC_VER)
#if _MSC_VER < 1900
std::cout << "MS Visual C++ " << int(_MSC_VER/100-6) << "." << int((_MSC_VER/10)-60-10*(int)(_MSC_VER/100-6));
#else
std::cout << "MS Visual C++ " << int(_MSC_VER/100-5) << "." << int((_MSC_VER/10)-50-10*(int)(_MSC_VER/100-5));
#endif
#elif defined(__GNUC__)
std::cout << "GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << "";
#else
std::cout << "unrecognized";
#endif

#if defined(__MINGW64__)
std::cout << "; MinGW64 " << __MINGW64_VERSION_MAJOR << "." << __MINGW64_VERSION_MINOR;
#elif defined(__MINGW32__)
std::cout << "; MinGW32 " << __MINGW32_MAJOR_VERSION << "." << __MINGW32_MINOR_VERSION;
#endif
std::cout << ")";

// suppress GetVersionExW is deprecated warning
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4996)
#endif
OSVERSIONINFOEXA aVerInfo; ZeroMemory(&aVerInfo, sizeof(aVerInfo));
aVerInfo.dwOSVersionInfoSize = sizeof(aVerInfo);
if (GetVersionExA((OSVERSIONINFOA* )&aVerInfo))
{
std::cout << " running on Windows " << aVerInfo.dwMajorVersion << "." << aVerInfo.dwMinorVersion << " [" << aVerInfo.dwBuildNumber << "]";
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif

std::cout << "\n\n";
}

int main(int argc, const char** argv)
{
printSystemInfo();
return actual_main(argc, argv);
}
22 changes: 22 additions & 0 deletions wglinfo.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>True/PM</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 and Windows 11 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
</application>
</compatibility>
</assembly>
5 changes: 5 additions & 0 deletions wglinfo.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include <windows.h>

#ifdef __GNUC__
// legacy syntax for MinGW
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "wglinfo.manifest"
#endif

VS_VERSION_INFO VERSIONINFO
FILEVERSION 22, 3, 0, 0
PRODUCTVERSION 22, 3, 0, 0
Expand Down

0 comments on commit fdb0edf

Please sign in to comment.