From c8e32a8331f5c658647e5c0aa480adbb9a059f7c Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 17 Mar 2010 19:56:22 +0100 Subject: [PATCH] Bug #52149 - packaging differences in CMake build Corrected some packaging bugs: - install mysqlservices library - install libmysqlclient_r.so.{16,16.0.0} as links to libmysqlclient.so - install libmysqld-debug.a - install my_safe_process, my_safe_kill and symlinks to mysql-test-run.pl (mtr, mysql-test-run) into correct place ${INSTALL_MYSQLTESTDIR} cmake/install_layout.cmake: Fix typo cmake/install_macros.cmake: Refactor INSTALL_SYMLINK to allow arbitrary symlink paths. Old version of this macro would make link extension the same as in target. This was not sufficient in some scenarios (would not allow for example libmysqlclient_r.so.16=>./libmysqlclient.so link) libmysql/CMakeLists.txt: Install extra symlinks to libmysqlclient.so (libmysqlclient_r.so.16 and libmysqlclient_r.so.16.0.0) for backward compatiblity. libmysqld/CMakeLists.txt: install libmysqld-debug.a libservices/CMakeLists.txt: install mysqlservices library mysql-test/lib/My/SafeProcess/CMakeLists.txt: install my_safe_process, my_safe_kill into correct place --- cmake/install_layout.cmake | 2 +- cmake/install_macros.cmake | 15 +++++----- libmysql/CMakeLists.txt | 29 +++++++++++++++++--- libmysqld/CMakeLists.txt | 5 ++++ libservices/CMakeLists.txt | 1 + mysql-test/CMakeLists.txt | 3 +- mysql-test/lib/My/SafeProcess/CMakeLists.txt | 4 +-- 7 files changed, 43 insertions(+), 16 deletions(-) diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake index 92eebebd4e2..2d8c218a293 100755 --- a/cmake/install_layout.cmake +++ b/cmake/install_layout.cmake @@ -111,7 +111,7 @@ ENDIF() # Clear cached variables if install layout was changed IF(OLD_INSTALL_LAYOUT) - IF(NOT OLD_INSTALL_LAYOUT STREQUAL INSTALL_LAYOUR) + IF(NOT OLD_INSTALL_LAYOUT STREQUAL INSTALL_LAYOUT) SET(FORCE FORCE) ENDIF() ENDIF() diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake index 1dcf8b5ca21..73da532ecf6 100644 --- a/cmake/install_macros.cmake +++ b/cmake/install_macros.cmake @@ -43,27 +43,26 @@ ENDMACRO() # Install symbolic link to CMake target. # the link is created in the same directory as target # and extension will be the same as for target file. -MACRO(INSTALL_SYMLINK linkbasename target destination) +MACRO(INSTALL_SYMLINK linkname target destination) IF(UNIX) GET_TARGET_PROPERTY(location ${target} LOCATION) GET_FILENAME_COMPONENT(path ${location} PATH) - GET_FILENAME_COMPONENT(name_we ${location} NAME_WE) - GET_FILENAME_COMPONENT(ext ${location} EXT) - SET(output ${path}/${linkbasename}${ext}) + GET_FILENAME_COMPONENT(name ${location} NAME) + SET(output ${path}/${linkname}) ADD_CUSTOM_COMMAND( OUTPUT ${output} COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${output} COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink - ${name_we}${ext} - ${linkbasename}${ext} + ${name} + ${linkname} WORKING_DIRECTORY ${path} DEPENDS ${target} ) - ADD_CUSTOM_TARGET(symlink_${linkbasename}${ext} + ADD_CUSTOM_TARGET(symlink_${linkname} ALL DEPENDS ${output}) - SET_TARGET_PROPERTIES(symlink_${linkbasename}${ext} PROPERTIES CLEAN_DIRECT_OUTPUT 1) + SET_TARGET_PROPERTIES(symlink_${linkname} PROPERTIES CLEAN_DIRECT_OUTPUT 1) IF(CMAKE_GENERATOR MATCHES "Xcode") # For Xcode, replace project config with install config STRING(REPLACE "${CMAKE_CFG_INTDIR}" diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index f9fc5355641..26af9c80a2b 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -153,15 +153,26 @@ SET(LIBS clientlib dbug strings vio mysys ${ZLIB_LIBRARY} ${SSL_LIBRARIES}) # Merge several convenience libraries into one big mysqlclient # and link them together into shared library. MERGE_LIBRARIES(mysqlclient STATIC ${LIBS}) -IF(UNIX) - INSTALL_SYMLINK(${CMAKE_STATIC_LIBRARY_PREFIX}mysqlclient_r mysqlclient ${INSTALL_LIBDIR}) -ENDIF() # Visual Studio users need debug static library for debug projects IF(MSVC) INSTALL_DEBUG_TARGET(mysqlclient DESTINATION ${INSTALL_LIBDIR}/debug) ENDIF() +IF(UNIX) + MACRO(GET_VERSIONED_LIBNAME LIBNAME EXTENSION VERSION OUTNAME) + SET(DOT_VERSION ".${VERSION}") + IF(DOT_VERSION STREQUAL ".") + SET(DOT_VERSION "") + ENDIF() + IF(APPLE) + SET(${OUTNAME} ${LIBNAME}${DOT_VERSION}${EXTENSION}) + ELSE() + SET(${OUTNAME} ${LIBNAME}${EXTENSION}${DOT_VERSION}) + ENDIF() + ENDMACRO() +ENDIF() + IF(NOT DISABLE_SHARED) MERGE_LIBRARIES(libmysql SHARED ${LIBS} EXPORTS ${CLIENT_API_FUNCTIONS}) IF(UNIX) @@ -182,6 +193,16 @@ IF(NOT DISABLE_SHARED) #(mysqlclient in this case) SET_TARGET_PROPERTIES(mysqlclient PROPERTIES CLEAN_DIRECT_OUTPUT 1) SET_TARGET_PROPERTIES(libmysql PROPERTIES CLEAN_DIRECT_OUTPUT 1) - INSTALL_SYMLINK(${CMAKE_SHARED_LIBRARY_PREFIX}mysqlclient_r libmysql ${INSTALL_LIBDIR}) + + # Install 3 links to libmysqlclient.so (client_r) + FOREACH(ver "" "${SHARED_LIB_MAJOR_VERSION}" + "${SHARED_LIB_MAJOR_VERSION}.0.0") + GET_VERSIONED_LIBNAME( + "${CMAKE_SHARED_LIBRARY_PREFIX}mysqlclient_r" + "${CMAKE_SHARED_LIBRARY_SUFFIX}" + "${ver}" + linkname) + INSTALL_SYMLINK(${linkname} libmysql ${INSTALL_LIBDIR}) + ENDFOREACH() ENDIF() ENDIF() diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index e5f2a8b56f9..26332cab61b 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -131,6 +131,11 @@ IF(MSVC) INSTALL_DEBUG_TARGET(mysqlserver DESTINATION ${INSTALL_LIBDIR}/debug) ENDIF() +IF(UNIX) + INSTALL_DEBUG_TARGET(mysqlserver DESTINATION ${INSTALL_LIBDIR} RENAME + ${CMAKE_STATIC_LIBRARY_PREFIX}/mysqld-debug) +ENDIF() + IF(MSVC AND NOT DISABLE_SHARED) MERGE_LIBRARIES(libmysqld SHARED ${LIBS} EXPORTS ${CLIENT_API_FUNCTIONS}) ENDIF() diff --git a/libservices/CMakeLists.txt b/libservices/CMakeLists.txt index ddfa2495ade..da84368b46c 100644 --- a/libservices/CMakeLists.txt +++ b/libservices/CMakeLists.txt @@ -18,3 +18,4 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) SET(MYSQLSERVICES_SOURCES my_snprintf_service.c thd_alloc_service.c) ADD_LIBRARY(mysqlservices ${MYSQLSERVICES_SOURCES}) +INSTALL(TARGETS mysqlservices DESTINATION ${INSTALL_LIBDIR}) diff --git a/mysql-test/CMakeLists.txt b/mysql-test/CMakeLists.txt index 2cc65a9c82f..b8b7d08135f 100644 --- a/mysql-test/CMakeLists.txt +++ b/mysql-test/CMakeLists.txt @@ -46,7 +46,8 @@ IF(UNIX) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mtr - ${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run DESTINATION mysql-test) + ${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run + DESTINATION ${INSTALL_MYSQLTESTDIR}) ENDIF() IF(CMAKE_GENERATOR MATCHES "Visual Studio") diff --git a/mysql-test/lib/My/SafeProcess/CMakeLists.txt b/mysql-test/lib/My/SafeProcess/CMakeLists.txt index ec2a13b910c..893e6d896be 100644 --- a/mysql-test/lib/My/SafeProcess/CMakeLists.txt +++ b/mysql-test/lib/My/SafeProcess/CMakeLists.txt @@ -20,8 +20,8 @@ ELSE() ADD_EXECUTABLE(my_safe_process safe_process.cc) ENDIF() -INSTALL(TARGETS my_safe_process DESTINATION "mysql-test/lib/My/SafeProcess") +INSTALL(TARGETS my_safe_process DESTINATION "${INSTALL_MYSQLTESTDIR}/lib/My/SafeProcess") IF(WIN32) - INSTALL(TARGETS my_safe_kill DESTINATION "mysql-test/lib/My/SafeProcess") + INSTALL(TARGETS my_safe_kill DESTINATION "${INSTALL_MYSQLTESTDIR}/lib/My/SafeProcess") ENDIF() INSTALL(FILES safe_process.pl Base.pm DESTINATION "${INSTALL_MYSQLTESTDIR}/lib/My/SafeProcess")