From 20cd73b2384fd69df7d37fd4b76118149564fadb Mon Sep 17 00:00:00 2001 From: Lawrin Novitsky Date: Mon, 8 Jun 2020 13:54:09 +0200 Subject: [PATCH] ODBC-285 binarry tarballs were "tarbombing" users CPACK_ARCHIVE_COMPONENT_INSTALL set to ON happened to be the reason. From now on, bintars will have directories tree under mariadb-connector-odbc-- - basically it will match file name. Fixed some typos. --- CMakeLists.txt | 13 ++-- cmake/install.cmake | 152 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+), 6 deletions(-) create mode 100644 cmake/install.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f87d93a6..6b4f9998 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,8 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/ma_odbc_version.h.in CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/maodbcu.rc.in ${CMAKE_SOURCE_DIR}/maodbcu.rc) +INCLUDE("${CMAKE_SOURCE_DIR}/cmake/install.cmake") + SET (MARIADB_ODBC_SOURCES odbc_3_api.c ma_error.c ma_connection.c @@ -100,7 +102,7 @@ ELSE() ENDIF() MESSAGE(STATUS "Libraries installation dir: ${INSTALL_LIB_SUFFIX}") SET(INSTALL_PLUGINDIR "${INSTALL_LIB_SUFFIX}/mariadb/plugin") - MESSAGE(STATUS "Autentication Plugins installation dir: ${INSTALL_PLUGINDIR}") + MESSAGE(STATUS "Authentication Plugins installation dir: ${INSTALL_PLUGINDIR}") ENDIF() IF(WIN32 OR WITH_OPENSSL OR "${WITH_SSL}" STREQUAL "OPENSSL") @@ -261,7 +263,6 @@ ENDIF() SET(CPACK_PACKAGE_VERSION ${MARIADB_ODBC_VERSION_MAJOR}.${MARIADB_ODBC_VERSION_MINOR}.${MARIADB_ODBC_VERSION_PATCH}) -SET(CPACK_ARCHIVE_COMPONENT_INSTALL ON) SET(CPACK_COMPONENTS_ALL ClientPlugins ODBCLibs Documentation) #SET(CPACK_COMPONENTS_ALL ODBCLibs Documentation) SET(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1) @@ -367,17 +368,17 @@ ELSE() ENDIF() INSTALL(TARGETS ${LIBRARY_NAME} - LIBRARY DESTINATION ./${INSTALL_LIB_SUFFIX} + LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT ODBCLibs) IF(NOT DEFINED INSTALL_DOC_DIR) - SET(INSTALL_DOC_DIR "./share/doc/${CPACK_PACKAGE_NAME}/" CACHE STRING "Directory, where to install documentation(README)") + SET(INSTALL_DOC_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${CPACK_PACKAGE_NAME}/" CACHE STRING "Directory, where to install documentation(README)") ENDIF() IF(NOT DEFINED INSTALL_LICENSE_DIR) - SET(INSTALL_LICENSE_DIR "./share/doc/${CPACK_PACKAGE_NAME}/" CACHE STRING "Directory, where to install license file") + SET(INSTALL_LICENSE_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${CPACK_PACKAGE_NAME}/" CACHE STRING "Directory, where to install license file") ENDIF() - MESSAGE(STATUS "Documetnation installed to ${INSTALL_DOC_DIR}") + MESSAGE(STATUS "Documentation installed to ${INSTALL_DOC_DIR}") MESSAGE(STATUS "License file installed to ${INSTALL_LICENSE_DIR}") INSTALL(FILES diff --git a/cmake/install.cmake b/cmake/install.cmake new file mode 100644 index 00000000..a44df3bb --- /dev/null +++ b/cmake/install.cmake @@ -0,0 +1,152 @@ +# +# Copyright (C) 2013-2016 MariaDB Corporation AB +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the COPYING-CMAKE-SCRIPTS file. +# + +# +# This file contains settings for the following layouts: +# +# - RPM +# Built with default prefix=/usr +# +# +# The following va+riables are used and can be overwritten +# +# INSTALL_LAYOUT installation layout (DEFAULT = standard for tar.gz and zip packages +# RPM packages +# +# INSTALL_BINDIR location of binaries (mariadb_config) +# INSTALL_LIBDIR location of libraries +# INSTALL_PLUGINDIR location of plugins + +IF(NOT INSTALL_LAYOUT) + SET(INSTALL_LAYOUT "DEFAULT") +ENDIF() + +SET(INSTALL_LAYOUT ${INSTALL_LAYOUT} CACHE + STRING "Installation layout. Currently supported options are DEFAULT (tar.gz and zip), RPM and DEB") + +# On Windows we only provide zip and .msi. Latter one uses a different packager. +IF(UNIX) + IF(INSTALL_LAYOUT MATCHES "RPM") + SET(libmariadb_prefix "/usr") + ELSEIF(INSTALL_LAYOUT MATCHES "DEFAULT|DEB") + SET(libmariadb_prefix ${CMAKE_INSTALL_PREFIX}) + ENDIF() +ENDIF() + +IF(CMAKE_DEFAULT_PREFIX_INITIALIZED_BY_DEFAULT) + SET(CMAKE_DEFAULT_PREFIX ${libmariadb_prefix} CACHE PATH "Installation prefix" FORCE) +ENDIF() + +# check if the specified installation layout is valid +SET(VALID_INSTALL_LAYOUTS "DEFAULT" "RPM" "DEB") +LIST(FIND VALID_INSTALL_LAYOUTS "${INSTALL_LAYOUT}" layout_no) +IF(layout_no EQUAL -1) + MESSAGE(FATAL_ERROR "Invalid installation layout ${INSTALL_LAYOUT}. Please specify one of the following layouts: ${VALID_INSTALL_LAYOUTS}") +ENDIF() + + + +# +# Todo: We don't generate man pages yet, will fix it +# later (webhelp to man transformation) +# + +# +# DEFAULT layout +# + +SET(INSTALL_BINDIR_DEFAULT "bin") +SET(INSTALL_LIBDIR_DEFAULT "lib/mariadb") +SET(INSTALL_PCDIR_DEFAULT "lib/pkgconfig") +SET(INSTALL_INCLUDEDIR_DEFAULT "include/mariadb") +SET(INSTALL_DOCDIR_DEFAULT "docs") +IF(NOT IS_SUBPROJECT) + SET(INSTALL_PLUGINDIR_DEFAULT "lib/mariadb/plugin") +ELSE() +ENDIF() +SET(LIBMARIADB_STATIC_DEFAULT "mariadbclient") +# +# RPM layout +# +SET(INSTALL_BINDIR_RPM "bin") +IF((CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le" OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "s390x") AND CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(INSTALL_LIBDIR_RPM "lib64/mariadb") + SET(INSTALL_PCDIR_RPM "lib64/pkgconfig") + SET(INSTALL_PLUGINDIR_RPM "lib64/mariadb/plugin") +ELSE() + SET(INSTALL_LIBDIR_RPM "lib/mariadb") + SET(INSTALL_PCDIR_RPM "lib/pkgconfig") + SET(INSTALL_PLUGINDIR_RPM "lib/mariadb/plugin") +ENDIF() +SET(INSTALL_INCLUDEDIR_RPM "include") +SET(INSTALL_DOCDIR_RPM "docs") +SET(LIBMARIADB_STATIC_RPM "mariadbclient") + +# +# DEB layout +# +SET(INSTALL_BINDIR_DEB "bin") +SET(INSTALL_LIBDIR_DEB "lib/${CMAKE_LIBRARY_ARCHITECTURE}") +SET(INSTALL_PCDIR_DEB "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig") +SET(INSTALL_PLUGINDIR_DEB "${INSTALL_LIBDIR_DEB}/libmariadb${CPACK_PACKAGE_VERSION_MAJOR}/plugin") +SET(INSTALL_INCLUDEDIR_DEB "include/mariadb") +SET(LIBMARIADB_STATIC_DEB "mariadb") + +IF(INSTALL_LAYOUT MATCHES "DEB") + SET(INSTALL_PLUGINDIR_CLIENT ${INSTALL_PLUGINDIR_DEB}) +ENDIF() + + +# +# Overwrite defaults +# +IF(INSTALL_LIBDIR) + SET(INSTALL_LIBDIR_${INSTALL_LAYOUT} ${INSTALL_LIBDIR}) +ENDIF() + +IF(INSTALL_PCDIR) + SET(INSTALL_PCDIR_${INSTALL_LAYOUT} ${INSTALL_PCDIR}) +ENDIF() + +IF(INSTALL_PLUGINDIR) + SET(INSTALL_PLUGINDIR_${INSTALL_LAYOUT} ${INSTALL_PLUGINDIR}) +ENDIF() + +# Extra INSTALL_PLUGINDIR_CLIENT that overrides any INSTALL_PLUGINDIR override +IF(INSTALL_PLUGINDIR_CLIENT) + SET(INSTALL_PLUGINDIR_${INSTALL_LAYOUT} ${INSTALL_PLUGINDIR_CLIENT}) +ENDIF() + +IF(INSTALL_INCLUDEDIR) + SET(INSTALL_INCLUDEDIR_${INSTALL_LAYOUT} ${INSTALL_INCLUDEDIR}) +ENDIF() + +IF(INSTALL_BINDIR) + SET(INSTALL_BINDIR_${INSTALL_LAYOUT} ${INSTALL_BINDIR}) +ENDIF() + +IF(NOT INSTALL_PREFIXDIR) + SET(INSTALL_PREFIXDIR_${INSTALL_LAYOUT} ${libmariadb_prefix}) +ELSE() + SET(INSTALL_PREFIXDIR_${INSTALL_LAYOUT} ${INSTALL_PREFIXDIR}) +ENDIF() + +IF(DEFINED INSTALL_SUFFIXDIR) + SET(INSTALL_SUFFIXDIR_${INSTALL_LAYOUT} ${INSTALL_SUFFIXDIR}) +ENDIF() + +FOREACH(dir "BIN" "LIB" "PC" "INCLUDE" "DOCS" "PLUGIN") + SET(INSTALL_${dir}DIR ${INSTALL_${dir}DIR_${INSTALL_LAYOUT}}) + MARK_AS_ADVANCED(INSTALL_${dir}DIR) + #MESSAGE1(INSTALL_${dir}DIR "MariaDB Connector C: INSTALL_${dir}DIR=${INSTALL_${dir}DIR}") +ENDFOREACH() + +SET(LIBMARIADB_STATIC_NAME ${LIBMARIADB_STATIC_${INSTALL_LAYOUT}}) +MARK_AS_ADVANCED(LIBMARIADB_STATIC_NAME) + +#MESSAGE1(LIBMARIADB_STATIC_NAME "MariaDB Connector C: LIBMARIADB_STATIC_NAME ${LIBMARIADB_STATIC_NAME}")