Commit 36fffdea authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Bug#58074: ADD_VERSION_INFO cmake/mysql_version.cmake fails if LINK_FLAGS are modified

Backport version info handling  (Windows-specific) from next-mr. 
Instead of adding ".res" object as linker flag, add  resource file (.rc) file to the source list.
This is more obvious and less error prone method.
parent 5a8b8b64
......@@ -224,8 +224,6 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
IF(SIGNCODE AND SIGNCODE_ENABLED)
SIGN_TARGET(${target})
ENDIF()
# For Windows, add version info to executables
ADD_VERSION_INFO(${target})
# Install man pages on Unix
IF(UNIX)
GET_TARGET_PROPERTY(target_location ${target} LOCATION)
......
......@@ -250,6 +250,9 @@ MACRO(MERGE_LIBRARIES)
ENDFOREACH()
ENDIF()
CREATE_EXPORT_FILE(SRC ${TARGET} "${ARG_EXPORTS}")
IF(NOT ARG_NOINSTALL)
ADD_VERSION_INFO(${TARGET} SHARED SRC)
ENDIF()
ADD_LIBRARY(${TARGET} ${LIBTYPE} ${SRC})
TARGET_LINK_LIBRARIES(${TARGET} ${LIBS})
IF(ARG_OUTPUT_NAME)
......
......@@ -37,7 +37,7 @@ FUNCTION (MYSQL_ADD_EXECUTABLE)
LIST(REMOVE_AT ARG_DEFAULT_ARGS 0)
SET(sources ${ARG_DEFAULT_ARGS})
ADD_VERSION_INFO(${target} EXECUTABLE sources)
ADD_EXECUTABLE(${target} ${ARG_WIN32} ${ARG_MACOSX_BUNDLE} ${ARG_EXCLUDE_FROM_ALL} ${sources})
# tell CPack where to install
IF(NOT ARG_EXCLUDE_FROM_ALL)
......
......@@ -133,9 +133,8 @@ ENDIF()
# 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)
......@@ -143,31 +142,14 @@ IF(MSVC)
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\"")
FUNCTION(ADD_VERSION_INFO target target_type sources_var)
IF("${target_type}" MATCHES "SHARED" OR "${target_type}" MATCHES "MODULE")
SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_dll.rc)
ELSEIF("${target_type}" MATCHES "EXE")
SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_exe.rc)
ENDIF()
SET(${sources_var} ${${sources_var}} ${rcfile} PARENT_SCOPE)
ENDFUNCTION()
ELSE()
FUNCTION(ADD_VERSION_INFO)
......
......@@ -151,6 +151,7 @@ MACRO(MYSQL_ADD_PLUGIN)
ENDIF()
ENDIF()
ADD_VERSION_INFO(${target} MODULE SOURCES)
ADD_LIBRARY(${target} MODULE ${SOURCES})
DTRACE_INSTRUMENT(${target})
SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX ""
......
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