diff options
| author | Vladislav Vaintroub <vvaintroub@mysql.com> | 2009-12-18 23:53:30 +0100 |
|---|---|---|
| committer | Vladislav Vaintroub <vvaintroub@mysql.com> | 2009-12-18 23:53:30 +0100 |
| commit | 94c6c01e6cba1245e91666a20a2eb410f801d1f4 (patch) | |
| tree | 5bd743311c627949ab06195560ba2e8fc844d41c | |
| parent | 20685d1c6de6ced6092953741797583d3699a9b4 (diff) | |
| download | mariadb-git-94c6c01e6cba1245e91666a20a2eb410f801d1f4.tar.gz | |
Simplify embedding version info into executables with ADD_VERSION_INFO
| -rwxr-xr-x | CMakeLists.txt | 18 | ||||
| -rw-r--r-- | cmake/install_macros.cmake | 10 | ||||
| -rw-r--r-- | cmake/libutils.cmake | 3 | ||||
| -rw-r--r-- | cmake/mysql_add_executable.cmake | 45 | ||||
| -rw-r--r-- | cmake/mysql_version.cmake | 45 | ||||
| -rw-r--r-- | cmake/plugin.cmake | 6 | ||||
| -rw-r--r-- | cmake/versioninfo.rc.in | 4 | ||||
| -rwxr-xr-x | sql/CMakeLists.txt | 5 |
8 files changed, 65 insertions, 71 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 81681dddb6e..4c1cdb94da4 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake index 7e11bdfb3ab..902b717c1d4 100644 --- a/cmake/install_macros.cmake +++ b/cmake/install_macros.cmake @@ -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} ) diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index 2d125c8a103..5198cd3a898 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -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) diff --git a/cmake/mysql_add_executable.cmake b/cmake/mysql_add_executable.cmake index 6df7c8dda33..cb0237332c2 100644 --- a/cmake/mysql_add_executable.cmake +++ b/cmake/mysql_add_executable.cmake @@ -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 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() diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index b6a55b2ede0..3e46f523973 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -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") diff --git a/cmake/versioninfo.rc.in b/cmake/versioninfo.rc.in index 9d581043a2c..97c45ec86c0 100644 --- a/cmake/versioninfo.rc.in +++ b/cmake/versioninfo.rc.in @@ -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"
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index b6f33236675..43f22903aef 100755 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -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) |
