Skip to content

Commit

Permalink
ODBC-311 Connector/ODBC libraries go to the wrong directories and it …
Browse files Browse the repository at this point in the history
…breaks packaging

* enabled build with OpenSSL by default on UNIX
* added deb and rpm variables to set the layout accordingly
* added properly configured layout for rpm packages
* added properly configured layout for deb packages

it's not possible to hardcode all multiarch tuples on debian without
GNUInstallDirs. so, only ia32 and amd64 are in place
now, install layout is fixed and project can be built/tested on other systems
(not deb and not rpm)
  • Loading branch information
abychko authored and lawrinn committed Jun 11, 2021
1 parent 3c0611e commit 8ce387a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 39 deletions.
43 changes: 16 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# ************************************************************************************
# Copyright (C) 2013,2019 MariaDB Corporation AB
#
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not see <http://www.gnu.org/licenses>
# or write to the Free Software Foundation, Inc.,
# or write to the Free Software Foundation, Inc.,
# 51 Franklin St., Fifth Floor, Boston, MA 02110, USA
# *************************************************************************************/
PROJECT(mariadb_connector_odbc C)
Expand All @@ -34,7 +34,7 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/maodbcu.rc.in
${CMAKE_SOURCE_DIR}/maodbcu.rc)

SET (MARIADB_ODBC_SOURCES odbc_3_api.c
ma_api_internal.c
ma_api_internal.c
ma_error.c
ma_connection.c
ma_helper.c
Expand Down Expand Up @@ -70,7 +70,7 @@ MACRO(ADD_OPTION _name _text _default)
ENDIF()
ENDMACRO()

# This has to be before C/C's cmake run, or it will build with /MD
# This has to be before C/C's cmake run, or it will build with /MD
IF(WIN32)
IF (MSVC)
SET(CONFIG_TYPES "DEBUG" "RELEASE" "RELWITHDEBINFO" "MINSIZEREL")
Expand All @@ -83,28 +83,20 @@ IF(WIN32)
SET(COMPILER_FLAGS "${COMPILER_FLAGS} /RTC1 /RTCc")
STRING(REPLACE "/Zi" "/ZI" COMPILER_FLAGS ${COMPILER_FLAGS})
ENDIF()
MESSAGE (STATUS "CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}= ${COMPILER_FLAGS}")
SET(CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE} ${COMPILER_FLAGS} CACHE
MESSAGE (STATUS "CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}= ${COMPILER_FLAGS}")
SET(CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE} ${COMPILER_FLAGS} CACHE
STRING "overwritten by mariadb-odbc" FORCE)
ENDIF()
ENDFOREACH()
ENDFOREACH()
ENDIF()
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)# -DWIN32_LEAN_AND_MEAN)
SET(INSTALL_PLUGINDIR "${MARIADB_DEFAULT_PLUGINS_SUBDIR}")
ELSE()
# This has been done before C/C cmake scripts are included
IF(NOT DEFINED INSTALL_LIB_SUFFIX)
SET(INSTALL_LIB_SUFFIX "lib" CACHE STRING "Directory, under which to install libraries, e.g. lib or lib64")
IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8" AND EXISTS "/usr/lib64/")
SET(INSTALL_LIB_SUFFIX "lib64")
ENDIF()
ENDIF()
MESSAGE(STATUS "Libraries installation dir: ${INSTALL_LIB_SUFFIX}")
SET(INSTALL_PLUGINDIR "${INSTALL_LIB_SUFFIX}/mariadb/plugin")
MESSAGE(STATUS "Authentication Plugins installation dir: ${INSTALL_PLUGINDIR}")
ENDIF()

### Setting installation paths - should go before C/C subproject sets its own. We need to have control over those
INCLUDE("${CMAKE_SOURCE_DIR}/cmake/install.cmake")

IF(WIN32 OR WITH_OPENSSL OR "${WITH_SSL}" STREQUAL "OPENSSL")
IF(WITH_OPENSSL OR "${WITH_SSL}" STREQUAL "OPENSSL")
FIND_PACKAGE(OpenSSL)
Expand Down Expand Up @@ -144,9 +136,6 @@ ENDIF()

ADD_OPTION(WITH_UNIT_TESTS "build test suite" ON)

### Setting installation paths - should go before C/C subproject sets its own. We need to have control over those
INCLUDE("${CMAKE_SOURCE_DIR}/cmake/install.cmake")

# Currently limiting this feature to Windows onle, where it's most probably going to be only used
IF(WIN32 AND ALL_PLUGINS_STATIC)
SET(CLIENT_PLUGIN_AUTH_GSSAPI_CLIENT "STATIC")
Expand Down Expand Up @@ -231,9 +220,9 @@ IF(WIN32)

SET(PLATFORM_DEPENDENCIES ws2_32 Shlwapi Pathcch)
IF (MSVC)
MESSAGE(STATUS "MSVC_VERSION= ${MSVC_VERSION}")
MESSAGE(STATUS "MSVC_VERSION= ${MSVC_VERSION}")
IF (NOT(MSVC_VERSION LESS 1900))
MESSAGE(STATUS "Configuring to link connector against legacy_stdio_definitions")
MESSAGE(STATUS "Configuring to link connector against legacy_stdio_definitions")
SET(LEGACY_STDIO legacy_stdio_definitions)
SET(PLATFORM_DEPENDENCIES ${PLATFORM_DEPENDENCIES} ${LEGACY_STDIO})
ENDIF()
Expand All @@ -255,7 +244,7 @@ ENDIF()
IF(NOT WIN32)
# Looking for DM(UnixODBC) files
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/FindDM.cmake)

IF(DM_FOUND)
INCLUDE_DIRECTORIES(${ODBC_INCLUDE_DIR})
LINK_DIRECTORIES(${ODBC_LIB_DIR})
Expand All @@ -282,7 +271,7 @@ SET(CPACK_COMPONENTS_ALL ClientPlugins ODBCLibs Documentation)
SET(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)

# TODO: Make it optional
# Disable dbug information for release builds
# Disable dbug information for release builds
#SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDBUG_OFF")
#SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF")
#SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
Expand Down Expand Up @@ -328,7 +317,7 @@ IF(WIN32)
ELSE()
MESSAGE(STATUS "Version script: ${CMAKE_SOURCE_DIR}/maodbc.def")
ADD_LIBRARY(${LIBRARY_NAME} SHARED ${MARIADB_ODBC_SOURCES} maodbcu.rc)

IF(APPLE)
SET(MAODBC_INSTALL_RPATH "${ODBC_LIB_DIR}" "@loader_path" "/usr/local/opt/libiodbc" "/usr/local/iODBC/lib" "/usr/local/opt/openssl@1.1/lib" "/usr/local/opt/libressl/lib")
SET_TARGET_PROPERTIES(${LIBRARY_NAME}
Expand Down
49 changes: 37 additions & 12 deletions cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
# INSTALL_DOCDIR location of docs
# INSTALL_LICENSEDIR location of license

IF(DEB)
SET(INSTALL_LAYOUT "DEB")
ENDIF()

IF(RPM)
SET(INSTALL_LAYOUT "RPM")
ENDIF()

IF(NOT INSTALL_LAYOUT)
SET(INSTALL_LAYOUT "DEFAULT")
ENDIF()
Expand All @@ -33,9 +41,9 @@ SET(INSTALL_LAYOUT ${INSTALL_LAYOUT} CACHE

# On Windows we only provide zip and .msi. Latter one uses a different packager.
IF(UNIX)
IF(INSTALL_LAYOUT MATCHES "RPM")
IF(INSTALL_LAYOUT MATCHES "RPM|DEB")
SET(libmariadb_prefix "/usr")
ELSEIF(INSTALL_LAYOUT MATCHES "DEFAULT|DEB")
ELSEIF(INSTALL_LAYOUT STREQUAL "DEFAULT")
SET(libmariadb_prefix ${CMAKE_INSTALL_PREFIX})
ENDIF()
ENDIF()
Expand All @@ -51,7 +59,13 @@ IF(layout_no EQUAL -1)
MESSAGE(FATAL_ERROR "Invalid installation layout ${INSTALL_LAYOUT}. Please specify one of the following layouts: ${VALID_INSTALL_LAYOUTS}")
ENDIF()


# This has been done before C/C cmake scripts are included
IF(NOT DEFINED INSTALL_LIB_SUFFIX)
SET(INSTALL_LIB_SUFFIX "lib" CACHE STRING "Directory, under which to install libraries, e.g. lib or lib64")
IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8" AND EXISTS "/usr/lib64/")
SET(INSTALL_LIB_SUFFIX "lib64")
ENDIF()
ENDIF()

#
# Todo: We don't generate man pages yet, will fix it
Expand All @@ -70,9 +84,9 @@ SET(INSTALL_DOCDIR_DEFAULT "docs")
SET(INSTALL_LICENSEDIR_DEFAULT ${INSTALL_DOCDIR_DEFAULT})
IF(NOT IS_SUBPROJECT)
SET(INSTALL_PLUGINDIR_DEFAULT "lib/mariadb/plugin")
ELSE()
ENDIF()
SET(LIBMARIADB_STATIC_DEFAULT "mariadbclient")

#
# RPM layout
#
Expand All @@ -86,25 +100,31 @@ ELSE()
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(INSTALL_INCLUDEDIR_RPM "include/mariadb")
SET(INSTALL_DOCDIR_RPM "share/doc/mariadb-connector-odbc")
SET(INSTALL_LICENSEDIR_RPM ${INSTALL_DOCDIR_RPM})
SET(LIBMARIADB_STATIC_RPM "mariadbclient")

#
# DEB layout
#
# Only ia-32 and amd64 here. the list is too long to hardcode it
IF(NOT CMAKE_LIBRARY_ARCHITECTURE)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu")
ELSE()
SET(CMAKE_LIBRARY_ARCHITECTURE "i386-linux-gnu")
ENDIF()
ENDIF()

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(INSTALL_DOCDIR_DEB "share/doc/mariadb-connector-odbc")
SET(INSTALL_LICENSEDIR_DEB "${INSTALL_DOCDIR_DEB}")
SET(LIBMARIADB_STATIC_DEB "mariadb")

IF(INSTALL_LAYOUT MATCHES "DEB")
SET(INSTALL_PLUGINDIR_CLIENT ${INSTALL_PLUGINDIR_DEB})
ENDIF()


#
# Overwrite defaults
#
Expand Down Expand Up @@ -157,3 +177,8 @@ FOREACH(dir "BIN" "LIB" "PC" "INCLUDE" "DOC" "LICENSE" "PLUGIN")
MESSAGE(STATUS "MariaDB Connector ODBC: INSTALL_${dir}DIR=${INSTALL_${dir}DIR}")
ENDFOREACH()

SET(INSTALL_PLUGINDIR_CLIENT ${INSTALL_PLUGINDIR})
MESSAGE(STATUS "MariaDB Connector ODBC: INSTALL_PLUGINDIR_CLIENT=${INSTALL_PLUGINDIR_CLIENT}")

MESSAGE(STATUS "Libraries installation dir: ${INSTALL_LIBDIR}")
MESSAGE(STATUS "Authentication Plugins installation dir: ${INSTALL_PLUGINDIR}")

0 comments on commit 8ce387a

Please sign in to comment.