Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ support-files/mariadb-extra.socket
support-files/mariadb@.service
support-files/mariadb@.socket
support-files/mariadb-extra@.socket
support-files/mariadb-plugin-config.cmake
support-files/mini-benchmark
support-files/my-huge.cnf
support-files/my-innodb-heavy-4G.cnf
Expand Down
18 changes: 15 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) 2006, 2017, Oracle and/or its affiliates.
# Copyright (c) 2008, 2022, MariaDB Corporation.
# Copyright (c) 2008, 2026, MariaDB Corporation.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -43,6 +43,7 @@ MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}")

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/cmake ${CMAKE_SOURCE_DIR}/cmake/Internal/CPack)
SET(mariadb-plugin_DIR ${CMAKE_SOURCE_DIR}/cmake)

# Use a default manufacturer if no manufacturer was identified.
IF(NOT DEFINED MANUFACTURER)
Expand Down Expand Up @@ -167,7 +168,7 @@ INCLUDE(dtrace)
INCLUDE(pcre)
INCLUDE(libfmt)
INCLUDE(ctest)
INCLUDE(plugin)
INCLUDE(mariadb-plugin-config)
INCLUDE(install_macros)
INCLUDE(systemd)
INCLUDE(mysql_add_executable)
Expand Down Expand Up @@ -493,7 +494,18 @@ SET(PYTHON_SHEBANG "/usr/bin/env python3" CACHE STRING "python shebang")
MARK_AS_ADVANCED(PYTHON_SHEBANG)

# Add storage engines and plugins.
CONFIGURE_PLUGINS()
IF(NOT WITHOUT_SERVER)
FILE(GLOB dirs_storage ${CMAKE_SOURCE_DIR}/storage/*)
ENDIF()

FILE(GLOB dirs_plugin ${CMAKE_SOURCE_DIR}/plugin/*)
FOREACH(dir ${dirs_storage} ${dirs_plugin})
IF (EXISTS ${dir}/CMakeLists.txt)
ADD_SUBDIRECTORY(${dir})
ENDIF()
ENDFOREACH()
Comment thread
vuvova marked this conversation as resolved.

VERIFY_PLUGINS()

ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(dbug)
Expand Down
56 changes: 24 additions & 32 deletions cmake/plugin.cmake → cmake/mariadb-plugin-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

INCLUDE(CMakeParseArguments)

# MYSQL_ADD_PLUGIN(plugin_name source1...sourceN
# MARIADB_ADD_PLUGIN(plugin_name source1...sourceN
# [STORAGE_ENGINE]
# [STATIC_ONLY|MODULE_ONLY]
# [MANDATORY|DEFAULT]
Expand All @@ -32,7 +32,7 @@ INCLUDE(CMakeParseArguments)
# [LINK_LIBRARIES lib1...libN]
# [DEPENDS target1...targetN]

MACRO(MYSQL_ADD_PLUGIN)
MACRO(MARIADB_ADD_PLUGIN)
CMAKE_PARSE_ARGUMENTS(ARG
"STORAGE_ENGINE;STATIC_ONLY;MODULE_ONLY;MANDATORY;DEFAULT;DISABLED;NOT_EMBEDDED;RECOMPILE_FOR_EMBEDDED;CLIENT"
"MODULE_OUTPUT_NAME;STATIC_OUTPUT_NAME;COMPONENT;CONFIG;VERSION"
Expand All @@ -42,7 +42,7 @@ MACRO(MYSQL_ADD_PLUGIN)
IF(NOT WITHOUT_SERVER OR ARG_CLIENT)

# Add common include directories
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/sql
${PCRE_INCLUDE_DIRS}
${SSL_INCLUDE_DIRS}
Expand Down Expand Up @@ -133,7 +133,7 @@ MACRO(MYSQL_ADD_PLUGIN)
IF(ARG_VERSION)
SET(version_string ";PLUGIN_${plugin}_VERSION=\"${ARG_VERSION}\"")
ENDIF()

IF(NOT ARG_MODULE_OUTPUT_NAME)
IF(ARG_STORAGE_ENGINE)
SET(ARG_MODULE_OUTPUT_NAME "ha_${target}")
Expand All @@ -148,10 +148,10 @@ MACRO(MYSQL_ADD_PLUGIN)

IF(CMAKE_GENERATOR MATCHES "Makefiles|Ninja")
# If there is a shared library from previous shared build,
# remove it. This is done just for mysql-test-run.pl
# so it does not try to use stale shared lib as plugin
# remove it. This is done just for mysql-test-run.pl
# so it does not try to use stale shared lib as plugin
# in test.
FILE(REMOVE
FILE(REMOVE
${CMAKE_CURRENT_BINARY_DIR}/${ARG_MODULE_OUTPUT_NAME}${CMAKE_SHARED_MODULE_SUFFIX})
ENDIF()

Expand All @@ -166,9 +166,9 @@ MACRO(MYSQL_ADD_PLUGIN)
# Recompile some plugins for embedded
ADD_CONVENIENCE_LIBRARY(${target}_embedded ${SOURCES})
RESTRICT_SYMBOL_EXPORTS(${target}_embedded)
DTRACE_INSTRUMENT(${target}_embedded)
DTRACE_INSTRUMENT(${target}_embedded)
IF(ARG_RECOMPILE_FOR_EMBEDDED)
SET_TARGET_PROPERTIES(${target}_embedded
SET_TARGET_PROPERTIES(${target}_embedded
PROPERTIES COMPILE_DEFINITIONS "EMBEDDED_LIBRARY${version_string}")
ENDIF()
ADD_DEPENDENCIES(${target}_embedded GenError ${ARG_DEPENDS})
Expand All @@ -179,7 +179,7 @@ MACRO(MYSQL_ADD_PLUGIN)
ENDIF()

IF(ARG_STATIC_OUTPUT_NAME)
SET_TARGET_PROPERTIES(${target} PROPERTIES
SET_TARGET_PROPERTIES(${target} PROPERTIES
OUTPUT_NAME ${ARG_STATIC_OUTPUT_NAME})
ENDIF()

Expand All @@ -190,7 +190,7 @@ MACRO(MYSQL_ADD_PLUGIN)
SET(${with_var} ON CACHE INTERNAL "Link ${plugin} statically to the server" FORCE)

# Update mysqld dependencies
SET (MYSQLD_STATIC_PLUGIN_LIBS ${MYSQLD_STATIC_PLUGIN_LIBS}
SET (MYSQLD_STATIC_PLUGIN_LIBS ${MYSQLD_STATIC_PLUGIN_LIBS}
${target} ${ARG_LINK_LIBRARIES} CACHE INTERNAL "" FORCE)

IF(WITH_EMBEDDED_SERVER AND (NOT ARG_NOT_EMBEDDED))
Expand All @@ -205,19 +205,19 @@ MACRO(MYSQL_ADD_PLUGIN)
ENDIF()

IF(ARG_MANDATORY)
SET (mysql_mandatory_plugins
SET (mysql_mandatory_plugins
"${mysql_mandatory_plugins}${builtin_entry}\n")
SET (mysql_mandatory_plugins ${mysql_mandatory_plugins} PARENT_SCOPE)
ELSE()
SET (mysql_optional_plugins
SET (mysql_optional_plugins
"${mysql_optional_plugins}${builtin_entry}\n")
SET (mysql_optional_plugins ${mysql_optional_plugins} PARENT_SCOPE)
ENDIF()
ELSEIF(PLUGIN_${plugin} MATCHES "(DYNAMIC|AUTO|YES)"
AND NOT ARG_STATIC_ONLY AND NOT WITHOUT_DYNAMIC_PLUGINS)

ADD_VERSION_INFO(${target} MODULE SOURCES)
ADD_LIBRARY(${target} MODULE ${SOURCES})
ADD_LIBRARY(${target} MODULE ${SOURCES})
DTRACE_INSTRUMENT(${target})

SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX "")
Expand All @@ -238,10 +238,10 @@ MACRO(MYSQL_ADD_PLUGIN)
ENDIF()

# Server plugins use symbols defined in mysqld executable.
# Some operating systems like Windows and OSX and are pretty strict about
# Some operating systems like Windows and OSX and are pretty strict about
# unresolved symbols. Others are less strict and allow unresolved symbols
# in shared libraries. On Linux for example, CMake does not even add
# executable to the linker command line (it would result into link error).
# in shared libraries. On Linux for example, CMake does not even add
# executable to the linker command line (it would result into link error).
# Thus we skip TARGET_LINK_LIBRARIES on Linux, as it would only generate
# an additional dependency.
IF(ARG_RECOMPILE_FOR_EMBEDDED OR ARG_STORAGE_ENGINE)
Expand All @@ -256,8 +256,8 @@ MACRO(MYSQL_ADD_PLUGIN)

ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDS})

SET_TARGET_PROPERTIES(${target} PROPERTIES
OUTPUT_NAME "${ARG_MODULE_OUTPUT_NAME}")
SET_TARGET_PROPERTIES(${target} PROPERTIES
OUTPUT_NAME "${ARG_MODULE_OUTPUT_NAME}")
# Install dynamic library
IF(ARG_COMPONENT)
IF(CPACK_COMPONENTS_ALL AND
Expand Down Expand Up @@ -326,20 +326,12 @@ MACRO(MYSQL_ADD_PLUGIN)
ENDMACRO()


# Add all CMake projects under storage and plugin
# subdirectories, configure sql_builtins.cc
MACRO(CONFIGURE_PLUGINS)
IF(NOT WITHOUT_SERVER)
FILE(GLOB dirs_storage ${CMAKE_SOURCE_DIR}/storage/*)
ENDIF()

FILE(GLOB dirs_plugin ${CMAKE_SOURCE_DIR}/plugin/*)
FOREACH(dir ${dirs_storage} ${dirs_plugin})
IF (EXISTS ${dir}/CMakeLists.txt)
ADD_SUBDIRECTORY(${dir})
ENDIF()
ENDFOREACH()
MACRO(MYSQL_ADD_PLUGIN)
MARIADB_ADD_PLUGIN(${ARGV})
ENDMACRO()

# verify that all -DPLUGIN_xxx=YES plugins are being built
MACRO(VERIFY_PLUGINS)
GET_CMAKE_PROPERTY(ALL_VARS VARIABLES)
FOREACH (V ${ALL_VARS})
IF (V MATCHES "^PLUGIN_")
Expand Down
1 change: 1 addition & 0 deletions cmake/wsrep.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ IF(WITH_WSREP)
# Set the patch version
SET(WSREP_PATCH_VERSION "22")

ADD_DEFINITIONS(-DWITH_WSREP)
ADD_SUBMODULE(wsrep-lib)

# Obtain wsrep API version
Expand Down
1 change: 0 additions & 1 deletion config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,6 @@

#ifndef EMBEDDED_LIBRARY
#cmakedefine WSREP_INTERFACE_VERSION "@WSREP_INTERFACE_VERSION@"
#cmakedefine WITH_WSREP 1
#endif

#if !defined(__STDC_FORMAT_MACROS)
Expand Down
23 changes: 13 additions & 10 deletions plugin/auth_examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
#
# Copyright (c) 2026, MariaDB plc
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; version 2 of the
# License.
#
#
# This program 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 General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA

MYSQL_ADD_PLUGIN(dialog_examples dialog_examples.c
FIND_PACKAGE(mariadb-plugin REQUIRED)

MARIADB_ADD_PLUGIN(dialog_examples dialog_examples.c
MODULE_ONLY COMPONENT Test)
MYSQL_ADD_PLUGIN(auth_test_plugin test_plugin.c
MARIADB_ADD_PLUGIN(auth_test_plugin test_plugin.c
MODULE_ONLY COMPONENT Test)
MYSQL_ADD_PLUGIN(qa_auth_interface qa_auth_interface.c
MARIADB_ADD_PLUGIN(qa_auth_interface qa_auth_interface.c
MODULE_ONLY COMPONENT Test)

MYSQL_ADD_PLUGIN(qa_auth_server qa_auth_server.c
MARIADB_ADD_PLUGIN(qa_auth_server qa_auth_server.c
MODULE_ONLY COMPONENT Test)

MYSQL_ADD_PLUGIN(qa_auth_client qa_auth_client.c
MARIADB_ADD_PLUGIN(qa_auth_client qa_auth_client.c
MODULE_ONLY COMPONENT Test)

MYSQL_ADD_PLUGIN(auth_0x0100 auth_0x0100.c MODULE_ONLY COMPONENT Test)
MARIADB_ADD_PLUGIN(auth_0x0100 auth_0x0100.c MODULE_ONLY COMPONENT Test)

# disabled in favor of
# libmariadb/plugins/auth/mariadb_cleartext.c
#
#MYSQL_ADD_PLUGIN(mysql_clear_password clear_password_client.c
#MARIADB_ADD_PLUGIN(mysql_clear_password clear_password_client.c
# MODULE_ONLY CLIENT COMPONENT ClientPlugins)
4 changes: 3 additions & 1 deletion plugin/daemon_example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2026, MariaDB plc
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -13,7 +14,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA

MYSQL_ADD_PLUGIN(daemon_example daemon_example.cc RECOMPILE_FOR_EMBEDDED
FIND_PACKAGE(mariadb-plugin REQUIRED)
MARIADB_ADD_PLUGIN(daemon_example daemon_example.cc RECOMPILE_FOR_EMBEDDED
MODULE_ONLY MODULE_OUTPUT_NAME "libdaemon_example" COMPONENT Test)

INSTALL(FILES daemon_example.ini DESTINATION ${INSTALL_PLUGINDIR}
Expand Down
5 changes: 3 additions & 2 deletions plugin/example_key_management/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
MYSQL_ADD_PLUGIN(EXAMPLE_KEY_MANAGEMENT example_key_management_plugin.cc
MODULE_ONLY COMPONENT Test)
FIND_PACKAGE(mariadb-plugin REQUIRED)
MARIADB_ADD_PLUGIN(EXAMPLE_KEY_MANAGEMENT example_key_management_plugin.cc
MODULE_ONLY COMPONENT Test)
2 changes: 1 addition & 1 deletion sql/sql_builtin.cc.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/*
Note that sql_builtin.cc is automatically built by sql_bultin.cc.in
and cmake/plugin.cmake
and cmake/mariadb-plugin-config.cmake
*/

#include <my_global.h>
Expand Down
4 changes: 3 additions & 1 deletion storage/example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2026, MariaDB plc
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -13,5 +14,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA

FIND_PACKAGE(mariadb-plugin REQUIRED)
SET(EXAMPLE_SOURCES ha_example.cc)
MYSQL_ADD_PLUGIN(example ${EXAMPLE_SOURCES} STORAGE_ENGINE MODULE_ONLY COMPONENT Test)
MARIADB_ADD_PLUGIN(example ${EXAMPLE_SOURCES} STORAGE_ENGINE MODULE_ONLY COMPONENT Test)
8 changes: 7 additions & 1 deletion support-files/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) 2006, 2016, Oracle and/or its affiliates.
# Copyright (c) 2012, 2022, MariaDB
# Copyright (c) 2012, 2026, MariaDB plc
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -256,4 +256,10 @@ IF(UNIX AND NOT WITHOUT_SERVER)
WORKING_DIRECTORY \$ENV{DESTDIR}${prefix})"
COMPONENT SupportFiles)
ENDIF(INSTALL_SYSCONFDIR)

FILE(READ ${CMAKE_SOURCE_DIR}/cmake/install_layout.cmake install_layout.cmake)
FILE(READ ${CMAKE_SOURCE_DIR}/cmake/mariadb-plugin-config.cmake plugin.cmake)
CONFIGURE_FILE(mariadb-plugin-config.cmake.in mariadb-plugin-config.cmake @ONLY)
Comment thread
vuvova marked this conversation as resolved.
INSTALL(FILES mariadb-plugin-config.cmake DESTINATION ${INSTALL_SHAREDIR}/cmake/mariadb-plugin/
COMPONENT Development)
ENDIF()
33 changes: 33 additions & 0 deletions support-files/mariadb-plugin-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2026, MariaDB plc
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA

MACRO(DTRACE_INSTRUMENT)
ENDMACRO()
MACRO(ADD_VERSION_INFO)
ENDMACRO()
MACRO(MYSQL_INSTALL_TARGETS)
INSTALL(TARGETS ${ARGV})
ENDMACRO()
ADD_CUSTOM_TARGET(GenError)
Comment on lines +16 to +23

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not so easy. I need to try it on a plugin with tests


INCLUDE(FeatureSummary)

GET_FILENAME_COMPONENT(prefix "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
INCLUDE_DIRECTORIES(${prefix}/@INSTALL_INCLUDEDIR@/server ${prefix}/@INSTALL_INCLUDEDIR@/server/private)

@install_layout.cmake@

@plugin.cmake@
Comment thread
vuvova marked this conversation as resolved.