Commit 833be37d authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Add version resource to windows executables

parent 1f6bfeed
...@@ -19,4 +19,5 @@ EXTRA_DIST = \ ...@@ -19,4 +19,5 @@ EXTRA_DIST = \
stack_direction.c \ stack_direction.c \
do_abi_check.cmake \ do_abi_check.cmake \
merge_archives_unix.cmake.in \ merge_archives_unix.cmake.in \
dtrace_prelink.cmake dtrace_prelink.cmake \
versioninfo.rc.in
...@@ -134,6 +134,12 @@ FUNCTION(MYSQL_INSTALL_TARGETS) ...@@ -134,6 +134,12 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
IF(WIN32)
FOREACH(target ${TARGETS})
EMBED_VERSION_INFO(${target})
ENDFOREACH()
ENDIF()
INSTALL(TARGETS ${TARGETS} DESTINATION ${ARG_DESTINATION}) INSTALL(TARGETS ${TARGETS} DESTINATION ${ARG_DESTINATION})
SET(INSTALL_LOCATION ${ARG_DESTINATION} ) SET(INSTALL_LOCATION ${ARG_DESTINATION} )
INSTALL_DEBUG_SYMBOLS("${TARGETS}") INSTALL_DEBUG_SYMBOLS("${TARGETS}")
......
...@@ -125,10 +125,11 @@ IF(NOT CPACK_PACKAGE_FILE_NAME) ...@@ -125,10 +125,11 @@ IF(NOT CPACK_PACKAGE_FILE_NAME)
SET(CPACK_PACKAGE_FILE_NAME ${package_name}) SET(CPACK_PACKAGE_FILE_NAME ${package_name})
ENDIF() ENDIF()
IF(NOT CPACK_SOURCE_PACKAGE_FILE_NAME) IF(NOT CPACK_SOURCE_PACKAGE_FILE_NAME)
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mysql-${VERSION}") SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mysql-${VERSION}")
ENDIF() ENDIF()
SET(CPACK_PACKAGE_VENDOR "Sun Microsystems") SET(CPACK_PACKAGE_VENDOR "Sun Microsystems, Inc")
SET(CPACK_SOURCE_GENERATOR "TGZ") SET(CPACK_SOURCE_GENERATOR "TGZ")
SET(CPACK_SOURCE_IGNORE_FILES SET(CPACK_SOURCE_IGNORE_FILES
\\\\.bzr/ \\\\.bzr/
...@@ -136,7 +137,78 @@ SET(CPACK_SOURCE_IGNORE_FILES ...@@ -136,7 +137,78 @@ SET(CPACK_SOURCE_IGNORE_FILES
.bzrignore .bzrignore
CMakeCache.txt CMakeCache.txt
/CMakeFiles/ /CMakeFiles/
/version_resources/
/_CPack_Packages/ /_CPack_Packages/
$.gz $.gz
$.zip $.zip
) )
# Defintions for windows version resources
SET(PRODUCTNAME "MySQL Server")
SET(COMPANYNAME ${CPACK_PACKAGE_VENDOR})
# Function to embed version info into executables/dlls on Windows
# Refer http://msdn.microsoft.com/en-us/library/aa381058(VS.85).aspx
# for more information
FUNCTION(EMBED_VERSION_INFO target)
IF(NOT WIN32)
RETURN()
ENDIF()
IF(NOT CMAKE_RC_COMPILER)
RETURN()
ENDIF()
GET_TARGET_PROPERTY(target_type ${target} TYPE)
IF(target_type MATCHES "STATIC")
RETURN()
ENDIF()
IF(TARGET_TYPE MATCHES "EXE")
SET(FILETYPE VFT_APP)
ELSE()
SET(FILETYPE VFT_DLL)
ENDIF()
IF(NOT MAJOR_VERSION)
MESSAGE(FATAL_ERROR "MAJOR_VERSION is not defined")
ENDIF()
IF(NOT MINOR_VERSION)
MESSAGE(FATAL_ERROR "MINOR_VERSION is not defined")
ENDIF()
IF(NOT PATCH)
SET(PATCH 0)
ENDIF()
GET_TARGET_PROPERTY(target_location ${target} LOCATION)
GET_FILENAME_COMPONENT(INTERNALNAME ${target_location} NAME_WE)
IF(NOT FILEDESCRIPTION)
SET(FILEDESCRIPTION ${INTERNALNAME})
ENDIF()
GET_FILENAME_COMPONENT(ORIGINALFILENAME ${target_location} NAME)
# Directory where we have resouce script and compiled .res file
SET(RES_DIR ${CMAKE_CURRENT_BINARY_DIR}/version_resources)
# Create resource script (.rc)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/versioninfo.rc.in
${RES_DIR}/${target}_versioninfo.rc)
# Compile resource script to object if required
IF(EXISTS ${RES_DIR}/${target}_versioninfo.res)
IF(${RES_DIR}/${target}_versioninfo.rc IS_NEWER_THAN
${RES_DIR}/${target}_versioninfo.res)
SET(RUN_RC 1)
ENDIF()
ELSE()
SET(RUN_RC 1)
ENDIF()
IF(RUN_RC)
# Run resource compiler
EXECUTE_PROCESS(
COMMAND ${CMAKE_RC_COMPILER} /nologo /fo ${target}_versioninfo.res
${target}_versioninfo.rc
WORKING_DIRECTORY ${RES_DIR}
)
ENDIF()
TARGET_LINK_LIBRARIES(${target} ${RES_DIR}/${target}_versioninfo.res)
ENDFUNCTION()
#include <windows.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@PATCH@,0
PRODUCTVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@PATCH@,0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS__WINDOWS32
FILETYPE @FILETYPE@
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", "@FILEDESCRIPTION@\0"
VALUE "FileVersion", "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH@\0"
VALUE "InternalName", "@INTERNALNAME@\0"
VALUE "OriginalFilename", "@ORIGINALFILENAME@\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment