Commit 7377c50c authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

implement convenience libraries

parent 9abc7cf0
......@@ -61,7 +61,7 @@ INCLUDE(cmake/zlib.cmake)
INCLUDE(cmake/ssl.cmake)
INCLUDE(cmake/readline.cmake)
INCLUDE(cmake/mysql_version.cmake)
INCLUDE(cmake/misc.cmake)
INCLUDE(cmake/libutils.cmake)
INCLUDE(cmake/dtrace.cmake)
INCLUDE(cmake/plugin.cmake)
INCLUDE(cmake/install_macros.cmake)
......
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 \
......
......@@ -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")
......
@CMAKE_CONFIGURABLE_FILE_CONTENT@
......@@ -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})
......
This diff is collapsed.
# 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()
......@@ -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
......
......@@ -18,6 +18,5 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/include
)
SET(DBUG_SOURCES dbug.c sanity.c)
USE_ABSOLUTE_FILENAMES(DBUG_SOURCES)
ADD_LIBRARY(dbug ${DBUG_SOURCES})
ADD_CONVENIENCE_LIBRARY(dbug ${DBUG_SOURCES})
TARGET_LINK_LIBRARIES(dbug mysys)
......@@ -27,7 +27,7 @@ ${CMAKE_SOURCE_DIR}/storage/ndb/include/mgmapi)
IF(NOT CMAKE_CROSSCOMPILING)
ADD_EXECUTABLE(comp_err comp_err.c)
TARGET_LINK_LIBRARIES(comp_err ${ZLIB_LIBRARY} mysys)
TARGET_LINK_LIBRARIES(comp_err mysys)
ENDIF()
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/include/mysqld_error.h
......
......@@ -29,6 +29,6 @@ ENDIF()
SET(YASSL_SOURCES src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp src/handshake.cpp src/lock.cpp
src/log.cpp src/socket_wrapper.cpp src/ssl.cpp src/timer.cpp src/yassl_error.cpp
src/yassl_imp.cpp src/yassl_int.cpp)
USE_ABSOLUTE_FILENAMES(YASSL_SOURCES)
ADD_LIBRARY(yassl ${YASSL_SOURCES})
ADD_CONVENIENCE_LIBRARY(yassl ${YASSL_SOURCES})
......@@ -18,9 +18,6 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
ADD_DEFINITIONS(${SSL_DEFINES})
IF(PREVENT_CPP_RUNTIME)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PREVENT_CPP_RUNTIME}")
ENDIF()
SET(TAOCRYPT_SOURCES src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp src/asn.cpp src/coding.cpp
src/des.cpp src/dh.cpp src/dsa.cpp src/file.cpp src/hash.cpp src/integer.cpp src/md2.cpp
src/md4.cpp src/md5.cpp src/misc.cpp src/random.cpp src/ripemd.cpp src/rsa.cpp src/sha.cpp
......@@ -29,6 +26,5 @@ SET(TAOCRYPT_SOURCES src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp
include/error.hpp include/file.hpp include/hash.hpp include/hmac.hpp include/integer.hpp
include/md2.hpp include/md5.hpp include/misc.hpp include/modarith.hpp include/modes.hpp
include/random.hpp include/ripemd.hpp include/rsa.hpp include/sha.hpp)
USE_ABSOLUTE_FILENAMES(TAOCRYPT_SOURCES)
ADD_LIBRARY(taocrypt ${TAOCRYPT_SOURCES})
ADD_CONVENIENCE_LIBRARY(taocrypt ${TAOCRYPT_SOURCES})
......@@ -24,13 +24,115 @@ INCLUDE_DIRECTORIES(
${ZLIB_INCLUDE_DIR})
ADD_DEFINITIONS(${SSL_DEFINES})
SET(CLIENT_API_FUNCTIONS
load_defaults
mysql_thread_end
mysql_thread_init
myodbc_remove_escape
mysql_affected_rows
mysql_autocommit
mysql_stmt_bind_param
mysql_stmt_bind_result
mysql_change_user
mysql_character_set_name
mysql_close
mysql_commit
mysql_data_seek
mysql_debug
mysql_dump_debug_info
mysql_eof
mysql_errno
mysql_error
mysql_escape_string
mysql_hex_string
mysql_stmt_execute
mysql_stmt_fetch
mysql_stmt_fetch_column
mysql_fetch_field
mysql_fetch_field_direct
mysql_fetch_fields
mysql_fetch_lengths
mysql_fetch_row
mysql_field_count
mysql_field_seek
mysql_field_tell
mysql_free_result
mysql_get_client_info
mysql_get_host_info
mysql_get_proto_info
mysql_get_server_info
mysql_get_client_version
mysql_get_ssl_cipher
mysql_info
mysql_init
mysql_insert_id
mysql_kill
mysql_set_server_option
mysql_list_dbs
mysql_list_fields
mysql_list_processes
mysql_list_tables
mysql_more_results
mysql_next_result
mysql_num_fields
mysql_num_rows
mysql_odbc_escape_string
mysql_options
mysql_stmt_param_count
mysql_stmt_param_metadata
mysql_ping
mysql_stmt_result_metadata
mysql_query
mysql_read_query_result
mysql_real_connect
mysql_real_escape_string
mysql_real_query
mysql_refresh
mysql_rollback
mysql_row_seek
mysql_row_tell
mysql_select_db
mysql_stmt_send_long_data
mysql_send_query
mysql_shutdown
mysql_ssl_set
mysql_stat
mysql_stmt_affected_rows
mysql_stmt_close
mysql_stmt_reset
mysql_stmt_data_seek
mysql_stmt_errno
mysql_stmt_error
mysql_stmt_free_result
mysql_stmt_num_rows
mysql_stmt_row_seek
mysql_stmt_row_tell
mysql_stmt_store_result
mysql_store_result
mysql_thread_id
mysql_thread_safe
mysql_use_result
mysql_warning_count
mysql_stmt_sqlstate
mysql_sqlstate
mysql_get_server_version
mysql_stmt_prepare
mysql_stmt_init
mysql_stmt_insert_id
mysql_stmt_attr_get
mysql_stmt_attr_set
mysql_stmt_field_count
mysql_set_local_infile_default
mysql_set_local_infile_handler
mysql_embedded
mysql_server_init
mysql_server_end
mysql_set_character_set
mysql_get_character_set_info
CACHE INTERNAL "Functions exported by client API"
#Remove -fno-implicit-templates
#(yassl sources cannot be compiled with it)
STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ADD_DEFINITIONS(-DDISABLE_DTRACE)
)
SET(CLIENT_SOURCES
get_password.c
......@@ -42,71 +144,22 @@ SET(CLIENT_SOURCES
../sql-common/pack.c
../sql/password.c
)
ADD_LIBRARY(clientlib STATIC ${CLIENT_SOURCES})
ADD_CONVENIENCE_LIBRARY(clientlib ${CLIENT_SOURCES})
DTRACE_INSTRUMENT(clientlib)
ADD_DEPENDENCIES(clientlib GenError)
# Merge several static libraries into one big mysqlclient.
SET(LIBS dbug strings vio mysys ${ZLIB_LIBRARY} ${SSL_LIBRARIES})
MERGE_STATIC_LIBS(mysqlclient mysqlclient "${LIBS};clientlib")
ADD_DEPENDENCIES(mysqlclient GenError)
SET_TARGET_PROPERTIES(mysqlclient PROPERTIES CLEAN_DIRECT_OUTPUT 1)
# Make shared client library
IF(WIN32)
SET(SHARED_OUTPUT_NAME libmysql)
ELSE()
SET(SHARED_OUTPUT_NAME mysqlclient)
ENDIF()
# On Windows, we can make a shared library out of static.
# On Unix, we need to recompile all sources, unless we compiled with -fPIC, in
# which case we can link static libraries to shared.
IF(MSVC)
STATIC_TO_SHARED(mysqlclient libmysql libmysql.def)
ELSE()
SET(LIBMYSQL_SOURCES ${CLIENT_SOURCES})
IF(NOT WITH_PIC)
# Add all sources that come into common static libs.
FOREACH(LIB ${LIBS})
GET_TARGET_PROPERTY(SRC ${LIB} SOURCES)
IF (NOT SRC)
# This must be system shared lib (zlib or openssl)
# Users of libmysql must link with it too.
LIST(APPEND OS_LIBS ${LIB})
ELSE()
LIST(APPEND LIBMYSQL_SOURCES ${SRC})
ENDIF()
ENDFOREACH()
# Some extra flags as in mysys
IF(CMAKE_COMPILER_IS_GNUCC AND NOT HAVE_CXX_NEW)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/mysys/my_new.cc
PROPERTIES COMPILE_FLAGS "-DUSE_MYSYS_NEW")
ENDIF()
ENDIF()
ADD_LIBRARY(libmysql SHARED ${LIBMYSQL_SOURCES})
ADD_DEPENDENCIES(libmysql GenError)
SET_TARGET_PROPERTIES(libmysql PROPERTIES OUTPUT_NAME ${SHARED_OUTPUT_NAME}
SOVERSION "${SHARED_LIB_MAJOR_VERSION}.0")
SET_TARGET_PROPERTIES(libmysql PROPERTIES CLEAN_DIRECT_OUTPUT 1)
IF(WITH_PIC)
TARGET_LINK_LIBRARIES(libmysql ${LIBS})
ENDIF()
IF(OS_LIBS)
TARGET_LINK_LIBRARIES(libmysql ${OS_LIBS})
ENDIF()
ENDIF()
SET(LIBS clientlib dbug strings vio mysys ${ZLIB_LIBRARY} ${SSL_LIBRARIES})
# Merge several convenience libraries into one big mysqlclient
# and link them together into shared library.
MERGE_LIBRARIES(mysqlclient STATIC ${LIBS})
MERGE_LIBRARIES(libmysql SHARED ${LIBS} EXPORTS ${CLIENT_API_FUNCTIONS})
IF(UNIX)
# Name of shared library is mysqlclient on Unix
SET_TARGET_PROPERTIES(libmysql PROPERTIES OUTPUT_NAME mysqlclient)
# clean direct output needs to be set several targets have the same name
#(mysqlclient in this case)
SET_TARGET_PROPERTIES(mysqlclient PROPERTIES CLEAN_DIRECT_OUTPUT 1)
# Install links to shared and static libraries
# (append _r to base name)
INSTALL_SYMLINK(${CMAKE_SHARED_LIBRARY_PREFIX}mysqlclient_r libmysql lib)
......@@ -114,4 +167,4 @@ IF(UNIX)
ENDIF()
INSTALL(TARGETS mysqlclient libmysql DESTINATION lib)
INSTALL_DEBUG_SYMBOLS( "mysqlclient;libmysql")
INSTALL_DEBUG_SYMBOLS("mysqlclient;libmysql")
LIBRARY LIBMYSQL
VERSION 6.0
EXPORTS
_dig_vec_lower
_dig_vec_upper
bmove_upp
delete_dynamic
free_defaults
getopt_compare_strings
getopt_ull_limit_value
handle_options
init_dynamic_array
insert_dynamic
int2str
is_prefix
list_add
list_delete
load_defaults
my_end
my_getopt_print_errors
my_init
my_malloc
my_memdup
my_no_flags_free
my_path
mysql_get_parameters
my_print_help
my_print_variables
my_realloc
my_strdup
mysql_thread_end
mysql_thread_init
myodbc_remove_escape
......@@ -118,22 +92,12 @@ EXPORTS
mysql_stmt_sqlstate
mysql_sqlstate
mysql_get_server_version
set_dynamic
strcend
strcont
strdup_root
strfill
strinstr
strmake
strmov
strxmov
mysql_stmt_prepare
mysql_stmt_init
mysql_stmt_insert_id
mysql_stmt_attr_get
mysql_stmt_attr_set
mysql_stmt_field_count
client_errors
mysql_set_local_infile_default
mysql_set_local_infile_handler
mysql_embedded
......@@ -141,5 +105,3 @@ EXPORTS
mysql_server_end
mysql_set_character_set
mysql_get_character_set_info
get_defaults_options
modify_defaults_file
......@@ -13,7 +13,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
ADD_DEFINITIONS(-DMYSQL_SERVER -DEMBEDDED_LIBRARY -DDISABLE_DTRACE
ADD_DEFINITIONS(-DMYSQL_SERVER -DEMBEDDED_LIBRARY
${SSL_DEFINES})
INCLUDE_DIRECTORIES(
......@@ -29,7 +29,7 @@ ${SSL_INTERNAL_INCLUDE_DIRS}
${NDB_CLUSTER_INCLUDES}
${CMAKE_SOURCE_DIR}/sql/backup
)
SET(GEN_SOURCES
${CMAKE_BINARY_DIR}/sql/sql_yacc.h
${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
......@@ -37,23 +37,8 @@ ${CMAKE_BINARY_DIR}/sql/lex_hash.h
)
SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED TRUE)
SET(LIBS dbug strings regex mysys vio ${ZLIB_LIBRARY} ${SSL_LIBRARIES}
${MYSQLD_STATIC_PLUGIN_LIBS} ${NDB_CLIENT_LIBS})
# Quirk: recompile selected storage engines with -DEMBEDDED_LIBRARY
# They depend on internal structures like THD that is different in embedded.
SET(RECOMPILE_ENGINES myisam myisammrg heap ndbcluster)
FOREACH(ENGINE ${RECOMPILE_ENGINES})
LIST(REMOVE_ITEM LIBS ${ENGINE})
GET_TARGET_PROPERTY(SRC ${ENGINE} SOURCES)
IF(SRC)
LIST(APPEND ENGINE_SOURCES ${SRC})
ENDIF()
ENDFOREACH()
SET(LIBMYSQLD_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../libmysql/libmysql.c ../libmysql/errmsg.c ../client/get_password.c
../sql-common/client.c ../sql-common/my_time.c
../sql-common/my_user.c ../sql-common/pack.c
......@@ -96,13 +81,13 @@ SET(LIBMYSQLD_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../sql/sql_signal.cc ../sql/rpl_handler.cc
${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
${GEN_SOURCES}
${ENGINE_SOURCES}
${MYSYS_LIBWRAP_SOURCE}
)
ADD_LIBRARY(mysqlserver_int STATIC ${LIBMYSQLD_SOURCES})
ADD_DEPENDENCIES(mysqlserver_int GenError GenServerSource)
ADD_LIBRARY(sql_embedded STATIC ${SQL_EMBEDDED_SOURCES})
DTRACE_INSTRUMENT(sql_embedded)
ADD_DEPENDENCIES(sql_embedded GenError GenServerSource)
# On Windows, static embedded server library is called mysqlserver.lib
# On Unix, it is libmysqld.a
......@@ -112,17 +97,31 @@ ELSE()
SET(MYSQLSERVER_OUTPUT_NAME mysqld)
ENDIF()
# Merge slim mysqlserver_int with other libraries like mysys to create a big
# static library that contains everything.
MERGE_STATIC_LIBS(mysqlserver ${MYSQLSERVER_OUTPUT_NAME}
"mysqlserver_int;${LIBS}")
IF(LIBWRAP_LIBRARY)
TARGET_LINK_LIBRARIES(mysqlserver ${LIBWRAP_LIBRARY})
ENDIF()
SET(LIBS
dbug strings regex mysys vio
${ZLIB_LIBRARY} ${SSL_LIBRARIES} ${LIBWRAP_LIBRARY}
${MYSQLD_STATIC_PLUGIN_LIBS} ${NDB_CLIENT_LIBS}
sql_embedded
)
# Some storage engine were compiled for embedded specifically
# (with corresponding target ${engine}_embedded)
SET(EMBEDDED_LIBS)
FOREACH(LIB ${LIBS})
GET_TARGET_PROPERTY(EMBEDDED_LOCATION ${LIB}_embedded LOCATION)
IF(EMBEDDED_LOCATION)
LIST(APPEND EMBEDDED_LIBS ${LIB}_embedded)
ELSE()
LIST(APPEND EMBEDDED_LIBS ${LIB})
ENDIF()
ENDFOREACH()
MERGE_LIBRARIES(mysqlserver STATIC ${EMBEDDED_LIBS}
OUTPUT_NAME ${MYSQLSERVER_OUTPUT_NAME})
INSTALL(TARGETS mysqlserver DESTINATION lib)
IF(MSVC)
STATIC_TO_SHARED(mysqlserver libmysqld libmysqld.def)
MERGE_LIBRARIES(libmysqld SHARED ${LIBS} EXPORTS ${CLIENT_API_FUNCTIONS})
INSTALL(TARGETS libmysqld DESTINATION lib)
ENDIF()
......@@ -56,7 +56,6 @@ IF(UNIX)
SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_atomic.c)
SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_getncpus.c)
ENDIF()
USE_ABSOLUTE_FILENAMES(MYSYS_SOURCES)
ADD_LIBRARY(mysys ${MYSYS_SOURCES})
ADD_CONVENIENCE_LIBRARY(mysys ${MYSYS_SOURCES})
TARGET_LINK_LIBRARIES(mysys dbug strings ${ZLIB_LIBRARY})
DTRACE_INSTRUMENT(mysys)
......@@ -17,6 +17,4 @@
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
SET(REGEX_SOURCES regcomp.c regerror.c regexec.c regfree.c reginit.c)
USE_ABSOLUTE_FILENAMES(REGEX_SOURCES)
ADD_LIBRARY(regex ${REGEX_SOURCES})
ADD_CONVENIENCE_LIBRARY(regex STATIC ${REGEX_SOURCES})
......@@ -24,6 +24,4 @@ SET(STRINGS_SOURCES bchange.c bcmp.c bfill.c bmove512.c bmove_upp.c ctype-big5.c
strtod.c strtol.c strtoll.c strtoul.c strtoull.c strxmov.c strxnmov.c xml.c
my_strchr.c strcont.c strinstr.c strnlen.c strappend.c)
USE_ABSOLUTE_FILENAMES(STRINGS_SOURCES)
ADD_LIBRARY(strings ${STRINGS_SOURCES})
ADD_CONVENIENCE_LIBRARY(strings STATIC ${STRINGS_SOURCES})
......@@ -19,7 +19,4 @@ ${SSL_INCLUDE_DIRS})
ADD_DEFINITIONS(${SSL_DEFINES})
SET(VIO_SOURCES vio.c viosocket.c viossl.c viosslfactories.c)
USE_ABSOLUTE_FILENAMES(VIO_SOURCES)
ADD_LIBRARY(vio ${VIO_SOURCES})
ADD_DEPENDENCIES(vio GenError)
ADD_CONVENIENCE_LIBRARY(vio ${VIO_SOURCES})
......@@ -18,10 +18,8 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/zlib
)
SET(ZLIB_SOURCES adler32.c compress.c crc32.c crc32.h deflate.c deflate.h gzio.c infback.c inffast.c inffast.h
inffixed.h inflate.c inflate.h inftrees.c inftrees.h trees.c trees.h uncompr.c zconf.h zlib.h
zutil.c zutil.h)
USE_ABSOLUTE_FILENAMES(ZLIB_SOURCES)
ADD_LIBRARY(zlib ${ZLIB_SOURCES})
ADD_CONVENIENCE_LIBRARY(zlib ${ZLIB_SOURCES})
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