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) ...@@ -224,8 +224,6 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
IF(SIGNCODE AND SIGNCODE_ENABLED) IF(SIGNCODE AND SIGNCODE_ENABLED)
SIGN_TARGET(${target}) SIGN_TARGET(${target})
ENDIF() ENDIF()
# For Windows, add version info to executables
ADD_VERSION_INFO(${target})
# Install man pages on Unix # Install man pages on Unix
IF(UNIX) IF(UNIX)
GET_TARGET_PROPERTY(target_location ${target} LOCATION) GET_TARGET_PROPERTY(target_location ${target} LOCATION)
......
...@@ -250,6 +250,9 @@ MACRO(MERGE_LIBRARIES) ...@@ -250,6 +250,9 @@ MACRO(MERGE_LIBRARIES)
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
CREATE_EXPORT_FILE(SRC ${TARGET} "${ARG_EXPORTS}") CREATE_EXPORT_FILE(SRC ${TARGET} "${ARG_EXPORTS}")
IF(NOT ARG_NOINSTALL)
ADD_VERSION_INFO(${TARGET} SHARED SRC)
ENDIF()
ADD_LIBRARY(${TARGET} ${LIBTYPE} ${SRC}) ADD_LIBRARY(${TARGET} ${LIBTYPE} ${SRC})
TARGET_LINK_LIBRARIES(${TARGET} ${LIBS}) TARGET_LINK_LIBRARIES(${TARGET} ${LIBS})
IF(ARG_OUTPUT_NAME) IF(ARG_OUTPUT_NAME)
......
...@@ -37,7 +37,7 @@ FUNCTION (MYSQL_ADD_EXECUTABLE) ...@@ -37,7 +37,7 @@ FUNCTION (MYSQL_ADD_EXECUTABLE)
LIST(REMOVE_AT ARG_DEFAULT_ARGS 0) LIST(REMOVE_AT ARG_DEFAULT_ARGS 0)
SET(sources ${ARG_DEFAULT_ARGS}) SET(sources ${ARG_DEFAULT_ARGS})
ADD_VERSION_INFO(${target} EXECUTABLE sources)
ADD_EXECUTABLE(${target} ${ARG_WIN32} ${ARG_MACOSX_BUNDLE} ${ARG_EXCLUDE_FROM_ALL} ${sources}) ADD_EXECUTABLE(${target} ${ARG_WIN32} ${ARG_MACOSX_BUNDLE} ${ARG_EXCLUDE_FROM_ALL} ${sources})
# tell CPack where to install # tell CPack where to install
IF(NOT ARG_EXCLUDE_FROM_ALL) IF(NOT ARG_EXCLUDE_FROM_ALL)
......
...@@ -133,9 +133,8 @@ ENDIF() ...@@ -133,9 +133,8 @@ ENDIF()
# Refer to http://msdn.microsoft.com/en-us/library/aa381058(VS.85).aspx # Refer to http://msdn.microsoft.com/en-us/library/aa381058(VS.85).aspx
# for more info. # for more info.
IF(MSVC) IF(MSVC)
GET_TARGET_PROPERTY(location gen_versioninfo LOCATION)
IF(NOT location)
GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
SET(FILETYPE VFT_APP) SET(FILETYPE VFT_APP)
CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in
${CMAKE_BINARY_DIR}/versioninfo_exe.rc) ${CMAKE_BINARY_DIR}/versioninfo_exe.rc)
...@@ -143,31 +142,14 @@ IF(MSVC) ...@@ -143,31 +142,14 @@ IF(MSVC)
SET(FILETYPE VFT_DLL) SET(FILETYPE VFT_DLL)
CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in
${CMAKE_BINARY_DIR}/versioninfo_dll.rc) ${CMAKE_BINARY_DIR}/versioninfo_dll.rc)
ADD_CUSTOM_COMMAND( FUNCTION(ADD_VERSION_INFO target target_type sources_var)
OUTPUT ${CMAKE_BINARY_DIR}/versioninfo_exe.res IF("${target_type}" MATCHES "SHARED" OR "${target_type}" MATCHES "MODULE")
${CMAKE_BINARY_DIR}/versioninfo_dll.res SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_dll.rc)
COMMAND ${CMAKE_RC_COMPILER} versioninfo_exe.rc ELSEIF("${target_type}" MATCHES "EXE")
COMMAND ${CMAKE_RC_COMPILER} versioninfo_dll.rc SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_exe.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() ENDIF()
SET(${sources_var} ${${sources_var}} ${rcfile} PARENT_SCOPE)
ENDFUNCTION() ENDFUNCTION()
ELSE() ELSE()
FUNCTION(ADD_VERSION_INFO) FUNCTION(ADD_VERSION_INFO)
......
...@@ -151,6 +151,7 @@ MACRO(MYSQL_ADD_PLUGIN) ...@@ -151,6 +151,7 @@ MACRO(MYSQL_ADD_PLUGIN)
ENDIF() ENDIF()
ENDIF() ENDIF()
ADD_VERSION_INFO(${target} MODULE SOURCES)
ADD_LIBRARY(${target} MODULE ${SOURCES}) ADD_LIBRARY(${target} MODULE ${SOURCES})
DTRACE_INSTRUMENT(${target}) DTRACE_INSTRUMENT(${target})
SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX "" 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