From 8085114c35072860cc346c2cef3db119a7520d75 Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Fri, 4 Nov 2022 08:45:20 -0400 Subject: [PATCH] File Versioning (Windows) (#72) --- CMakeLists.txt | 6 ++++ src/CMakeLists.txt | 6 +++- src/installer.wxs | 2 +- src/quicreach.cpp | 4 +-- src/quicreach.rc | 12 ++++++++ src/quicreach.ver | 77 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 src/quicreach.rc create mode 100644 src/quicreach.ver diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a632669..5ce92015 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,12 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # outside the build tree to the install RPATH. set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +if (WIN32) + # Statically link the OS included part of the runtime. + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") +endif() + # Configure and build msquic dependency. if (WIN32) set(QUIC_TLS "schannel" CACHE STRING "TLS Library to use") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index efbd37d3..fbbe66e2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,11 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -add_executable(quicreach quicreach.cpp) +if (WIN32) + add_executable(quicreach quicreach.cpp quicreach.rc) +else() + add_executable(quicreach quicreach.cpp) +endif() target_link_libraries(quicreach PRIVATE inc warnings msquic) if (NOT BUILD_SHARED_LIBS) target_link_libraries(quicreach PRIVATE base_link) diff --git a/src/installer.wxs b/src/installer.wxs index 8ffdba3f..92ff9bd9 100644 --- a/src/installer.wxs +++ b/src/installer.wxs @@ -5,7 +5,7 @@ Manufacturer="Microsoft" Name="quicreach" UpgradeCode="8395c163-ac9f-4a89-82fc-689fe25f0777" - Version="1.1.1.0"> + Version="1.2.0.0"> diff --git a/src/quicreach.cpp b/src/quicreach.cpp index ec9ebdf7..0307bc54 100644 --- a/src/quicreach.cpp +++ b/src/quicreach.cpp @@ -7,6 +7,7 @@ #define _CRT_SECURE_NO_WARNINGS 1 #define QUIC_API_ENABLE_PREVIEW_FEATURES 1 +#define QUICREACH_VERSION_ONLY 1 #include #include @@ -14,10 +15,9 @@ #include #include #include +#include "quicreach.ver" #include "domains.hpp" -#define QUICREACH_VERSION "1.1.0" - #ifdef _WIN32 #define QUIC_CALL __cdecl #else diff --git a/src/quicreach.rc b/src/quicreach.rc new file mode 100644 index 00000000..d6436847 --- /dev/null +++ b/src/quicreach.rc @@ -0,0 +1,12 @@ +// +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +// + +#include + +#define VER_FILETYPE VFT_APP +#define VER_FILESUBTYPE VFT2_UNKNOWN +#define VER_ORIGINALFILENAME_STR "quicreach.exe" + +#include "quicreach.ver" diff --git a/src/quicreach.ver b/src/quicreach.ver new file mode 100644 index 00000000..ab4c9b51 --- /dev/null +++ b/src/quicreach.ver @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +// + +#ifndef VER_MAJOR +#define VER_MAJOR 1 +#endif + +#ifndef VER_MINOR +#define VER_MINOR 2 +#endif + +#ifndef VER_PATCH +#define VER_PATCH 0 +#endif + +#ifndef VER_BUILD_ID +#define VER_BUILD_ID 0 +#endif + +#ifndef VER_GIT_HASH +#define VER_GIT_HASH_STR "Unknown" +#else +#define STR_HELPER_GIT_VER(x) #x +#define STR_GIT_VER(x) STR_HELPER_GIT_VER(x) +#define VER_GIT_HASH_STR STR_GIT_VER(VER_GIT_HASH) +#endif + +#define STR_HELPER(x) #x +#define STR(x) STR_HELPER(x) + +#define QUICREACH_VERSION STR(VER_MAJOR) "." STR(VER_MINOR) "." STR(VER_PATCH) "." STR(VER_BUILD_ID) + +#ifndef QUICREACH_VERSION_ONLY + +#define VER_COMPANYNAME_STR "Microsoft Corporation" +#define VER_FILEDESCRIPTION_STR "Microsoft\256 QUIC Library" +#define VER_INTERNALNAME_STR "quicreach" +#define VER_LEGALCOPYRIGHT_STR "\251 Microsoft Corporation. All rights reserved." +#define VER_PRODUCTNAME_STR "Microsoft\256 QUIC" + +#define VER_FILEVERSION VER_MAJOR,VER_MINOR,VER_PATCH,0 +#define VER_FILEVERSION_STR QUICREACH_VERSION "\0" +#define VER_PRODUCTVERSION_STR QUICREACH_VERSION "\0" + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VER_FILEVERSION +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS 0 +FILEOS VOS_NT_WINDOWS32 +FILETYPE VER_FILETYPE +FILESUBTYPE VER_FILESUBTYPE + +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", VER_COMPANYNAME_STR + VALUE "FileDescription", VER_FILEDESCRIPTION_STR + VALUE "FileVersion", VER_FILEVERSION_STR + VALUE "InternalName", VER_INTERNALNAME_STR + VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR + VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR + VALUE "ProductName", VER_PRODUCTNAME_STR + VALUE "ProductVersion", VER_PRODUCTVERSION_STR + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x04B0 + END +END + +#endif // QUICREACH_VERSION_ONLY