From 80e795dc9744281e4f04fe626e52e66313347ea6 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Sat, 15 Aug 2020 15:56:07 -0700 Subject: [PATCH] Added version info to meshconvert logo output --- CMakeLists.txt | 2 +- Meshconvert/Meshconvert.cpp | 29 ++++++++++++++++++-- Meshconvert/Meshconvert_Desktop_2017.vcxproj | 12 ++++---- Meshconvert/Meshconvert_Desktop_2019.vcxproj | 12 ++++---- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0effd1d2..620df4a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,7 @@ add_executable(meshconvert Meshconvert/Mesh.cpp Meshconvert/SDKMesh.h) target_include_directories(meshconvert PUBLIC MeshConvert Utilities) -target_link_libraries(meshconvert ${PROJECT_NAME}) +target_link_libraries(meshconvert ${PROJECT_NAME} version.lib) source_group(meshconvert REGULAR_EXPRESSION meshconvert/*.*) if(MSVC) diff --git a/Meshconvert/Meshconvert.cpp b/Meshconvert/Meshconvert.cpp index 6225df70..63fdfbe5 100644 --- a/Meshconvert/Meshconvert.cpp +++ b/Meshconvert/Meshconvert.cpp @@ -284,7 +284,33 @@ namespace void PrintLogo() { - wprintf(L"Microsoft (R) MeshConvert Command-line Tool\n"); + wchar_t version[32] = {}; + + wchar_t appName[_MAX_PATH] = {}; + if (GetModuleFileNameW(nullptr, appName, _countof(appName))) + { + DWORD size = GetFileVersionInfoSizeW(appName, nullptr); + if (size > 0) + { + auto verInfo = std::make_unique(size); + if (GetFileVersionInfoW(appName, 0, size, verInfo.get())) + { + LPVOID lpstr = nullptr; + UINT strLen = 0; + if (VerQueryValueW(verInfo.get(), L"\\StringFileInfo\\040904B0\\ProductVersion", &lpstr, &strLen)) + { + wcsncpy_s(version, reinterpret_cast(lpstr), strLen); + } + } + } + } + + if (!*version || wcscmp(version, L"1.0.0.0") == 0) + { + swprintf_s(version, L"%03d (library)", DIRECTX_MESH_VERSION); + } + + wprintf(L"Microsoft (R) MeshConvert Command-line Tool Version %ls\n", version); wprintf(L"Copyright (C) Microsoft Corp. All rights reserved.\n"); #ifdef _DEBUG wprintf(L"*** Debug build ***\n"); @@ -292,7 +318,6 @@ namespace wprintf(L"\n"); } - void PrintUsage() { PrintLogo(); diff --git a/Meshconvert/Meshconvert_Desktop_2017.vcxproj b/Meshconvert/Meshconvert_Desktop_2017.vcxproj index 60aaf12e..3a9b5b7f 100644 --- a/Meshconvert/Meshconvert_Desktop_2017.vcxproj +++ b/Meshconvert/Meshconvert_Desktop_2017.vcxproj @@ -140,7 +140,7 @@ /Zc:__cplusplus %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) Console true true @@ -171,7 +171,7 @@ /Zc:__cplusplus %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) Console true @@ -201,7 +201,7 @@ /Zc:__cplusplus %(AdditionalOptions) - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) true Console true @@ -233,7 +233,7 @@ /Zc:__cplusplus %(AdditionalOptions) - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) true Console true @@ -265,7 +265,7 @@ /Zc:__cplusplus %(AdditionalOptions) - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) true Console true @@ -297,7 +297,7 @@ /Zc:__cplusplus %(AdditionalOptions) - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) true Console true diff --git a/Meshconvert/Meshconvert_Desktop_2019.vcxproj b/Meshconvert/Meshconvert_Desktop_2019.vcxproj index b753d110..a79cd95c 100644 --- a/Meshconvert/Meshconvert_Desktop_2019.vcxproj +++ b/Meshconvert/Meshconvert_Desktop_2019.vcxproj @@ -141,7 +141,7 @@ 26812 - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) Console true true @@ -173,7 +173,7 @@ 26812 - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) Console true @@ -204,7 +204,7 @@ 26812 - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) true Console true @@ -237,7 +237,7 @@ 26812 - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) true Console true @@ -270,7 +270,7 @@ 26812 - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) true Console true @@ -303,7 +303,7 @@ 26812 - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) true Console true