MDEV-6248 GUI-friendly cmake options to enable/disable plugins

* Introduce a set of PLUGIN_xxx cmake options with values
  NO, STATIC, DYNAMIC, AUTO, YES (abort if plugin is not compiled)
* Deprecate redundant and ambiguous WITH_xxx, WITH_PLUGIN_xxx,
  WITH_xxx_STORAGE_ENGINE, WITHOUT_xxx, WITHOUT_PLUGIN_xxx,
  WITHOUT_xxx_STORAGE_ENGINE
* Actually check whether a plugin is disabled (DISABLED keyword was
  always present, but it was ignored until now).
* Support conditionally disabled plugins - keyword ONLY_IF
* Use ONLY_IF for conditionally skipping plugins, instead of
  doing MYSQL_ADD_PLUGIN conditionally as before. Because if
  MYSQL_ADD_PLUGIN isn't done at all, PLUGIN_xxx=YES cannot work.
This commit is contained in:
Sergei Golubchik 2014-06-23 12:09:00 +02:00
commit 787ec31778
10 changed files with 140 additions and 149 deletions

View file

@ -29,11 +29,11 @@ INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake)
MACRO(MYSQL_ADD_PLUGIN)
MYSQL_PARSE_ARGUMENTS(ARG
"LINK_LIBRARIES;DEPENDENCIES;MODULE_OUTPUT_NAME;STATIC_OUTPUT_NAME;COMPONENT;CONFIG"
"LINK_LIBRARIES;DEPENDENCIES;MODULE_OUTPUT_NAME;STATIC_OUTPUT_NAME;COMPONENT;CONFIG;ONLY_IF"
"STORAGE_ENGINE;STATIC_ONLY;MODULE_ONLY;MANDATORY;DEFAULT;DISABLED;RECOMPILE_FOR_EMBEDDED"
${ARGN}
)
# Add common include directories
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/sql
@ -47,45 +47,58 @@ MACRO(MYSQL_ADD_PLUGIN)
STRING(TOUPPER ${plugin} plugin)
STRING(TOLOWER ${plugin} target)
# Figure out whether to build plugin
IF(WITH_PLUGIN_${plugin})
SET(WITH_${plugin} 1)
ENDIF()
IF (ARG_MANDATORY)
UNSET(PLUGIN_${plugin} CACHE)
SET(PLUGIN_${plugin} "YES")
ELSE()
SET (compat ".")
# Figure out whether to build plugin.
# recognize and support the maze of old WITH/WITHOUT combinations
IF(WITHOUT_${plugin}_STORAGE_ENGINE
OR WITHOUT_${plugin}
OR WITHOUT_PLUGIN_${plugin}
OR WITH_NONE)
IF(WITH_MAX_NO_NDB)
SET(WITH_MAX 1)
SET(WITHOUT_NDBCLUSTER 1)
ENDIF()
IF(ARG_DEFAULT)
IF(NOT DEFINED WITH_${plugin} AND
NOT DEFINED WITH_${plugin}_STORAGE_ENGINE)
SET(WITH_${plugin} 1)
SET(compat "${compat}without")
ENDIF()
ENDIF()
IF(WITH_${plugin}_STORAGE_ENGINE
OR WITH_{$plugin}
OR WITH_ALL
OR WITH_MAX
AND NOT WITHOUT_${plugin}_STORAGE_ENGINE
AND NOT WITHOUT_${plugin}
AND NOT ARG_MODULE_ONLY)
SET(WITH_${plugin} 1)
ELSEIF(WITHOUT_${plugin} OR WITHOUT_${plugin}_STORAGE_ENGINE OR
WITH_NONE OR ${plugin}_DISABLED)
SET(WITHOUT_${plugin} 1)
SET(WITH_${plugin}_STORAGE_ENGINE 0)
SET(WITH_${plugin} 0)
ENDIF()
IF(ARG_MANDATORY)
SET(WITH_${plugin} 1)
IF(WITH_${plugin}_STORAGE_ENGINE
OR WITH_${plugin}
OR WITH_PLUGIN_${plugin}
OR WITH_ALL
OR WITH_MAX
OR WITH_MAX_NO_NDB
OR ARG_DEFAULT)
SET(compat "with${compat}")
ENDIF()
IF (compat STREQUAL ".")
SET(howtobuild DYNAMIC)
ELSEIF (compat STREQUAL "with.")
IF (NOT ARG_MODULE_ONLY)
SET(howtobuild STATIC)
ELSE()
SET(howtobuild DYNAMIC)
ENDIF()
ELSEIF (compat STREQUAL ".without")
SET(howtobuild NO)
ELSEIF (compat STREQUAL "with.without")
SET(howtobuild STATIC)
ENDIF()
# NO - not at all
# YES - static if possible, otherwise dynamic if possible, otherwise abort
# AUTO - static if possible, otherwise dynamic, if possible
# STATIC - static if possible, otherwise not at all
# DYNAMIC - dynamic if possible, otherwise not at all
SET(PLUGIN_${plugin} ${howtobuild}
CACHE STRING "How to build plugin ${plugin}. Options are: NO STATIC DYNAMIC YES AUTO.")
ENDIF()
IF (NOT PLUGIN_${plugin} MATCHES "^(NO|YES|AUTO|STATIC|DYNAMIC)$")
MESSAGE(FATAL_ERROR "Invalid value for PLUGIN_${plugin}")
ENDIF()
IF(ARG_STORAGE_ENGINE)
SET(with_var "WITH_${plugin}_STORAGE_ENGINE" )
ELSE()
@ -95,7 +108,6 @@ MACRO(MYSQL_ADD_PLUGIN)
IF(NOT ARG_DEPENDENCIES)
SET(ARG_DEPENDENCIES)
ENDIF()
SET(BUILD_PLUGIN 1)
IF(NOT ARG_MODULE_OUTPUT_NAME)
IF(ARG_STORAGE_ENGINE)
@ -105,8 +117,13 @@ MACRO(MYSQL_ADD_PLUGIN)
ENDIF()
ENDIF()
IF(ARG_ONLY_IF AND NOT ${ARG_ONLY_IF})
SET(ARG_DISABLED 1)
ENDIF()
# Build either static library or module
IF (WITH_${plugin} AND NOT ARG_MODULE_ONLY)
IF (PLUGIN_${plugin} MATCHES "(STATIC|AUTO|YES)" AND NOT ARG_MODULE_ONLY
AND NOT ARG_DISABLED)
IF(CMAKE_GENERATOR MATCHES "Makefiles|Ninja")
# If there is a shared library from previous shared build,
@ -142,17 +159,15 @@ MACRO(MYSQL_ADD_PLUGIN)
OUTPUT_NAME ${ARG_STATIC_OUTPUT_NAME})
ENDIF()
IF(ARG_LINK_LIBRARIES)
TARGET_LINK_LIBRARIES (${target} ${ARG_LINK_LIBRARIES})
ENDIF()
# Update mysqld dependencies
SET (MYSQLD_STATIC_PLUGIN_LIBS ${MYSQLD_STATIC_PLUGIN_LIBS}
${target} ${ARG_LINK_LIBRARIES} CACHE INTERNAL "" FORCE)
IF(ARG_MANDATORY)
SET(${with_var} ON CACHE INTERNAL "Link ${plugin} statically to the server"
FORCE)
ELSE()
SET(${with_var} ON CACHE BOOL "Link ${plugin} statically to the server"
FORCE)
ENDIF()
SET(${with_var} ON CACHE INTERNAL "Link ${plugin} statically to the server" FORCE)
IF(ARG_MANDATORY)
SET (mysql_mandatory_plugins
@ -163,14 +178,16 @@ MACRO(MYSQL_ADD_PLUGIN)
"${mysql_optional_plugins} builtin_maria_${target}_plugin,")
SET (mysql_optional_plugins ${mysql_optional_plugins} PARENT_SCOPE)
ENDIF()
ELSEIF(NOT WITHOUT_${plugin} AND NOT ARG_STATIC_ONLY AND NOT WITHOUT_DYNAMIC_PLUGINS)
ELSEIF(PLUGIN_${plugin} MATCHES "(DYNAMIC|AUTO|YES)"
AND NOT ARG_STATIC_ONLY AND NOT WITHOUT_DYNAMIC_PLUGINS
AND NOT ARG_DISABLED)
ADD_VERSION_INFO(${target} MODULE SOURCES)
ADD_LIBRARY(${target} MODULE ${SOURCES})
DTRACE_INSTRUMENT(${target})
SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX ""
COMPILE_DEFINITIONS "MYSQL_DYNAMIC_PLUGIN")
TARGET_LINK_LIBRARIES (${target} mysqlservices)
TARGET_LINK_LIBRARIES (${target} mysqlservices ${ARG_LINK_LIBRARIES})
# Plugin uses symbols defined in mysqld executable.
# Some operating systems like Windows and OSX and are pretty strict about
@ -180,15 +197,12 @@ MACRO(MYSQL_ADD_PLUGIN)
# Thus we skip TARGET_LINK_LIBRARIES on Linux, as it would only generate
# an additional dependency.
IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
TARGET_LINK_LIBRARIES (${target} mysqld ${ARG_LINK_LIBRARIES})
TARGET_LINK_LIBRARIES (${target} mysqld)
ENDIF()
ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES})
IF(NOT ARG_MODULE_ONLY)
# set cached variable, e.g with checkbox in GUI
SET(${with_var} OFF CACHE BOOL "Link ${plugin} statically to the server"
FORCE)
ENDIF()
UNSET(${with_var} CACHE)
SET_TARGET_PROPERTIES(${target} PROPERTIES
OUTPUT_NAME "${ARG_MODULE_OUTPUT_NAME}")
# Install dynamic library
@ -213,18 +227,8 @@ MACRO(MYSQL_ADD_PLUGIN)
ENDIF()
MYSQL_INSTALL_TARGETS(${target} DESTINATION ${INSTALL_PLUGINDIR} COMPONENT ${ARG_COMPONENT})
#INSTALL_DEBUG_TARGET(${target} DESTINATION ${INSTALL_PLUGINDIR}/debug COMPONENT ${ARG_COMPONENT})
ELSE()
IF(WITHOUT_${plugin})
# Update cache variable
STRING(REPLACE "WITH_" "WITHOUT_" without_var ${with_var})
SET(${without_var} ON CACHE BOOL "Don't build ${plugin}"
FORCE)
ENDIF()
SET(BUILD_PLUGIN 0)
ENDIF()
IF(BUILD_PLUGIN AND ARG_LINK_LIBRARIES)
TARGET_LINK_LIBRARIES (${target} ${ARG_LINK_LIBRARIES})
ELSEIF(PLUGIN_${plugin} MATCHES "YES")
MESSAGE(FATAL_ERROR "Plugin ${plugin} cannot be built")
ENDIF()
GET_FILENAME_COMPONENT(subpath ${CMAKE_CURRENT_SOURCE_DIR} NAME)