Cut away some trash

This commit is contained in:
Alexey Milovidov 2021-10-25 02:33:08 +03:00
parent a06a54e411
commit de7919555e

View File

@ -6,149 +6,109 @@ set(CLIENT_PLUGIN_AUTH_GSSAPI_CLIENT OFF)
set(CLIENT_PLUGIN_CLIENT_ED25519 OFF) set(CLIENT_PLUGIN_CLIENT_ED25519 OFF)
set(CLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD OFF) set(CLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD OFF)
set(SKIP_TESTS 1)
if (GLIBC_COMPATIBILITY) if (GLIBC_COMPATIBILITY)
set(LIBM glibc-compatibility) set(LIBM glibc-compatibility)
endif() endif()
if (USE_INTERNAL_ZLIB_LIBRARY)
set(ZLIB_FOUND ON)
set(ZLIB_LIBRARY ${ZLIB_LIBRARIES})
set(WITH_EXTERNAL_ZLIB ON)
endif()
# This is the LGPL libmariadb project. # This is the LGPL libmariadb project.
# Is C/C built as subproject? set(CC_SOURCE_DIR ${CMAKE_SOURCE_DIR}/contrib/mariadb-connector-c)
get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY) set(CC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
SET(CC_SOURCE_DIR ${CMAKE_SOURCE_DIR}/contrib/mariadb-connector-c) set(WITH_SSL ON)
SET(CC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
SET(WITH_SSL ON) set(MARIADB_CONNECTOR_C_COPYRIGHT "2013-2017 MariaDB Corporation Ab")
SET(MARIADB_CONNECTOR_C_COPYRIGHT "2013-2017 MariaDB Corporation Ab")
INCLUDE(${CC_SOURCE_DIR}/cmake/plugins.cmake) INCLUDE(${CC_SOURCE_DIR}/cmake/plugins.cmake)
IF(AUTH_GSSAPI_PLUGIN_TYPE MATCHES "STATIC") set(PROTOCOL_VERSION 10) # we adapted new password option from PHP's mysqlnd !
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${GSSAPI_LIBS})
ENDIF()
SET(PROTOCOL_VERSION 10) # we adapted new password option from PHP's mysqlnd !
# if C/C is build as subproject inside MariaDB server tree we will # if C/C is build as subproject inside MariaDB server tree we will
# use the version defined by server # use the version defined by server
IF(MAJOR_VERSION) if(MAJOR_VERSION)
SET(MARIADB_CLIENT_VERSION_MAJOR ${MAJOR_VERSION}) set(MARIADB_CLIENT_VERSION_MAJOR ${MAJOR_VERSION})
SET(MARIADB_CLIENT_VERSION_MINOR ${MINOR_VERSION}) set(MARIADB_CLIENT_VERSION_MINOR ${MINOR_VERSION})
SET(MARIADB_CLIENT_VERSION_PATCH ${PATCH_VERSION}) set(MARIADB_CLIENT_VERSION_PATCH ${PATCH_VERSION})
SET(MARIADB_CLIENT_VERSION_EXTRA ${EXTRA_VERSION}) set(MARIADB_CLIENT_VERSION_EXTRA ${EXTRA_VERSION})
ELSE() else()
SET(MARIADB_CLIENT_VERSION_MAJOR "10") set(MARIADB_CLIENT_VERSION_MAJOR "10")
SET(MARIADB_CLIENT_VERSION_MINOR "4") set(MARIADB_CLIENT_VERSION_MINOR "4")
SET(MARIADB_CLIENT_VERSION_PATCH "3") set(MARIADB_CLIENT_VERSION_PATCH "3")
SET(MARIADB_CLIENT_VERSION_EXTRA "") set(MARIADB_CLIENT_VERSION_EXTRA "")
ENDIF() endif()
SET(MARIADB_CLIENT_VERSION "${MARIADB_CLIENT_VERSION_MAJOR}.${MARIADB_CLIENT_VERSION_MINOR}.${MARIADB_CLIENT_VERSION_PATCH}${MARIADB_CLIENT_VERSION_EXTRA}") set(MARIADB_CLIENT_VERSION "${MARIADB_CLIENT_VERSION_MAJOR}.${MARIADB_CLIENT_VERSION_MINOR}.${MARIADB_CLIENT_VERSION_PATCH}${MARIADB_CLIENT_VERSION_EXTRA}")
SET(MARIADB_BASE_VERSION "mariadb-${MARIADB_CLIENT_VERSION_MAJOR}.${MARIADB_CLIENT_VERSION_MINOR}") set(MARIADB_BASE_VERSION "mariadb-${MARIADB_CLIENT_VERSION_MAJOR}.${MARIADB_CLIENT_VERSION_MINOR}")
MATH(EXPR MARIADB_VERSION_ID "${MARIADB_CLIENT_VERSION_MAJOR} * 10000 + MATH(EXPR MARIADB_VERSION_ID "${MARIADB_CLIENT_VERSION_MAJOR} * 10000 +
${MARIADB_CLIENT_VERSION_MINOR} * 100 + ${MARIADB_CLIENT_VERSION_MINOR} * 100 +
${MARIADB_CLIENT_VERSION_PATCH}") ${MARIADB_CLIENT_VERSION_PATCH}")
IF (NOT MARIADB_PORT) IF (NOT MARIADB_PORT)
SET(MARIADB_PORT 3306) set(MARIADB_PORT 3306)
ENDIF () ENDIF ()
IF(NOT MARIADB_UNIX_ADDR) if(NOT MARIADB_UNIX_ADDR)
SET(MARIADB_UNIX_ADDR "/tmp/mysql.sock") set(MARIADB_UNIX_ADDR "/tmp/mysql.sock")
ENDIF() endif()
INCLUDE(${CC_SOURCE_DIR}/cmake/SearchLibrary.cmake) set(HAVE_ALLOCA_H 1)
set(HAVE_ARPA_INET_H 1)
set(HAVE_DLFCN_H 1)
set(HAVE_FCNTL_H 1)
set(HAVE_FLOAT_H 1)
set(HAVE_LIMITS_H 1)
set(HAVE_PWD_H 1)
set(HAVE_SCHED_H 1)
set(HAVE_SELECT_H 0)
set(INCLUDE_SIGNAL 1)
set(HAVE_SIGNAL 1)
set(HAVE_STDDEF_H 1)
set(HAVE_STDINT_H 1)
set(HAVE_STDLIB_H 1)
set(HAVE_STRING_H 1)
set(HAVE_STRINGS_H 1)
set(HAVE_SYS_IOCTL_H 1)
set(HAVE_SYS_SELECT_H 1)
set(HAVE_SYS_SOCKET_H 1)
set(HAVE_SYS_TYPES_H 1)
set(HAVE_SYS_UN_H 1)
set(HAVE_UNISTD_H 1)
set(HAVE_UTIME_H 1)
set(HAVE_UCONTEXT_H 1)
set(HAVE_ALLOCA 1)
set(HAVE_DLERROR 0)
set(HAVE_DLOPEN 0)
set(HAVE_FCNTL 1)
set(HAVE_MEMCPY 1)
set(HAVE_NL_LANGINFO 0)
set(HAVE_SETLOCALE 0)
set(HAVE_POLL 1)
IF(WITH_EXTERNAL_ZLIB) set(SIZEOF_CHARP 8)
IF(NOT ZLIB_FOUND) set(SIZEOF_INT 4)
FIND_PACKAGE(ZLIB) set(SIZEOF_LONG 8)
ENDIF() set(SIZEOF_LONG_LONG 8)
IF(ZLIB_FOUND) set(SIZEOF_SIZE_T 8)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) set(SOCKET_SIZE_TYPE socklen_t)
SET(LIBZ ${ZLIB_LIBRARY})
ENDIF()
ENDIF()
# check for various include files set(SYSTEM_LIBS ${SYSTEM_LIBS} zlib)
INCLUDE(${CC_SOURCE_DIR}/cmake/CheckIncludeFiles.cmake)
# check for various functions
INCLUDE(${CC_SOURCE_DIR}/cmake/CheckFunctions.cmake)
# check for various types
INCLUDE(${CC_SOURCE_DIR}/cmake/CheckTypes.cmake)
IF(UNIX) if(CMAKE_HAVE_PTHREAD_H)
SEARCH_LIBRARY(LIBNSL gethostbyname_r "nsl_r;nsl") set(CMAKE_REQUIRED_INCLUDES pthread.h)
SEARCH_LIBRARY(LIBSOCKET setsockopt socket) endif()
FIND_PACKAGE(Threads)
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${LIBNSL} ${LIBBIND} ${LIBICONV} ${LIBZ} ${LIBSOCKET})
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${LIBNSL} ${LIBBIND} ${LIBICONV} ${LIBZ} ${LIBSOCKET})
#remove possible dups from required libraries
LIST(LENGTH CMAKE_REQUIRED_LIBRARIES rllength)
IF(${rllength} GREATER 0)
LIST(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES)
ENDIF()
ENDIF()
add_definitions(-DMARIADB_SYSTEM_TYPE="${CMAKE_SYSTEM_NAME}")
add_definitions(-DMARIADB_MACHINE_TYPE="${CMAKE_SYSTEM_PROCESSOR}")
IF(CMAKE_HAVE_PTHREAD_H) set(HAVE_THREADS 1)
SET(CMAKE_REQUIRED_INCLUDES pthread.h) set(DEFAULT_CHARSET "utf8mb4")
ENDIF()
ADD_DEFINITIONS(-DMARIADB_SYSTEM_TYPE="${CMAKE_SYSTEM_NAME}") add_definitions(-DHAVE_OPENSSL -DHAVE_TLS)
ADD_DEFINITIONS(-DMARIADB_MACHINE_TYPE="${CMAKE_SYSTEM_PROCESSOR}") set(SSL_SOURCES "${CC_SOURCE_DIR}/libmariadb/secure/openssl.c")
set(SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
include_directories(BEFORE ${OPENSSL_INCLUDE_DIR})
set(TLS_LIBRARY_VERSION "OpenSSL ${OPENSSL_VERSION}")
SET(HAVE_THREADS 1) set(ENABLED_LOCAL_INFILE OFF)
SET(DEFAULT_CHARSET "utf8mb4")
# convert SSL options to uppercase
IF(WITH_SSL)
STRING(TOUPPER ${WITH_SSL} WITH_SSL)
ENDIF()
IF(WITH_SSL STREQUAL "ON")
SET(WITH_SSL "OPENSSL")
ENDIF()
IF(NOT WITH_SSL STREQUAL "OFF")
IF(WITH_SSL STREQUAL "OPENSSL")
IF (NOT OPENSSL_FOUND)
FIND_PACKAGE(OpenSSL)
ENDIF()
IF(OPENSSL_FOUND)
ADD_DEFINITIONS(-DHAVE_OPENSSL -DHAVE_TLS)
SET(SSL_SOURCES "${CC_SOURCE_DIR}/libmariadb/secure/openssl.c")
SET(SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
INCLUDE_DIRECTORIES(BEFORE ${OPENSSL_INCLUDE_DIR})
TRY_RUN(LIBRESSL_RESULT HAVE_LIBRESSL
${CMAKE_BINARY_DIR}
${CC_SOURCE_DIR}/cmake/libressl_version.c
COMPILE_DEFINITIONS "-I${OPENSSL_INCLUDE_DIR}"
RUN_OUTPUT_VARIABLE LIBRESSL_VERSION)
IF(HAVE_LIBRESSL)
ADD_DEFINITIONS(-DHAVE_LIBRESSL)
SET(TLS_LIBRARY_VERSION ${LIBRESSL_VERSION})
ELSE()
SET(TLS_LIBRARY_VERSION "OpenSSL ${OPENSSL_VERSION}")
ENDIF()
ENDIF()
ENDIF()
MARK_AS_ADVANCED(SSL_SOURCES)
ENDIF()
SET(ENABLED_LOCAL_INFILE OFF)
INCLUDE(${CC_SOURCE_DIR}/cmake/FindIconv.cmake)
CONFIGURE_FILE(${CC_SOURCE_DIR}/include/ma_config.h.in CONFIGURE_FILE(${CC_SOURCE_DIR}/include/ma_config.h.in
${CC_BINARY_DIR}/include/ma_config.h) ${CC_BINARY_DIR}/include/ma_config.h)
@ -157,44 +117,34 @@ CONFIGURE_FILE(${CC_SOURCE_DIR}/include/ma_config.h.in
CONFIGURE_FILE(${CC_SOURCE_DIR}/include/mariadb_version.h.in CONFIGURE_FILE(${CC_SOURCE_DIR}/include/mariadb_version.h.in
${CC_BINARY_DIR}/include/mariadb_version.h) ${CC_BINARY_DIR}/include/mariadb_version.h)
INCLUDE_DIRECTORIES(${CC_BINARY_DIR}/include) include_directories(${CC_BINARY_DIR}/include)
IF(WITH_SSL) if(WITH_SSL)
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${SSL_LIBRARIES}) set(SYSTEM_LIBS ${SYSTEM_LIBS} ${SSL_LIBRARIES})
ENDIF() endif()
IF(NOT AUTH_GSSAPI_PLUGIN_TYPE MATCHES "OFF")
INCLUDE(${CC_SOURCE_DIR}/cmake/FindGSSAPI.cmake)
IF(GSSAPI_FOUND)
INCLUDE_DIRECTORIES(${GSSAPI_INCS})
IF(AUTH_GSSAPI_PLUGIN_TYPE MATCHES "STATIC")
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${GSSAPI_LIBS})
ENDIF()
ENDIF()
ENDIF()
INCLUDE(${CC_SOURCE_DIR}/plugins/CMakeLists.txt) INCLUDE(${CC_SOURCE_DIR}/plugins/CMakeLists.txt)
INCLUDE_DIRECTORIES(${CC_SOURCE_DIR}/include include_directories(${CC_SOURCE_DIR}/include
${CC_SOURCE_DIR}/libmariadb) ${CC_SOURCE_DIR}/libmariadb)
ADD_DEFINITIONS(-D HAVE_COMPRESS) add_definitions(-D HAVE_COMPRESS)
ADD_DEFINITIONS(-D LIBMARIADB) add_definitions(-D LIBMARIADB)
ADD_DEFINITIONS(-D THREAD) add_definitions(-D THREAD)
# handle static plugins # handle static plugins
SET(LIBMARIADB_SOURCES ${LIBMARIADB_PLUGIN_SOURCES}) set(LIBMARIADB_SOURCES ${LIBMARIADB_PLUGIN_SOURCES})
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${LIBMARIADB_PLUGIN_LIBS}) set(SYSTEM_LIBS ${SYSTEM_LIBS} ${LIBMARIADB_PLUGIN_LIBS})
ADD_DEFINITIONS(${LIBMARIADB_PLUGIN_DEFS}) add_definitions(${LIBMARIADB_PLUGIN_DEFS})
FOREACH(plugin ${PLUGINS_STATIC}) FOREACH(plugin ${PLUGINS_STATIC})
SET(EXTERNAL_PLUGINS "${EXTERNAL_PLUGINS} extern struct st_mysql_client_plugin ${plugin}_client_plugin;\n") set(EXTERNAL_PLUGINS "${EXTERNAL_PLUGINS} extern struct st_mysql_client_plugin ${plugin}_client_plugin;\n")
SET(BUILTIN_PLUGINS "${BUILTIN_PLUGINS} (struct st_mysql_client_plugin *)&${plugin}_client_plugin,\n") set(BUILTIN_PLUGINS "${BUILTIN_PLUGINS} (struct st_mysql_client_plugin *)&${plugin}_client_plugin,\n")
ENDFOREACH() ENDFOREACH()
CONFIGURE_FILE(${CC_SOURCE_DIR}/libmariadb/ma_client_plugin.c.in CONFIGURE_FILE(${CC_SOURCE_DIR}/libmariadb/ma_client_plugin.c.in
${CC_BINARY_DIR}/libmariadb/ma_client_plugin.c) ${CC_BINARY_DIR}/libmariadb/ma_client_plugin.c)
SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} set(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES}
${CC_SOURCE_DIR}/plugins/auth/my_auth.c ${CC_SOURCE_DIR}/plugins/auth/my_auth.c
${CC_SOURCE_DIR}/libmariadb/ma_array.c ${CC_SOURCE_DIR}/libmariadb/ma_array.c
${CC_SOURCE_DIR}/libmariadb/ma_charset.c ${CC_SOURCE_DIR}/libmariadb/ma_charset.c
@ -225,27 +175,27 @@ ${CC_BINARY_DIR}/libmariadb/ma_client_plugin.c
${SSL_SOURCES} ${SSL_SOURCES}
) )
IF(ICONV_INCLUDE_DIR) if(ICONV_INCLUDE_DIR)
INCLUDE_DIRECTORIES(BEFORE ${ICONV_INCLUDE_DIR}) include_directories(BEFORE ${ICONV_INCLUDE_DIR})
ENDIF() endif()
ADD_DEFINITIONS(-DLIBICONV_PLUG) add_definitions(-DLIBICONV_PLUG)
IF(ZLIB_FOUND AND WITH_EXTERNAL_ZLIB) if(ZLIB_FOUND AND WITH_EXTERNAL_ZLIB)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) include_directories(${ZLIB_INCLUDE_DIR})
ENDIF() endif()
IF(WITH_DYNCOL) if(WITH_DYNCOL)
SET(MARIADB_LIB_SYMBOLS ${MARIADB_LIB_SYMBOLS} ${MARIADB_DYNCOL_SYMBOLS}) set(MARIADB_LIB_SYMBOLS ${MARIADB_LIB_SYMBOLS} ${MARIADB_DYNCOL_SYMBOLS})
SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} ${CC_SOURCE_DIR}/libmariadb/mariadb_dyncol.c) set(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} ${CC_SOURCE_DIR}/libmariadb/mariadb_dyncol.c)
ENDIF() endif()
SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} ${CC_SOURCE_DIR}/libmariadb/mariadb_async.c ${CC_SOURCE_DIR}/libmariadb/ma_context.c) set(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} ${CC_SOURCE_DIR}/libmariadb/mariadb_async.c ${CC_SOURCE_DIR}/libmariadb/ma_context.c)
ADD_LIBRARY(mariadbclient STATIC ${LIBMARIADB_SOURCES}) add_library(mariadbclient STATIC ${LIBMARIADB_SOURCES})
TARGET_LINK_LIBRARIES(mariadbclient ${SYSTEM_LIBS}) target_link_libraries(mariadbclient ${SYSTEM_LIBS})
target_include_directories(mariadbclient PUBLIC ${CC_BINARY_DIR}/include ${CC_SOURCE_DIR}/include ${CC_SOURCE_DIR}/libmariadb) target_include_directories(mariadbclient PUBLIC ${CC_BINARY_DIR}/include ${CC_SOURCE_DIR}/include ${CC_SOURCE_DIR}/libmariadb)
SET_TARGET_PROPERTIES(mariadbclient PROPERTIES IMPORTED_INTERFACE_LINK_LIBRARIES "${SYSTEM_LIBS}") set_target_properties(mariadbclient PROPERTIES IMPORTED_INTERFACE_LINK_LIBRARIES "${SYSTEM_LIBS}")