summaryrefslogtreecommitdiff
path: root/cmake/mysql_version.cmake
diff options
context:
space:
mode:
authorVladislav Vaintroub <vvaintroub@mysql.com>2009-12-18 23:53:30 +0100
committerVladislav Vaintroub <vvaintroub@mysql.com>2009-12-18 23:53:30 +0100
commit27c0d595e9e3a35232672209219ecc9b74004ab4 (patch)
tree5bd743311c627949ab06195560ba2e8fc844d41c /cmake/mysql_version.cmake
parentc7d19daba5987593b7cc7da7ff2f68e073d10838 (diff)
downloadmariadb-git-27c0d595e9e3a35232672209219ecc9b74004ab4.tar.gz
Simplify embedding version info into executables with ADD_VERSION_INFO
Diffstat (limited to 'cmake/mysql_version.cmake')
-rw-r--r--cmake/mysql_version.cmake45
1 files changed, 44 insertions, 1 deletions
diff --git a/cmake/mysql_version.cmake b/cmake/mysql_version.cmake
index d8677e6c3ad..6b83cb50b2d 100644
--- a/cmake/mysql_version.cmake
+++ b/cmake/mysql_version.cmake
@@ -151,4 +151,47 @@ SET(CPACK_SOURCE_IGNORE_FILES
SET(PRODUCTNAME "MySQL Server")
SET(COMPANYNAME ${CPACK_PACKAGE_VENDOR})
-
+# Add version information to the exe and dll files
+# Refer to http://msdn.microsoft.com/en-us/library/aa381058(VS.85).aspx
+# for more info.
+IF(MSVC)
+ GET_TARGET_PROPERTY(location gen_versioninfo LOCATION)
+ IF(NOT location)
+ GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
+ SET(FILETYPE VFT_APP)
+ CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in
+ ${CMAKE_BINARY_DIR}/versioninfo_exe.rc)
+
+ SET(FILETYPE VFT_DLL)
+ CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in
+ ${CMAKE_BINARY_DIR}/versioninfo_dll.rc)
+
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${CMAKE_BINARY_DIR}/versioninfo_exe.res
+ ${CMAKE_BINARY_DIR}/versioninfo_dll.res
+ COMMAND ${CMAKE_RC_COMPILER} versioninfo_exe.rc
+ COMMAND ${CMAKE_RC_COMPILER} versioninfo_dll.rc
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ )
+ ADD_CUSTOM_TARGET(gen_versioninfo
+ DEPENDS
+ ${CMAKE_BINARY_DIR}/versioninfo_exe.res
+ ${CMAKE_BINARY_DIR}/versioninfo_dll.res
+ )
+ ENDIF()
+
+ FUNCTION(ADD_VERSION_INFO target)
+ GET_TARGET_PROPERTY(target_type ${target} TYPE)
+ ADD_DEPENDENCIES(${target} gen_versioninfo)
+ IF(target_type MATCHES "SHARED" OR target_type MATCHES "MODULE")
+ SET_PROPERTY(TARGET ${target} APPEND PROPERTY LINK_FLAGS
+ "\"${CMAKE_BINARY_DIR}/versioninfo_dll.res\"")
+ ELSEIF(target_type MATCHES "EXE")
+ SET_PROPERTY(TARGET ${target} APPEND PROPERTY LINK_FLAGS
+ "${target_link_flags} \"${CMAKE_BINARY_DIR}/versioninfo_exe.res\"")
+ ENDIF()
+ ENDFUNCTION()
+ELSE()
+ FUNCTION(ADD_VERSION_INFO)
+ ENDFUNCTION()
+ENDIF()