Commit 787ec317 authored by Sergei Golubchik's avatar Sergei Golubchik

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.
parent da9bb66b
......@@ -46,8 +46,6 @@ SET(FEATURE_SET_large 5)
SET(FEATURE_SET_xlarge 6)
SET(FEATURE_SET_community 7)
#SET(WITH_CASSANDRA_STORAGE_ENGINE ON)
IF(FEATURE_SET)
STRING(TOLOWER ${FEATURE_SET} feature_set)
SET(num ${FEATURE_SET_${feature_set}})
......@@ -56,7 +54,7 @@ IF(FEATURE_SET)
Should be xsmall, small, classic, large, or community
")
ENDIF()
SET(WITH_PARTITION_STORAGE_ENGINE OFF)
SET(PLUGIN_PARTITION "NO")
IF(num EQUAL FEATURE_SET_xsmall)
SET(WITH_NONE ON)
ENDIF()
......@@ -65,34 +63,23 @@ IF(FEATURE_SET)
SET(WITH_EMBEDDED_SERVER ON CACHE BOOL "")
ENDIF()
IF(num GREATER FEATURE_SET_small)
SET(WITH_ARCHIVE_STORAGE_ENGINE ON)
SET(WITH_BLACKHOLE_STORAGE_ENGINE ON)
SET(WITH_FEDERATEDX_STORAGE_ENGINE ON)
SET(WITH_PLUGIN_FEEDBACK ON)
SET(PLUGIN_ARCHIVE "STATIC")
SET(PLUGIN_BLACKHOLE "STATIC")
SET(PLUGIN_FEDERATEDX "STATIC")
SET(PLUGIN_FEEDBACK "STATIC")
ENDIF()
IF(num GREATER FEATURE_SET_classic)
SET(WITH_INNOBASE_STORAGE_ENGINE ON)
SET(PLUGIN_INNOBASE "STATIC")
ENDIF()
IF(num GREATER FEATURE_SET_large)
SET(WITH_PARTITION_STORAGE_ENGINE ON)
SET(PLUGIN_PARTITION "STATIC")
#SET(PLUGIN_CASSANDRA "STATIC")
ENDIF()
IF(num GREATER FEATURE_SET_xlarge)
# OPTION(WITH_ALL ON)
# better no set this, otherwise server would be linked
# statically with experimental stuff like audit_null
ENDIF()
# Update cache with current values, remove engines we do not care about
# from build.
FOREACH(eng ARCHIVE BLACKHOLE FEDERATED INNOBASE PARTITION)
IF(NOT WITH_${eng}_STORAGE_ENGINE)
SET(WITHOUT_${eng}_STORAGE_ENGINE ON CACHE BOOL "")
MARK_AS_ADVANCED(WITHOUT_${eng}_STORAGE_ENGINE)
SET(WITH_${eng}_STORAGE_ENGINE OFF CACHE BOOL "")
ELSE()
SET(WITH_${eng}_STORAGE_ENGINE ON CACHE BOOL "")
ENDIF()
ENDFOREACH()
ENDIF()
OPTION(ENABLED_LOCAL_INFILE "" ON)
......
......@@ -29,7 +29,7 @@ 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}
)
......@@ -47,44 +47,57 @@ 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(WITH_MAX_NO_NDB)
SET(WITH_MAX 1)
SET(WITHOUT_NDBCLUSTER 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(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_${plugin}
OR WITH_PLUGIN_${plugin}
OR WITH_ALL
OR WITH_MAX
AND NOT WITHOUT_${plugin}_STORAGE_ENGINE
AND NOT WITHOUT_${plugin}
AND NOT ARG_MODULE_ONLY)
OR WITH_MAX_NO_NDB
OR ARG_DEFAULT)
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)
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()
IF(ARG_MANDATORY)
SET(WITH_${plugin} 1)
# 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" )
......@@ -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)
......
......@@ -72,7 +72,7 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
ENDIF()
ENDIF()
IF(WITH_INNOBASE_STORAGE_ENGINE)
IF(WITH_INNOBASE_STORAGE_ENGINE OR WITH_XTRADB_STORAGE_ENGINE)
# Add path to the InnoDB headers
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include)
# We use the InnoDB code directly in case the code changes.
......
......@@ -4,10 +4,10 @@ INCLUDE (CheckFunctionExists)
CHECK_INCLUDE_FILES (security/pam_appl.h HAVE_PAM_APPL_H)
CHECK_FUNCTION_EXISTS (strndup HAVE_STRNDUP)
IF(HAVE_PAM_APPL_H)
IF(HAVE_STRNDUP)
IF(HAVE_STRNDUP)
ADD_DEFINITIONS(-DHAVE_STRNDUP)
ENDIF(HAVE_STRNDUP)
MYSQL_ADD_PLUGIN(auth_pam auth_pam.c LINK_LIBRARIES pam MODULE_ONLY)
ENDIF(HAVE_PAM_APPL_H)
ENDIF(HAVE_STRNDUP)
MYSQL_ADD_PLUGIN(auth_pam auth_pam.c ONLY_IF HAVE_PAM_APPL_H
LINK_LIBRARIES pam MODULE_ONLY)
......@@ -35,5 +35,8 @@ IF (NOT HAVE_PEERCRED)
ENDIF()
IF(HAVE_PEERCRED OR HAVE_SOCKPEERCRED)
MYSQL_ADD_PLUGIN(auth_socket auth_socket.c MODULE_ONLY)
SET(AUTH_SOCKET_OK 1)
ENDIF()
MYSQL_ADD_PLUGIN(auth_socket auth_socket.c ONLY_IF AUTH_SOCKET_OK MODULE_ONLY)
......@@ -14,10 +14,10 @@ IF(HAVE_NETDB_H)
ENDIF(HAVE_NETDB_H)
IF(WIN32)
MYSQL_ADD_PLUGIN(FEEDBACK ${FEEDBACK_SOURCES}
LINK_LIBRARIES ${SSL_LIBRARIES}
STATIC_ONLY DEFAULT)
ELSE(WIN32)
MYSQL_ADD_PLUGIN(FEEDBACK ${FEEDBACK_SOURCES}
LINK_LIBRARIES ${SSL_LIBRARIES})
SET(MAYBE_STATIC_ONLY STATIC_ONLY)
ENDIF(WIN32)
MYSQL_ADD_PLUGIN(FEEDBACK ${FEEDBACK_SOURCES}
LINK_LIBRARIES ${SSL_LIBRARIES}
${MAYBE_STATIC_ONLY} DEFAULT)
......@@ -17,18 +17,14 @@ MARK_AS_ADVANCED(Thrift_LIBS Thrift_INCLUDE_DIRS)
IF(EXISTS ${Thrift_LIBS})
GET_FILENAME_COMPONENT(LINK_DIR ${Thrift_LIBS} PATH ABSOLUTE)
ELSE()
RETURN()
ENDIF()
INCLUDE_DIRECTORIES(AFTER ${Thrift_INCLUDE_DIRS}/..)
SET(CMAKE_REQUIRED_INCLUDES ${Thrift_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(AFTER ${Thrift_INCLUDE_DIRS}/..)
SET(CMAKE_REQUIRED_INCLUDES ${Thrift_INCLUDE_DIRS})
STRING(REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
STRING(REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
SET(CMAKE_REQUIRED_INCLUDES "${Thrift_INCLUDE_DIRS}/..")
CHECK_CXX_SOURCE_COMPILES(
SET(CMAKE_REQUIRED_INCLUDES "${Thrift_INCLUDE_DIRS}/..")
CHECK_CXX_SOURCE_COMPILES(
"
#include <thrift/Thrift.h>
#include <boost/shared_ptr.hpp>
......@@ -37,9 +33,9 @@ int main() {
return 0;
}
" CASSANDRASE_OK)
ENDIF()
IF(CASSANDRASE_OK)
SET(cassandra_sources
SET(cassandra_sources
ha_cassandra.cc
ha_cassandra.h
cassandra_se.h
......@@ -51,10 +47,11 @@ IF(CASSANDRASE_OK)
gen-cpp/cassandra_constants.cpp
gen-cpp/Cassandra.h)
LINK_DIRECTORIES(${LINK_DIR})
LINK_DIRECTORIES(${LINK_DIR})
SET(CASSANDRA_DEB_FILES "usr/lib/mysql/plugin/ha_cassandra.so" PARENT_SCOPE)
SET(CASSANDRA_DEB_FILES "usr/lib/mysql/plugin/ha_cassandra.so" PARENT_SCOPE)
MYSQL_ADD_PLUGIN(cassandra ${cassandra_sources} STORAGE_ENGINE MODULE_ONLY LINK_LIBRARIES thrift COMPONENT cassandra-engine)
MYSQL_ADD_PLUGIN(cassandra ${cassandra_sources} STORAGE_ENGINE
ONLY_IF CASSANDRASE_OK
MODULE_ONLY LINK_LIBRARIES thrift COMPONENT cassandra-engine)
ENDIF(CASSANDRASE_OK)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
FUNCTION(CHECK_OQGRAPH)
MESSAGE(STATUS "Configuring OQGraph")
FIND_PACKAGE(Boost)
IF(NOT Boost_FOUND)
......@@ -37,26 +38,29 @@ ENDIF()
IF(BOOST_OK)
ADD_DEFINITIONS(-DHAVE_OQGRAPH)
IF(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc" PARENT_SCOPE)
# Fix problem with judy not finding inttypes.h on Windows:
ADD_DEFINITIONS(-DJU_WIN)
ELSE(MSVC)
# Fix lp bug 1221555 with -fpermissive, so that errors in gcc 4.7 become warnings for the time being
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -fno-strict-aliasing -fpermissive")
STRING(REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -fno-strict-aliasing -fpermissive" PARENT_SCOPE)
ENDIF(MSVC)
ADD_DEFINITIONS(-DBOOST_NO_RTTI=1 -DBOOST_NO_TYPEID=1 -DBOOST_DISABLE_ASSERTS=1)
MESSAGE(STATUS "OQGraph OK")
ELSE(BOOST_OK)
MESSAGE(STATUS "Requisites for OQGraph not met. OQGraph will not be compiled")
ENDIF(BOOST_OK)
ENDFUNCTION()
MYSQL_ADD_PLUGIN(oqgraph ha_oqgraph.cc graphcore.cc graphcore-graph.cc
CHECK_OQGRAPH()
MYSQL_ADD_PLUGIN(oqgraph ha_oqgraph.cc graphcore.cc graphcore-graph.cc
oqgraph_shim.cc oqgraph_thunk.cc oqgraph_judy.cc
STORAGE_ENGINE
ONLY_IF BOOST_OK
MODULE_ONLY
RECOMPILE_FOR_EMBEDDED
COMPONENT oqgraph-engine
LINK_LIBRARIES ${Judy_LIBRARIES})
MESSAGE(STATUS "OQGraph OK")
ELSE(BOOST_OK)
MESSAGE(STATUS "Requisites for OQGraph not met. OQGraph will not be compiled")
ENDIF(BOOST_OK)
......@@ -10,6 +10,7 @@ int main() { return 0; }
ENDIF()
IF(NOT TOKUDB_OK OR WITHOUT_TOKUDB OR WITHOUT_TOKUDB_STORAGE_ENGINE)
MYSQL_ADD_PLUGIN(tokudb DISABLED)
RETURN()
ENDIF()
......
......@@ -403,17 +403,12 @@ SET(INNOBASE_SOURCES
ut/ut0vec.cc
ut/ut0wqueue.cc)
IF(WITH_INNODB)
# Legacy option
SET(WITH_INNOBASE_STORAGE_ENGINE TRUE)
IF(NOT XTRADB_OK)
MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this platform")
ENDIF()
IF(XTRADB_OK)
MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE
DEFAULT
MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE
DEFAULT ONLY_IF XTRADB_OK
RECOMPILE_FOR_EMBEDDED
LINK_LIBRARIES ${ZLIB_LIBRARY} ${LINKER_SCRIPT})
ELSE()
MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this platform")
ENDIF()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment