diff options
author | Vladislav Vaintroub <wlad@sol> | 2009-11-24 23:15:47 +0000 |
---|---|---|
committer | Vladislav Vaintroub <wlad@sol> | 2009-11-24 23:15:47 +0000 |
commit | 7377c50cb4f5b5dcb356a71787b53840d2c6ef3c (patch) | |
tree | 7ec79f7bfee3d63a780478c577294a5b729d6143 /cmake | |
parent | 9abc7cf070fcb3d8e79ef0cb4d767d11affebb25 (diff) | |
download | mariadb-git-7377c50cb4f5b5dcb356a71787b53840d2c6ef3c.tar.gz |
implement convenience libraries
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Makefile.am | 3 | ||||
-rw-r--r-- | cmake/character_sets.cmake | 8 | ||||
-rw-r--r-- | cmake/configurable_file_content.in | 1 | ||||
-rw-r--r-- | cmake/install_macros.cmake | 8 | ||||
-rw-r--r-- | cmake/libutils.cmake | 291 | ||||
-rw-r--r-- | cmake/misc.cmake | 128 | ||||
-rw-r--r-- | cmake/plugin.cmake | 27 |
7 files changed, 317 insertions, 149 deletions
diff --git a/cmake/Makefile.am b/cmake/Makefile.am index 2326f787ab8..9148334e140 100644 --- a/cmake/Makefile.am +++ b/cmake/Makefile.am @@ -1,5 +1,6 @@ EXTRA_DIST = \ cat.cmake \ + ConfigurableFileContent.in \ check_minimal_version.cmake \ create_initial_db.cmake.in \ make_dist.cmake.in \ @@ -8,7 +9,7 @@ EXTRA_DIST = \ bison.cmake \ configure.pl \ character_sets.cmake \ - misc.cmake \ + libutils.cmake \ readline.cmake \ mysql_version.cmake \ install_macros.cmake \ diff --git a/cmake/character_sets.cmake b/cmake/character_sets.cmake index c21b6c60113..82de1f27d96 100644 --- a/cmake/character_sets.cmake +++ b/cmake/character_sets.cmake @@ -33,13 +33,9 @@ latin1 latin2 latin5 latin7 macce macroman sjis swe7 tis620 ucs2 ujis utf8 utf8mb3 utf16 utf32) -IF(WIN32) - SET (EXTRA_CHARSETS "all") -ELSE() - SET (EXTRA_CHARSETS "none") -ENDIF() +SET (EXTRA_CHARSETS "all") SET(WITH_EXTRA_CHARSETS ${EXTRA_CHARSETS} CACHE - STRING "Options are: none, complex,all") + STRING "Options are: none, complex, all") IF(WITH_EXTRA_CHARSETS MATCHES "complex") diff --git a/cmake/configurable_file_content.in b/cmake/configurable_file_content.in new file mode 100644 index 00000000000..df2c382e9b3 --- /dev/null +++ b/cmake/configurable_file_content.in @@ -0,0 +1 @@ +@CMAKE_CONFIGURABLE_FILE_CONTENT@ diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake index 4fc6db6b9b7..81fc44c6a15 100644 --- a/cmake/install_macros.cmake +++ b/cmake/install_macros.cmake @@ -19,13 +19,13 @@ MACRO (INSTALL_DEBUG_SYMBOLS targets) GET_TARGET_PROPERTY(location ${target} LOCATION) GET_TARGET_PROPERTY(type ${target} TYPE) IF(NOT INSTALL_LOCATION) - IF(type MATCHES "STATIC_LIBRARY" OR type MATCHES "MODULE_LIBRARY" OR type MATCHES "SHARED_LIBRARY") + IF(type MATCHES "STATIC_LIBRARY" OR type MATCHES "MODULE_LIBRARY" OR type MATCHES "SHARED_LIBRARY") SET(INSTALL_LOCATION "lib") - ELSEIF(type MATCHES "EXECUTABLE") + ELSEIF(type MATCHES "EXECUTABLE") SET(INSTALL_LOCATION "bin") - ELSE() + ELSE() MESSAGE(FATAL_ERROR "cannot determine type of ${target}. Don't now where to install") - ENDIF() + ENDIF() ENDIF() STRING(REPLACE ".exe" ".pdb" pdb_location ${location}) STRING(REPLACE ".dll" ".pdb" pdb_location ${pdb_location}) diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake new file mode 100644 index 00000000000..ea8f809de9f --- /dev/null +++ b/cmake/libutils.cmake @@ -0,0 +1,291 @@ +# Copyright (C) 2009 Sun Microsystems, Inc +# +# 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-1301 USA + + +# This file exports macros that emulate some functionality found in GNU libtool +# on Unix systems. One such feature is convenience libraries. In this context, +# convenience library is a static library that can be linked to shared library +# On systems that force position-independent code, linking into shared library +# normally requires compilation with a special flag (often -fPIC). To enable +# linking static libraries to shared, we compile source files that come into +# static library with the PIC flag (${CMAKE_SHARED_LIBRARY_C_FLAGS} in CMake) +# Some systems, like Windows or OSX do not need special compilation (Windows +# never uses PIC and OSX always uses it). +# +# The intention behind convenience libraries is simplify the build and to reduce +# excessive recompiles. + +# Except for convenience libraries, this file provides macros to merge static +# libraries (we need it for mysqlclient) and to create shared library out of +# convenience libraries(again, for mysqlclient) + +# Following macros are exported +# - ADD_CONVENIENCE_LIBRARY(target source1...sourceN) +# This macro creates convenience library. The functionality is similar to +# ADD_LIBRARY(target STATIC source1...sourceN), the difference is that resulting +# library can always be linked to shared library +# +# - MERGE_LIBRARIES(target [STATIC|SHARED|MODULE] [linklib1 .... linklibN] +# [EXPORTS exported_func1 .... exported_func_N] +# [OUTPUT_NAME output_name] +# This macro merges several static libraries into a single one or creates a shared +# library from several convenience libraries + +# Important global flags +# - WITH_PIC : If set, it is assumed that everything is compiled as position +# independent code (that is CFLAGS/CMAKE_C_FLAGS contain -fPIC or equivalent) +# If defined, ADD_CONVENIENCE_LIBRARY does not add PIC flag to compile flags +# +# - DISABLE_SHARED: If set, it is assumed that shared libraries are not produced +# during the build. ADD_CONVENIENCE_LIBRARY does not add anything to compile flags + + +GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +IF(NOT WIN32 AND NOT CYGWIN AND NOT APPLE AND NOT WITH_PIC AND NOT DISABLE_SHARED + AND CMAKE_SHARED_LIBRARY_C_FLAGS) + SET(_SKIP_PIC 1) +ENDIF() + +# CREATE_EXPORT_FILE (VAR target api_functions) +# Internal macro, used to create source file for shared libraries that +# otherwise consists entirely of "convenience" libraries. On Windows, +# also exports API functions as dllexport. On unix, creates a dummy file +# that references all exports and this prevents linker from creating an +# empty library(there are unportable alternatives, --whole-archive) +MACRO(CREATE_EXPORT_FILE VAR TARGET API_FUNCTIONS) + IF(WIN32) + SET(DUMMY ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_dummy.c) + SET(EXPORTS ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_exports.def) + CONFIGURE_FILE_CONTENT("" ${DUMMY}) + SET(CONTENT "EXPORTS\n") + FOREACH(FUNC ${API_FUNCTIONS}) + SET(CONTENT "${CONTENT} ${FUNC}\n") + ENDFOREACH() + CONFIGURE_FILE_CONTENT(${CONTENT} ${EXPORTS}) + SET(${VAR} ${DUMMY} ${EXPORTS}) + ELSE() + SET(EXPORTS ${CMAKE_CURRENT_BINARY_DIR}/${target}_exports_file.cc) + SET(CONTENT) + FOREACH(FUNC ${API_FUNCTIONS}) + SET(CONTENT "${CONTENT} extern void* ${FUNC}\;\n") + ENDFOREACH() + SET(CONTENT "${CONTENT} void *${TARGET}_api_funcs[] = {\n") + FOREACH(FUNC ${API_FUNCTIONS}) + SET(CONTENT "${CONTENT} &${FUNC},\n") + ENDFOREACH() + SET(CONTENT "${CONTENT} (void *)0\n}\;") + CONFIGURE_FILE_CONTENT(${CONTENT} ${EXPORTS}) + SET(${VAR} ${EXPORTS}) + ENDIF() +ENDMACRO() + + +# MYSQL_ADD_CONVENIENCE_LIBRARY(name source1...sourceN) +# Create static library that can be linked to shared library. +# On systems that force position-independent code, adds -fPIC or +# equivalent flag to compile flags. +MACRO(ADD_CONVENIENCE_LIBRARY) + SET(TARGET ${ARGV0}) + SET(SOURCES ${ARGN}) + LIST(REMOVE_AT SOURCES 0) + ADD_LIBRARY(${TARGET} STATIC ${SOURCES}) + IF(NOT _SKIP_PIC) + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS + "${CMAKE_SHARED_LIBRARY_C_FLAGS}") + ENDIF() +ENDMACRO() + + +# Handy macro to parse macro arguments +MACRO(CMAKE_PARSE_ARGUMENTS prefix arg_names option_names) + SET(DEFAULT_ARGS) + FOREACH(arg_name ${arg_names}) + SET(${prefix}_${arg_name}) + ENDFOREACH(arg_name) + FOREACH(option ${option_names}) + SET(${prefix}_${option} FALSE) + ENDFOREACH(option) + + SET(current_arg_name DEFAULT_ARGS) + SET(current_arg_list) + FOREACH(arg ${ARGN}) + SET(larg_names ${arg_names}) + LIST(FIND larg_names "${arg}" is_arg_name) + IF (is_arg_name GREATER -1) + SET(${prefix}_${current_arg_name} ${current_arg_list}) + SET(current_arg_name ${arg}) + SET(current_arg_list) + ELSE (is_arg_name GREATER -1) + SET(loption_names ${option_names}) + LIST(FIND loption_names "${arg}" is_option) + IF (is_option GREATER -1) + SET(${prefix}_${arg} TRUE) + ELSE (is_option GREATER -1) + SET(current_arg_list ${current_arg_list} ${arg}) + ENDIF (is_option GREATER -1) + ENDIF (is_arg_name GREATER -1) + ENDFOREACH(arg) + SET(${prefix}_${current_arg_name} ${current_arg_list}) +ENDMACRO() + +# Write content to file, using CONFIGURE_FILE +# The advantage compared to FILE(WRITE) is that timestamp +# does not change if file already has the same content +MACRO(CONFIGURE_FILE_CONTENT content file) + SET(CMAKE_CONFIGURABLE_FILE_CONTENT + "${content}\n") + CONFIGURE_FILE( + ${MYSQL_CMAKE_SCRIPT_DIR}/configurable_file_content.in + ${file} + @ONLY) +ENDMACRO() + +# Merge static libraries into a big static lib. The resulting library +# should not not have dependencies on other static libraries. +# We use it in MySQL to merge mysys,dbug,vio etc into mysqlclient + +MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) + # To produce a library we need at least one source file. + # It is created by ADD_CUSTOM_COMMAND below and will helps + # also help to track dependencies. + SET(SOURCE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_depends.c) + ADD_LIBRARY(${TARGET} STATIC ${SOURCE_FILE}) + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME}) + + FOREACH(LIB ${LIBS_TO_MERGE}) + GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION) + GET_TARGET_PROPERTY(LIB_TYPE ${LIB} TYPE) + IF(NOT LIB_LOCATION) + # 3rd party library like libz.so. Make sure that everything + # that links to our library links to this one as well. + TARGET_LINK_LIBRARIES(${TARGET} ${LIB}) + ELSE() + # This is a target in current project + # (can be a static or shared lib) + IF(LIB_TYPE STREQUAL "STATIC_LIBRARY") + SET(STATIC_LIBS ${STATIC_LIBS} ${LIB_LOCATION}) + ADD_DEPENDENCIES(${TARGET} ${LIB}) + ELSE() + # This is a shared library our static lib depends on. + TARGET_LINK_LIBRARIES(${TARGET} ${LIB}) + ENDIF() + ENDIF() + ENDFOREACH() + + # Make the generated dummy source file depended on all static input + # libs. If input lib changes,the source file is touched + # which causes the desired effect (relink). + ADD_CUSTOM_COMMAND( + OUTPUT ${SOURCE_FILE} + COMMAND ${CMAKE_COMMAND} -E touch ${SOURCE_FILE} + DEPENDS ${STATIC_LIBS}) + + IF(MSVC) + # To merge libs, just pass them to lib.exe command line. + SET(LINKER_EXTRA_FLAGS "") + FOREACH(LIB ${STATIC_LIBS}) + SET(LINKER_EXTRA_FLAGS "${LINKER_EXTRA_FLAGS} ${LIB}") + ENDFOREACH() + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS + "${LINKER_EXTRA_FLAGS}") + ELSE() + GET_TARGET_PROPERTY(TARGET_LOCATION ${TARGET} LOCATION) + IF(APPLE) + # Use OSX's libtool to merge archives (ihandles universal + # binaries properly) + ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD + COMMAND rm ${TARGET_LOCATION} + COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION} + ${STATIC_LIBS} + ) + ELSE() + # Generic Unix, Cygwin or MinGW. In post-build step, call + # script, that extracts objects from archives with "ar x" + # and repacks them with "ar r" + SET(TARGET ${TARGET}) + CONFIGURE_FILE( + ${MYSQL_CMAKE_SCRIPT_DIR}/merge_archives_unix.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake + @ONLY + ) + ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD + COMMAND rm ${TARGET_LOCATION} + COMMAND ${CMAKE_COMMAND} -P + ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake + ) + ENDIF() + ENDIF() +ENDMACRO() + +# Create libs from libs. +# Merges static libraries, creates shared libraries out of convenience libraries. +# MYSQL_MERGE_LIBRARIES(target [STATIC|SHARED|MODULE] +# [linklib1 .... linklibN] +# [EXPORTS exported_func1 .... exportedFuncN] +# [OUTPUT_NAME output_name] +#) +MACRO(MERGE_LIBRARIES) + CMAKE_PARSE_ARGUMENTS(ARG + "EXPORTS;OUTPUT_NAME" + "STATIC;SHARED;MODULE" + ${ARGN} + ) + LIST(GET ARG_DEFAULT_ARGS 0 TARGET) + SET(LIBS ${ARG_DEFAULT_ARGS}) + LIST(REMOVE_AT LIBS 0) + IF(ARG_STATIC) + IF (NOT "${ARG_OUTPUT_NAME}") + SET(ARG_OUTPUT_NAME ${TARGET}) + ENDIF() + MERGE_STATIC_LIBS(${TARGET} ${ARG_OUTPUT_NAME} "${LIBS}") + ELSEIF(ARG_SHARED OR ARG_MODULE) + IF(ARG_SHARED) + SET(LIBTYPE SHARED) + ELSE() + SET(LIBTYPE MODULE) + ENDIF() + # check for non-PIC libraries + IF(NOT _SKIP_PIC) + FOREACH(LIB ${LIBS}) + GET_TARGET_PROPERTY(${LIB} TYPE LIBTYPE) + IF(LIBTYPE STREQUAL "STATIC_LIBRARY") + GET_TARGET_PROPERTY(LIB COMPILE_FLAGS LIB_COMPILE_FLAGS) + STRING(REPLACE "${CMAKE_SHARED_LIBRARY_C_FLAGS}" + "<PIC_FLAG>" LIB_COMPILE_FLAGS ${LIB_COMPILE_FLAG}) + IF(NOT LIB_COMPILE_FLAGS MATCHES "<PIC_FLAG>") + MESSAGE(FATAL_ERROR + "Attempted to link non-PIC static library ${LIB} to shared library ${TARGET}\n" + "Please use ADD_CONVENIENCE_LIBRARY, instead of ADD_LIBRARY for ${LIB}" + ) + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + CREATE_EXPORT_FILE(SRC ${TARGET} "${EXPORTS}") + ADD_LIBRARY(${TARGET} SHARED ${SRC}) + TARGET_LINK_LIBRARIES(${TARGET} ${LIBS}) + IF(ARG_OUTPUT_NAME) + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME "${ARG_OUTPUT_NAME}") + ENDIF() + # Disallow undefined symbols in shared libraries, but allow for modules + # (they export from loading executable) + IF(LIBTYPE MATCHES "SHARED" AND CMAKE_SYSTEM_TYPE MATCHES "Linux") + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES LINK_FLAGS "-Wl,--no-undefined") + ENDIF() + ELSE() + MESSAGE(FATAL_ERROR "Unknown library type") + ENDIF() +ENDMACRO() + diff --git a/cmake/misc.cmake b/cmake/misc.cmake deleted file mode 100644 index c73e66ef3d7..00000000000 --- a/cmake/misc.cmake +++ /dev/null @@ -1,128 +0,0 @@ -# Copyright (C) 2009 Sun Microsystems, Inc -# -# 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-1301 USA - -# Merge static libraries. -MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) - # To produce a library we need at least one source file. - # It is created by ADD_CUSTOM_COMMAND below and will helps - # also help to track dependencies. - SET(SOURCE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_depends.c) - ADD_LIBRARY(${TARGET} STATIC ${SOURCE_FILE}) - SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME}) - - FOREACH(LIB ${LIBS_TO_MERGE}) - GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION) - GET_TARGET_PROPERTY(LIB_TYPE ${LIB} TYPE) - IF(NOT LIB_LOCATION) - # 3rd party library like libz.so. Make sure that everything - # that links to our library links to this one as well. - TARGET_LINK_LIBRARIES(${TARGET} ${LIB}) - ELSE() - # This is a target in current project - # (can be a static or shared lib) - IF(LIB_TYPE STREQUAL "STATIC_LIBRARY") - SET(STATIC_LIBS ${STATIC_LIBS} ${LIB_LOCATION}) - ADD_DEPENDENCIES(${TARGET} ${LIB}) - ELSE() - # This is a shared library our static lib depends on. - TARGET_LINK_LIBRARIES(${TARGET} ${LIB}) - ENDIF() - ENDIF() - ENDFOREACH() - - # Make the generated dummy source file depended on all static input - # libs. If input lib changes,the source file is touched - # which causes the desired effect (relink). - ADD_CUSTOM_COMMAND( - OUTPUT ${SOURCE_FILE} - COMMAND ${CMAKE_COMMAND} -E touch ${SOURCE_FILE} - DEPENDS ${STATIC_LIBS}) - - IF(MSVC) - # To merge libs, just pass them to lib.exe command line. - SET(LINKER_EXTRA_FLAGS "") - FOREACH(LIB ${STATIC_LIBS}) - SET(LINKER_EXTRA_FLAGS "${LINKER_EXTRA_FLAGS} ${LIB}") - ENDFOREACH() - SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS - "${LINKER_EXTRA_FLAGS}") - ELSE() - GET_TARGET_PROPERTY(TARGET_LOCATION ${TARGET} LOCATION) - IF(APPLE) - # Use OSX's libtool to merge archives (ihandles universal - # binaries properly) - ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD - COMMAND rm ${TARGET_LOCATION} - COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION} - ${STATIC_LIBS} - ) - ELSE() - # Generic Unix, Cygwin or MinGW. In post-build step, call - # script, that extracts objects from archives with "ar x" - # and repacks them with "ar r" - SET(TARGET ${TARGET}) - CONFIGURE_FILE( - ${CMAKE_SOURCE_DIR}/cmake/merge_archives_unix.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake - @ONLY - ) - ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD - COMMAND rm ${TARGET_LOCATION} - COMMAND ${CMAKE_COMMAND} -P - ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake - ) - ENDIF() - ENDIF() -ENDMACRO() - -# Convert static library to shared -MACRO(STATIC_TO_SHARED STATIC_LIB SHARED_LIB EXPORTS_FILE) - IF(NOT MSVC) - MESSAGE(FATAL_ERROR - "Cannot convert static ${STATIC_LIB} to shared ${TARGET} library." - ) - ENDIF() - - # Need one source file. - SET(SOURCE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${SHARED_LIB}_dummy.c) - ADD_CUSTOM_COMMAND( - OUTPUT ${SOURCE_FILE} - COMMAND ${CMAKE_COMMAND} -E touch ${SOURCE_FILE} - ) - - ADD_LIBRARY(${SHARED_LIB} SHARED ${SOURCE_FILE} ${EXPORTS_FILE}) - TARGET_LINK_LIBRARIES(${SHARED_LIB} ${STATIC_LIB}) -ENDMACRO() - -MACRO(SET_TARGET_SOURCEDIR TARGET) - SET(${TARGET}_SOURCEDIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "source directory for a target") -ENDMACRO() - -# Handy macro to use when source projects maybe used somewhere else -# For example, embedded or client library may recompile mysys sources -# In such cases, using absolute names in ADD_LIBRARY has the advantage that -# GET_TARGET_PROPERTY(xxx SOURCES) also returns absolute names, so there is -# no need to know the base directory of a target. -MACRO(USE_ABSOLUTE_FILENAMES FILELIST) - # Use absolute file paths for sources - # It helps when building embedded where we need to - # sources files for the plugin to recompile. - SET(RESOLVED_PATHS) - FOREACH(FILE ${${FILELIST}}) - GET_FILENAME_COMPONENT(ABSOLUTE_PATH ${FILE} ABSOLUTE) - LIST(APPEND RESOLVED_PATHS ${ABSOLUTE_PATH}) - ENDFOREACH() - SET(${FILELIST} ${RESOLVED_PATHS}) -ENDMACRO() diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 58a3dafa2f4..40e31aeea02 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -72,19 +72,26 @@ MACRO(MYSQL_PLUGIN plugin) ENDIF() - USE_ABSOLUTE_FILENAMES(${plugin}_SOURCES) - IF (WITH_${plugin} AND ${plugin}_PLUGIN_STATIC) ADD_DEFINITIONS(-DMYSQL_SERVER) #Create static library. ADD_LIBRARY(${target} ${${plugin}_SOURCES}) DTRACE_INSTRUMENT(${target}) ADD_DEPENDENCIES(${target} GenError) + IF(WITH_EMBEDDED_SERVER AND NOT ${plugin}_PLUGIN_DYNAMIC) + # Recompile couple of plugins for embedded + ADD_LIBRARY(${target}_embedded ${${plugin}_SOURCES}) + DTRACE_INSTRUMENT(${target}_embedded) + SET_TARGET_PROPERTIES(${target}_embedded + PROPERTIES COMPILE_DEFINITIONS "EMBEDDED_LIBRARY") + ADD_DEPENDENCIES(${target}_embedded GenError) + ENDIF() IF(${plugin}_LIBS) TARGET_LINK_LIBRARIES(${target} ${${plugin}_LIBS}) - ENDIF() + ENDIF() + SET_TARGET_PROPERTIES(${target} PROPERTIES - OUTPUT_NAME "${${plugin}_PLUGIN_STATIC}") + OUTPUT_NAME "${${plugin}_PLUGIN_STATIC}") # Update mysqld dependencies SET (MYSQLD_STATIC_PLUGIN_LIBS ${MYSQLD_STATIC_PLUGIN_LIBS} ${target} PARENT_SCOPE) @@ -92,6 +99,7 @@ MACRO(MYSQL_PLUGIN plugin) PARENT_SCOPE) SET(${with_var} ON CACHE BOOL "Link ${plugin} statically to the server" FORCE) + ELSEIF(NOT WITHOUT_${plugin} AND ${plugin}_PLUGIN_DYNAMIC AND NOT WITHOUT_DYNAMIC_PLUGINS) @@ -105,22 +113,21 @@ MACRO(MYSQL_PLUGIN plugin) SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX "") TARGET_LINK_LIBRARIES (${target} mysqlservices) - # Plugin uses symbols defined in mysqld executable. + # Plugin uses symbols defined in mysqld executable. # Some operating systems like Windows and OSX and are pretty strict about - # unresolved symbols. Others are less strict and allow unresolved symbols + # 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). # Thus we skip TARGET_LINK_LIBRARIES on Linux, as it would only generate # an additional dependency. - IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") + IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") TARGET_LINK_LIBRARIES (${target} mysqld) - ENDIF() - + ENDIF() ADD_DEPENDENCIES(${target} GenError) IF(${plugin}_PLUGIN_DYNAMIC) SET_TARGET_PROPERTIES(${target} PROPERTIES - OUTPUT_NAME "${${plugin}_PLUGIN_DYNAMIC}") + OUTPUT_NAME "${${plugin}_PLUGIN_DYNAMIC}") ENDIF() # Update cache "WITH" variable for plugins that support static linking |