Commit 27c0d595 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Simplify embedding version info into executables with ADD_VERSION_INFO

parent c7d19dab
......@@ -62,15 +62,15 @@ ELSE()
ENDIF()
# Add macros
INCLUDE(cmake/character_sets.cmake)
INCLUDE(cmake/zlib.cmake)
INCLUDE(cmake/ssl.cmake)
INCLUDE(cmake/readline.cmake)
INCLUDE(cmake/mysql_version.cmake)
INCLUDE(cmake/libutils.cmake)
INCLUDE(cmake/dtrace.cmake)
INCLUDE(cmake/plugin.cmake)
INCLUDE(cmake/install_macros.cmake)
INCLUDE(character_sets)
INCLUDE(zlib)
INCLUDE(ssl)
INCLUDE(readline)
INCLUDE(mysql_version)
INCLUDE(libutils)
INCLUDE(dtrace)
INCLUDE(plugin)
INCLUDE(install_macros)
INCLUDE(mysql_add_executable)
# Handle options
......
......@@ -130,12 +130,12 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
ENDIF()
# If signing is required, sign executables before installing
IF(SIGNCODE)
FOREACH(target ${TARGETS})
FOREACH(target ${TARGETS})
IF(SIGNCODE)
SIGN_TARGET(${target})
ENDFOREACH()
ENDIF()
ENDIF()
ADD_VERSION_INFO(${target})
ENDFOREACH()
INSTALL(TARGETS ${TARGETS} DESTINATION ${ARG_DESTINATION})
SET(INSTALL_LOCATION ${ARG_DESTINATION} )
......
......@@ -248,9 +248,6 @@ MACRO(MERGE_LIBRARIES)
ENDFOREACH()
ENDIF()
CREATE_EXPORT_FILE(SRC ${TARGET} "${ARG_EXPORTS}")
IF(WIN32 AND NOT ARG_NOINSTALL)
ADD_VERSION_INFO(${TARGET} VFT_DLL SRC )
ENDIF()
ADD_LIBRARY(${TARGET} ${LIBTYPE} ${SRC})
TARGET_LINK_LIBRARIES(${TARGET} ${LIBS})
IF(ARG_OUTPUT_NAME)
......
......@@ -37,53 +37,10 @@ FUNCTION (MYSQL_ADD_EXECUTABLE)
LIST(REMOVE_AT ARG_DEFAULT_ARGS 0)
SET(sources ${ARG_DEFAULT_ARGS})
IF(WIN32)
ADD_VERSION_INFO(${target} VFT_APP sources)
ENDIF()
ADD_EXECUTABLE(${target} ${ARG_WIN32} ${ARG_MACOSX_BUNDLE} ${ARG_EXCLUDE_FROM_ALL} ${sources})
# tell CPack where to install
IF(NOT ARG_EXCLUDE_FROM_ALL)
MYSQL_INSTALL_TARGETS(${target} DESTINATION bin)
ENDIF()
ENDFUNCTION()
# 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
MACRO(ADD_VERSION_INFO target filetype sources)
SET(HAVE_RC_FILE)
FOREACH(src ${sources})
IF("${src}" MATCHES "\\.rc$")
SET(HAVE_RC_FILE 1)
BREAK()
ENDIF()
ENDFOREACH()
IF(NOT HAVE_RC_FILE)
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()
SET(FILETYPE ${filetype})
SET(INTERNALNAME ${target})
IF(FILETYPE STREQUAL VFT_APP)
SET(ORIGINALFILENAME ${target}.exe)
ELSE()
SET(ORIGINALFILENAME ${target}.dll)
ENDIF()
SET(FILEDESCRIPTION ${target})
FIND_FILE(VERINFO_IN versioninfo.rc.in ${CMAKE_MODULE_PATH})
IF(NOT VERINFO_IN)
MESSAGE(FATAL_ERROR "cannot find version info template")
ENDIF()
CONFIGURE_FILE(${VERINFO_IN}
${CMAKE_CURRENT_BINARY_DIR}/${target}.rc)
LIST(APPEND ${sources} ${CMAKE_CURRENT_BINARY_DIR}/${target}.rc)
ENDIF()
ENDMACRO()
\ No newline at end of file
ENDFUNCTION()
\ No newline at end of file
......@@ -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()
......@@ -127,10 +127,8 @@ MACRO(MYSQL_ADD_PLUGIN)
SET(ARG_MODULE_OUTPUT_NAME "${target}")
ENDIF()
ENDIF()
IF(WIN32)
ADD_VERSION_INFO(${ARG_MODULE_OUTPUT_NAME} VFT_DLL SOURCES)
ENDIF()
ADD_LIBRARY(${target} MODULE ${SOURCES})
ADD_LIBRARY(${target} MODULE ${SOURCES})
DTRACE_INSTRUMENT(${target})
SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX ""
COMPILE_DEFINITIONS "MYSQL_DYNAMIC_PLUGIN")
......
......@@ -12,10 +12,8 @@ BEGIN
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", "@FILEDESCRIPTION@\0"
VALUE "FileVersion", "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH@.0\0"
VALUE "InternalName", "@INTERNALNAME@\0"
VALUE "OriginalFilename", "@ORIGINALFILENAME@\0"
VALUE "ProductVersion", "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH@.0\0"
END
END
BLOCK "VarFileInfo"
......
......@@ -103,13 +103,14 @@ MYSQL_ADD_EXECUTABLE(mysqld ${MYSQLD_SOURCE})
IF(NOT WITHOUT_DYNAMIC_PLUGINS)
SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE)
GET_TARGET_PROPERTY(mysqld_link_flags mysqld LINK_FLAGS)
IF (MINGW OR CYGWIN)
SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "-Wl,--export-all-symbols")
SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "{mysqld_link_flags} -Wl,--export-all-symbols")
ENDIF()
IF(MSVC)
# Set module definition file. Also use non-incremental linker,
# incremental appears to crash from time to time,if used with /DEF option
SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "/DEF:mysqld.def /INCREMENTAL:NO")
SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "${mysqld_link_flags} /DEF:mysqld.def /INCREMENTAL:NO")
FOREACH (CORELIB sql mysys dbug strings)
GET_TARGET_PROPERTY(LOC ${CORELIB} LOCATION)
......
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