summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-11-01 12:00:19 +0000
committerKitware Robot <kwrobot@kitware.com>2017-11-01 08:00:45 -0400
commitac1d19029119c32c67da555a892e9948b29eb067 (patch)
tree9a7fd9afa984f3c44377d88d434a8def97f807ce
parent93cd33310351d6e42b5287815b98b841585ac0ca (diff)
parent5b9da05b7acc27ce40d27afcda0029284a0a4590 (diff)
downloadcmake-ac1d19029119c32c67da555a892e9948b29eb067.tar.gz
Merge topic 'windows-embed-cmake-version'
5b9da05b Windows: Embed version information into CMake binaries Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1412
-rw-r--r--Source/CMakeLists.txt13
-rw-r--r--Source/CMakeVersion.rc.in34
2 files changed, 47 insertions, 0 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index e1c34bf25a..f15dff85bb 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -1057,6 +1057,19 @@ endif()
include (${CMake_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
include (${CMake_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
+if(WIN32)
+ # Add Windows executable version information.
+ configure_file("CMakeVersion.rc.in" "CMakeVersion.rc" @ONLY)
+
+ # We use a separate object library for this to work around a limitation of
+ # MinGW's windres tool with spaces in the path to the include directories.
+ add_library(CMakeVersion OBJECT "${CMAKE_CURRENT_BINARY_DIR}/CMakeVersion.rc")
+ set_property(TARGET CMakeVersion PROPERTY INCLUDE_DIRECTORIES "")
+ foreach(_tool ${_tools})
+ target_sources(${_tool} PRIVATE $<TARGET_OBJECTS:CMakeVersion>)
+ endforeach()
+endif()
+
# Install tools
foreach(_tool ${_tools})
diff --git a/Source/CMakeVersion.rc.in b/Source/CMakeVersion.rc.in
new file mode 100644
index 0000000000..f4ca3d5dc8
--- /dev/null
+++ b/Source/CMakeVersion.rc.in
@@ -0,0 +1,34 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#define VER_FILEVERSION @CMake_VERSION_MAJOR@,@CMake_VERSION_MINOR@,@CMake_VERSION_PATCH@
+#define VER_FILEVERSION_STR "@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@.@CMake_VERSION_PATCH@\0"
+
+#define VER_PRODUCTVERSION @CMake_VERSION_MAJOR@,@CMake_VERSION_MINOR@,@CMake_VERSION_PATCH@
+#define VER_PRODUCTVERSION_STR "@CMake_VERSION@\0"
+
+VS_VERSION_INFO VERSIONINFO
+FILEVERSION VER_FILEVERSION
+PRODUCTVERSION VER_PRODUCTVERSION
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904E4"
+ BEGIN
+ VALUE "FileVersion", VER_FILEVERSION_STR
+ VALUE "ProductVersion", VER_PRODUCTVERSION_STR
+ END
+ END
+
+ BLOCK "VarFileInfo"
+ BEGIN
+ /* The following line should only be modified for localized versions. */
+ /* It consists of any number of WORD,WORD pairs, with each pair */
+ /* describing a language,codepage combination supported by the file. */
+ /* */
+ /* For example, a file might have values "0x409,1252" indicating that it */
+ /* supports English language (0x409) in the Windows ANSI codepage (1252). */
+
+ VALUE "Translation", 0x409, 1252
+ END
+END