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_MYSQL_CLEAR_PASSWORD OFF)
set(SKIP_TESTS 1)
if (GLIBC_COMPATIBILITY)
set(LIBM glibc-compatibility)
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.
# Is C/C built as subproject?
get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY)
set(CC_SOURCE_DIR ${CMAKE_SOURCE_DIR}/contrib/mariadb-connector-c)
set(CC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
SET(CC_SOURCE_DIR ${CMAKE_SOURCE_DIR}/contrib/mariadb-connector-c)
SET(CC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(WITH_SSL ON)
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)
IF(AUTH_GSSAPI_PLUGIN_TYPE MATCHES "STATIC")
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${GSSAPI_LIBS})
ENDIF()
SET(PROTOCOL_VERSION 10) # we adapted new password option from PHP's mysqlnd !
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
# use the version defined by server
IF(MAJOR_VERSION)
SET(MARIADB_CLIENT_VERSION_MAJOR ${MAJOR_VERSION})
SET(MARIADB_CLIENT_VERSION_MINOR ${MINOR_VERSION})
SET(MARIADB_CLIENT_VERSION_PATCH ${PATCH_VERSION})
SET(MARIADB_CLIENT_VERSION_EXTRA ${EXTRA_VERSION})
ELSE()
SET(MARIADB_CLIENT_VERSION_MAJOR "10")
SET(MARIADB_CLIENT_VERSION_MINOR "4")
SET(MARIADB_CLIENT_VERSION_PATCH "3")
SET(MARIADB_CLIENT_VERSION_EXTRA "")
ENDIF()
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}")
if(MAJOR_VERSION)
set(MARIADB_CLIENT_VERSION_MAJOR ${MAJOR_VERSION})
set(MARIADB_CLIENT_VERSION_MINOR ${MINOR_VERSION})
set(MARIADB_CLIENT_VERSION_PATCH ${PATCH_VERSION})
set(MARIADB_CLIENT_VERSION_EXTRA ${EXTRA_VERSION})
else()
set(MARIADB_CLIENT_VERSION_MAJOR "10")
set(MARIADB_CLIENT_VERSION_MINOR "4")
set(MARIADB_CLIENT_VERSION_PATCH "3")
set(MARIADB_CLIENT_VERSION_EXTRA "")
endif()
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}")
MATH(EXPR MARIADB_VERSION_ID "${MARIADB_CLIENT_VERSION_MAJOR} * 10000 +
${MARIADB_CLIENT_VERSION_MINOR} * 100 +
${MARIADB_CLIENT_VERSION_PATCH}")
IF (NOT MARIADB_PORT)
SET(MARIADB_PORT 3306)
set(MARIADB_PORT 3306)
ENDIF ()
IF(NOT MARIADB_UNIX_ADDR)
SET(MARIADB_UNIX_ADDR "/tmp/mysql.sock")
ENDIF()
if(NOT MARIADB_UNIX_ADDR)
set(MARIADB_UNIX_ADDR "/tmp/mysql.sock")
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)
IF(NOT ZLIB_FOUND)
FIND_PACKAGE(ZLIB)
ENDIF()
IF(ZLIB_FOUND)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
SET(LIBZ ${ZLIB_LIBRARY})
ENDIF()
ENDIF()
set(SIZEOF_CHARP 8)
set(SIZEOF_INT 4)
set(SIZEOF_LONG 8)
set(SIZEOF_LONG_LONG 8)
set(SIZEOF_SIZE_T 8)
set(SOCKET_SIZE_TYPE socklen_t)
# check for various include files
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)
set(SYSTEM_LIBS ${SYSTEM_LIBS} zlib)
IF(UNIX)
SEARCH_LIBRARY(LIBNSL gethostbyname_r "nsl_r;nsl")
SEARCH_LIBRARY(LIBSOCKET setsockopt socket)
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()
if(CMAKE_HAVE_PTHREAD_H)
set(CMAKE_REQUIRED_INCLUDES pthread.h)
endif()
add_definitions(-DMARIADB_SYSTEM_TYPE="${CMAKE_SYSTEM_NAME}")
add_definitions(-DMARIADB_MACHINE_TYPE="${CMAKE_SYSTEM_PROCESSOR}")
IF(CMAKE_HAVE_PTHREAD_H)
SET(CMAKE_REQUIRED_INCLUDES pthread.h)
ENDIF()
set(HAVE_THREADS 1)
set(DEFAULT_CHARSET "utf8mb4")
ADD_DEFINITIONS(-DMARIADB_SYSTEM_TYPE="${CMAKE_SYSTEM_NAME}")
ADD_DEFINITIONS(-DMARIADB_MACHINE_TYPE="${CMAKE_SYSTEM_PROCESSOR}")
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})
set(TLS_LIBRARY_VERSION "OpenSSL ${OPENSSL_VERSION}")
SET(HAVE_THREADS 1)
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)
set(ENABLED_LOCAL_INFILE OFF)
CONFIGURE_FILE(${CC_SOURCE_DIR}/include/ma_config.h.in
${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
${CC_BINARY_DIR}/include/mariadb_version.h)
INCLUDE_DIRECTORIES(${CC_BINARY_DIR}/include)
include_directories(${CC_BINARY_DIR}/include)
IF(WITH_SSL)
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${SSL_LIBRARIES})
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()
if(WITH_SSL)
set(SYSTEM_LIBS ${SYSTEM_LIBS} ${SSL_LIBRARIES})
endif()
INCLUDE(${CC_SOURCE_DIR}/plugins/CMakeLists.txt)
INCLUDE_DIRECTORIES(${CC_SOURCE_DIR}/include
include_directories(${CC_SOURCE_DIR}/include
${CC_SOURCE_DIR}/libmariadb)
ADD_DEFINITIONS(-D HAVE_COMPRESS)
ADD_DEFINITIONS(-D LIBMARIADB)
ADD_DEFINITIONS(-D THREAD)
add_definitions(-D HAVE_COMPRESS)
add_definitions(-D LIBMARIADB)
add_definitions(-D THREAD)
# handle static plugins
SET(LIBMARIADB_SOURCES ${LIBMARIADB_PLUGIN_SOURCES})
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${LIBMARIADB_PLUGIN_LIBS})
ADD_DEFINITIONS(${LIBMARIADB_PLUGIN_DEFS})
set(LIBMARIADB_SOURCES ${LIBMARIADB_PLUGIN_SOURCES})
set(SYSTEM_LIBS ${SYSTEM_LIBS} ${LIBMARIADB_PLUGIN_LIBS})
add_definitions(${LIBMARIADB_PLUGIN_DEFS})
FOREACH(plugin ${PLUGINS_STATIC})
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(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")
ENDFOREACH()
CONFIGURE_FILE(${CC_SOURCE_DIR}/libmariadb/ma_client_plugin.c.in
${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}/libmariadb/ma_array.c
${CC_SOURCE_DIR}/libmariadb/ma_charset.c
@ -225,27 +175,27 @@ ${CC_BINARY_DIR}/libmariadb/ma_client_plugin.c
${SSL_SOURCES}
)
IF(ICONV_INCLUDE_DIR)
INCLUDE_DIRECTORIES(BEFORE ${ICONV_INCLUDE_DIR})
ENDIF()
ADD_DEFINITIONS(-DLIBICONV_PLUG)
if(ICONV_INCLUDE_DIR)
include_directories(BEFORE ${ICONV_INCLUDE_DIR})
endif()
add_definitions(-DLIBICONV_PLUG)
IF(ZLIB_FOUND AND WITH_EXTERNAL_ZLIB)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
ENDIF()
if(ZLIB_FOUND AND WITH_EXTERNAL_ZLIB)
include_directories(${ZLIB_INCLUDE_DIR})
endif()
IF(WITH_DYNCOL)
SET(MARIADB_LIB_SYMBOLS ${MARIADB_LIB_SYMBOLS} ${MARIADB_DYNCOL_SYMBOLS})
SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} ${CC_SOURCE_DIR}/libmariadb/mariadb_dyncol.c)
ENDIF()
if(WITH_DYNCOL)
set(MARIADB_LIB_SYMBOLS ${MARIADB_LIB_SYMBOLS} ${MARIADB_DYNCOL_SYMBOLS})
set(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} ${CC_SOURCE_DIR}/libmariadb/mariadb_dyncol.c)
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})
TARGET_LINK_LIBRARIES(mariadbclient ${SYSTEM_LIBS})
add_library(mariadbclient STATIC ${LIBMARIADB_SOURCES})
target_link_libraries(mariadbclient ${SYSTEM_LIBS})
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}")