Bug #58074 ADD_VERSION_INFO cmake/mysql_version.cmake fails if LINK_FLAGS are modified
Submitted: 9 Nov 2010 8:52 Modified: 15 Dec 2010 1:33
Reporter: Bernd Ocklin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Packaging Severity:S3 (Non-critical)
Version:mysql-5.5.5+ OS:Any
Assigned to: Vladislav Vaintroub CPU Architecture:Any
Tags: SEAGULL

[9 Nov 2010 8:52] Bernd Ocklin
Description:
ADD_VERSION_INFO cmake/mysql_version.cmake fails if LINK_FLAGS are modified. Basically it seems that APPEND in 

SET_PROPERTY(TARGET ${target} APPEND PROPERTY LINK_FLAGS
        "\"${CMAKE_BINARY_DIR}/versioninfo_dll.res\"")

is not working properly.

How to repeat:
e.g. modify LINK_FLAGS in libmysql/CMakeLists.txt

=== modified file 'libmysql/CMakeLists.txt'
--- libmysql/CMakeLists.txt	2010-06-28 12:39:45 +0000
+++ libmysql/CMakeLists.txt	2010-08-25 13:31:02 +0000
@@ -113,6 +113,8 @@
 ADD_LIBRARY(libmysql          SHARED ${CLIENT_SOURCES} dll.c libmysql.def)
 ADD_DEPENDENCIES(libmysql GenError)
 TARGET_LINK_LIBRARIES(libmysql wsock32 ws2_32)
+# workaround for http://support.microsoft.com/?scid=kb%3Ben-us%3B948127&x=7&y=15
+SET_TARGET_PROPERTIES(libmysql PROPERTIES LINK_FLAGS "/INCREMENTAL:NO")
 INSTALL_SYMLINK(${linkname} libmysql ${INSTALL_LIBDIR} COMPONENT SharedLibraries)
 MYSQL_INSTALL_TARGETS(libmysql DESTINATION ${INSTALL_LIBDIR} COMPONENT Development)

Suggested fix:
=== modified file 'storage/ndb/cmake/ndb_version.cmake'
--- storage/ndb/cmake/ndb_version.cmake	2010-08-19 15:37:04 +0000
+++ storage/ndb/cmake/ndb_version.cmake	2010-08-26 13:15:52 +0000
@@ -153,19 +153,4 @@
      ${CMAKE_BINARY_DIR}/versioninfo_dll.res
    )
   ENDIF()
-  
-  FUNCTION(ADD_VERSION_INFO target)
-    GET_TARGET_PROPERTY(target_type ${target} TYPE)
-    ADD_DEPENDENCIES(${target} gen_ndb_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()
[9 Nov 2010 14:22] Bernd Ocklin
Here is the correct patch:

diff -u ../mysql-5.5.5-m3-release/./cmake/mysql_version.cmake ./cmake/mysql_version.cmake
--- ../mysql-5.5.5-m3-release/./cmake/mysql_version.cmake	2010-06-28 18:12:23.000000000 +0200
+++ ./cmake/mysql_version.cmake	2010-10-26 12:31:53.000000000 +0200
@@ -157,13 +157,17 @@

   FUNCTION(ADD_VERSION_INFO target)
     GET_TARGET_PROPERTY(target_type ${target} TYPE)
+    GET_TARGET_PROPERTY(tmp_link_flags ${target} LINK_FLAGS)
+    IF(NOT DEFINED ${tmp_link_flags})
+      SET(tmp_link_flags "")
+    ENDIF()
     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\"")
+       SET_PROPERTY(TARGET ${target} PROPERTY LINK_FLAGS
+        "${tmp_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\"")
+      SET_PROPERTY(TARGET ${target} PROPERTY LINK_FLAGS
+      "${tmp_link_flags} ${target_link_flags} \"${CMAKE_BINARY_DIR}/versioninfo_exe.res\"")
     ENDIF()
   ENDFUNCTION()
 ELSE()
[9 Nov 2010 23:52] MySQL Verification Team
Thank you for the bug report.
[12 Nov 2010 12:43] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/123713

3120 Vladislav Vaintroub	2010-11-12
      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.
[12 Nov 2010 12:53] Vladislav Vaintroub
Bernd, I took the handling from next-mr (using source file version_info_xxx.rc rather then precompiled object version_info_xxx.res). On a reason I do not remember  (likely  an oversight), it was not in 5.5, even if it was in next-mr since April or so.
[5 Dec 2010 12:41] Bugs System
Pushed into mysql-trunk 5.6.1 (revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (version source revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (merge vers: 5.6.1) (pib:23)
[15 Dec 2010 1:33] Paul Dubois
Noted in 5.5.8 changelog.

During configuration, ADD_VERSION_INFO in cmake/mysql_version.cmake
failed if LINK_FLAGS was modified.
[16 Dec 2010 22:30] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (version source revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (merge vers: 5.5.9) (pib:24)