Add C/C as a submodule in libmariadb/

also
* fix includes
* rename cmake macros and targets to avoid name clashes
This commit is contained in:
Sergei Golubchik 2016-09-04 13:26:30 +02:00
parent ca02ad4fb0
commit 1fc49d3d1a
7 changed files with 49 additions and 172 deletions

View file

@ -362,8 +362,7 @@ ADD_SUBDIRECTORY(strings)
ADD_SUBDIRECTORY(vio)
ADD_SUBDIRECTORY(mysys)
ADD_SUBDIRECTORY(mysys_ssl)
ADD_SUBDIRECTORY(libmariadb)
ADD_SUBDIRECTORY(libmysql)
INCLUDE(mariadb_connector_c) # this does ADD_SUBDIRECTORY(libmariadb)
ADD_SUBDIRECTORY(client)
ADD_SUBDIRECTORY(extra)
ADD_SUBDIRECTORY(libservices)

View file

@ -19,7 +19,6 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/mysys_ssl
${ZLIB_INCLUDE_DIR}
${SSL_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/libmysql
${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/strings
${MY_READLINE_INCLUDE_DIR}
@ -28,16 +27,16 @@ INCLUDE_DIRECTORIES(
ADD_DEFINITIONS(-DHAVE_OPENSSL=1)
INCLUDE_DIRECTORIES(
BEFORE
${CONNECTOR_C_INSTALLDIR}/include/mariadb)
INCLUDE_DIRECTORIES(BEFORE
${CMAKE_BINARY_DIR}/libmariadb/include
${CMAKE_SOURCE_DIR}/libmariadb/include)
## We will need libeay32.dll and ssleay32.dll when running client executables.
COPY_OPENSSL_DLLS(copy_openssl_client)
ADD_DEFINITIONS(-DHAVE_LIBMARIADB=1)
SET(CLIENT_LIB ${CONNECTOR_C_LIBS} mysys)
SET(CLIENT_LIB mariadbclient mysys)
ADD_DEFINITIONS(${SSL_DEFINES})
MYSQL_ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc
@ -100,7 +99,7 @@ PROPERTIES HAS_CXX TRUE)
FOREACH(t mysql mysqltest mysqltest mysqlcheck mysqldump mysqlimport mysql_upgrade mysqlshow mysql_plugin mysqlbinlog
mysqladmin mysqlslap async_example)
ADD_DEPENDENCIES(${t} GenError mariadb_connector_c)
ADD_DEPENDENCIES(${t} GenError ${CLIENT_LIB})
ENDFOREACH()
ADD_DEFINITIONS(-DHAVE_DLOPEN)

View file

@ -58,13 +58,13 @@ IF(WIN32 OR CYGWIN OR APPLE OR WITH_PIC OR DISABLE_SHARED OR NOT CMAKE_SHARED_LI
ENDIF()
INCLUDE(CMakeParseArguments)
# CREATE_EXPORT_FILE (VAR target api_functions)
# CREATE_EXPORTS_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)
MACRO(CREATE_EXPORTS_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)
@ -255,7 +255,7 @@ MACRO(MERGE_LIBRARIES)
ENDIF()
ENDFOREACH()
ENDIF()
CREATE_EXPORT_FILE(SRC ${TARGET} "${ARG_EXPORTS}")
CREATE_EXPORTS_FILE(SRC ${TARGET} "${ARG_EXPORTS}")
IF(NOT ARG_NOINSTALL)
ADD_VERSION_INFO(${TARGET} SHARED SRC)
ENDIF()

View file

@ -1,32 +1,36 @@
#
# Configuration options for Connector/C
#
IF(WIN32)
# todo: libcurl for windows
SET(OPT CONC_)
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(CONC_WITH_RTC ON)
ENDIF()
SET(CONC_WITH_SIGNCODE ${SIGNCODE})
SET(SIGN_OPTIONS ${SIGNTOOL_PARAMETERS})
IF(TARGET zlib)
GET_PROPERTY(ZLIB_LIBRARY_LOCATION TARGET zlib PROPERTY LOCATION)
ELSE()
SET(CC_LIBS ${LIBDL} ${LIBM} ${CMAKE_THREAD_LIBS_INIT})
FIND_PACKAGE(OpenSSL)
#FIND_PACKAGE(GnuTLS)
IF(OPENSSL_FOUND)
SET(CC_LIBS ${CC_LIBS} ${OPENSSL_LIBRARIES})
SET(CC_CMAKE_OPTS "-DWITH_SSL=OPENSSL")
ELSEIF (GNUTLS_FOUND)
SET(CC_LIBS ${CC_LIBS} ${GNUTLS_LIBRARY})
SET(CC_CMAKE_OPTS "-DWITH_SSL=GNUTLS")
SET(ZLIB_LIBRARY_LOCATION ${ZLIB_LIBRARY})
ENDIF()
IF(SSL_DEFINES MATCHES "YASSL")
IF(WIN32)
SET(CONC_WITH_SSL "SCHANNEL")
ELSE()
SET(CC_CMAKE_OPTS "-DWITH_SSL=OFF")
ENDIF()
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/iconv.cmake)
IF(ICONV_FOUND)
IF(ICONV_EXTERNAL)
IF(NOT ICONV_LIBRARIES MATCHES "libc.so")
SET(CC_LIBS ${CC_LIBS} ${ICONV_LIBRARIES})
ENDIF()
ENDIF()
SET(CONC_WITH_SSL "GNUTLS") # that's what debian wants, right?
ENDIF()
ELSE()
SET(CONC_WITH_SSL "OPENSSL")
ENDIF()
IF(NOT TARGET zlib)
SET(CC_LIBS ${CC_LIBS} ${ZLIB_LIBRARY})
SET(CONC_WITH_CURL OFF)
SET(CONC_WITH_MYSQLCOMPAT ON)
IF (INSTALL_LAYOUT STREQUAL "RPM")
SET(CONC_INSTALL_LAYOUT "RPM")
ELSE()
SET(CONC_INSTALL_LAYOUT "DEFAULT")
ENDIF()
SET(mysqlclient_LIB_DEPENDS ${CC_LIBS} CACHE INTERNAL "")
MARK_AS_ADVANCED(CC_LIBS CC_CMAKE_OPTS)
MESSAGE("== Configuring MariaDB Connector/C")
ADD_SUBDIRECTORY(libmariadb)

View file

@ -58,13 +58,13 @@ IF(NOT WIN32 AND NOT CMAKE_GENERATOR MATCHES Xcode)
ADD_CUSTOM_COMMAND(OUTPUT user.ps
DEPENDS user.r ${OUTPUT_INC} ${SOURCE_INC}
COMMAND ${GROFF} -mm ${CMAKE_CURRENT_SOURCE_DIR}/user.r > user.ps || touch user.ps)
ADD_CUSTOM_TARGET(ps ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/user.ps)
ADD_CUSTOM_TARGET(user.ps ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/user.ps)
ENDIF(GROFF)
IF(NROFF)
ADD_CUSTOM_COMMAND(OUTPUT user.t
DEPENDS user.r ${OUTPUT_INC} ${SOURCE_INC}
COMMAND ${NROFF} -mm ${CMAKE_CURRENT_SOURCE_DIR}/user.r > user.t || touch user.t)
ADD_CUSTOM_TARGET(t ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/user.t)
ADD_CUSTOM_TARGET(user.t ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/user.t)
ENDIF(NROFF)
ENDIF()

View file

@ -1,127 +0,0 @@
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/mariadb_connector_c.cmake)
SET(CONNECTOR_C_INSTALLDIR "${CMAKE_CURRENT_BINARY_DIR}/mariadb-connector-c/${CMAKE_CFG_INTDIR}" CACHE STRING "")
SET(CONNECTOR_C_INSTALL_PREFIX ${CONNECTOR_C_INSTALLDIR})
IF(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${BUILD_TYPE}" CONNECTOR_C_INSTALL_PREFIX "${CONNECTOR_C_INSTALLDIR}")
ENDIF()
SET(CONNECTOR_C_GIT_TAG "v3.0-cc-server-integ-0" CACHE STRING "Git tag or branch for connector/c")
IF(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/mariadb-connector-c)
# Building from source package
SET(CONNECTOR_C_SOURCE_DIR ${CMAKE_SOURCE_DIR}/mariadb-connector-c)
SET(GIT_PARAMS)
ELSE()
# Building from git, use git to get Connector/C
SET(GIT_PARAMS
GIT_REPOSITORY "https://github.com/MariaDB/mariadb-connector-c/"
GIT_TAG ${CONNECTOR_C_GIT_TAG}
)
SET(CONNECTOR_C_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/mariadb-connector-c-src)
ENDIF()
IF(TARGET zlib)
GET_PROPERTY(ZLIB_LIBRARY_LOCATION TARGET zlib PROPERTY LOCATION)
ELSE()
SET(ZLIB_LIBRARY_LOCATION ${ZLIB_LIBRARY})
ENDIF()
INCLUDE(ExternalProject)
ExternalProject_Add(
mariadb_connector_c
${GIT_PARAMS}
UPDATE_COMMAND ""
PATCH_COMMAND ""
SOURCE_DIR ${CONNECTOR_C_SOURCE_DIR}
INSTALL_DIR ${CONNECTOR_C_INSTALLDIR}
CMAKE_ARGS ${CC_CMAKE_OPTS}
-DCMAKE_INSTALL_PREFIX=${CONNECTOR_C_INSTALL_PREFIX}
-DWITH_EXTERNAL_ZLIB=1
-DZLIB_FOUND=1
-DZLIB_LIBRARY=${ZLIB_LIBRARY_LOCATION}
-DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIR}
-DSKIP_TESTS=1
-DMARIADB_PORT=${MYSQL_TCP_PORT}
-DMARIADB_UNIX_ADDR=${MYSQL_UNIX_ADDR}
-DSHARED_LIB_MAJOR_VERSION=${SHARED_LIB_MAJOR_VERSION}
-DPLUGINDIR=${INSTALL_PLUGINDIR}
-DFOR_SERVER=1
TEST_COMMAND ""
)
IF(TARGET zlib)
ADD_DEPENDENCIES(mariadb_connector_c zlib)
ENDIF()
SET(STATIC_LIB_LOCATION "${CONNECTOR_C_INSTALLDIR}/lib/mariadb/${CMAKE_STATIC_LIBRARY_PREFIX}mysqlclient${CMAKE_STATIC_LIBRARY_SUFFIX}")
IF(WIN32)
SET(SHARED_LIB_LOCATION "${CONNECTOR_C_INSTALLDIR}/lib/mariadb/libmysql${CMAKE_SHARED_LIBRARY_SUFFIX}")
ELSE()
SET(SHARED_LIB_LOCATION "${CONNECTOR_C_INSTALLDIR}/lib/mariadb/libmysqlclient${CMAKE_SHARED_LIBRARY_SUFFIX}")
ENDIF()
IF(WIN32)
# On Windows, we need to install import library. We also install PDB for debugging
STRING(REPLACE ".dll" ".lib" IMPORT_LIB_LOCATION ${SHARED_LIB_LOCATION})
STRING(REPLACE ".dll" ".pdb" PDB_LOCATION ${SHARED_LIB_LOCATION})
ENDIF()
ADD_LIBRARY(mariadbclient STATIC IMPORTED GLOBAL)
SET_TARGET_PROPERTIES(mariadbclient PROPERTIES IMPORTED_LOCATION ${STATIC_LIB_LOCATION})
ADD_DEPENDENCIES(mariadbclient mariadb_connector_c GenError)
ADD_LIBRARY(libmariadb SHARED IMPORTED GLOBAL)
SET_TARGET_PROPERTIES(libmariadb PROPERTIES IMPORTED_LOCATION ${SHARED_LIB_LOCATION})
ADD_DEPENDENCIES(libmariadb mariadb_connector_c GenError)
SET(CONNECTOR_C_LIBS ${STATIC_LIB_LOCATION} ${CC_LIBS} ${ZLIB_LIBRARY} PARENT_SCOPE)
# INSTALL Connector/C files
# For multiconfig generators (Visual Studio and Xcode)
# we need to replace CMAKE_CFG_INTDIR in filepath with CMAKE_INSTALL_CONFIG_NAME
# for cpack.
FUNCTION(GET_INSTALL_LOCATION LOC VARNAME)
SET(val ${LOC})
IF (NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}" val ${val})
ENDIF()
SET(${VARNAME} ${val} PARENT_SCOPE)
ENDFUNCTION()
GET_INSTALL_LOCATION(${STATIC_LIB_LOCATION} STATIC_LIB_INSTALL_LOCATION)
INSTALL(FILES ${STATIC_LIB_INSTALL_LOCATION} DESTINATION ${INSTALL_LIBDIR} COMPONENT Development)
IF(UNIX)
STRING(REPLACE "mysqlclient" "mysqlclient_r"
STATIC_LIB_R_INSTALL_LOCATION "${STATIC_LIB_INSTALL_LOCATION}")
INSTALL(FILES ${STATIC_LIB_R_INSTALL_LOCATION} OPTIONAL DESTINATION ${INSTALL_LIBDIR} COMPONENT Development)
ENDIF()
# Install shared library
IF(WIN32)
# On Windows, we need to install import library. We also install PDB for debugging
SET(SHARED_LIB_FILES ${SHARED_LIB_LOCATION} ${IMPLIB_LOCATION} ${PDB_LOCATION})
ELSE()
STRING(REPLACE "mysqlclient" "mysqlclient_r" SHARED_LIB_R_LOCATION ${SHARED_LIB_LOCATION})
STRING(REPLACE "mysqlclient.so" "mysqlclient.so.${SHARED_LIB_MAJOR_VERSION}"
SHARED_LIB_LINK1_LOCATION ${SHARED_LIB_LOCATION})
STRING(REPLACE "mysqlclient.so" "mysqlclient.so.${SHARED_LIB_MAJOR_VERSION}.0.0"
SHARED_LIB_LINK2_LOCATION ${SHARED_LIB_LOCATION})
SET(SHARED_LIB_FILES ${SHARED_LIB_LOCATION} ${SHARED_LIB_R_LOCATION}
${SHARED_LIB_LINK1_LOCATION} ${SHARED_LIB_LINK2_LOCATION})
LIST(REMOVE_DUPLICATES SHARED_LIB_FILES)
ENDIF()
FOREACH(file ${SHARED_LIB_FILES})
GET_INSTALL_LOCATION(${file} loc)
IF(loc)
INSTALL(FILES ${loc} DESTINATION ${INSTALL_LIBDIR} COMPONENT SharedLibraries OPTIONAL)
ENDIF()
ENDFOREACH()

View file

@ -18,18 +18,20 @@ ADD_DEFINITIONS("-DMYSQL_CLIENT")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/client)
INCLUDE_DIRECTORIES(BEFORE ${CONNECTOR_C_INSTALLDIR}/include/mariadb)
INCLUDE_DIRECTORIES(BEFORE
${CMAKE_BINARY_DIR}/libmariadb/include
${CMAKE_SOURCE_DIR}/libmariadb/include)
ADD_EXECUTABLE(mysql_client_test mysql_client_test.c)
SET(CLIENT_LIB ${CONNECTOR_C_LIBS} mysys)
SET(CLIENT_LIB mariadbclient mysys)
TARGET_LINK_LIBRARIES(mysql_client_test ${CLIENT_LIB})
ADD_DEPENDENCIES(mysql_client_test GenError mariadb_connector_c)
ADD_DEPENDENCIES(mysql_client_test GenError ${CLIENT_LIB})
IF(WITH_UNIT_TESTS)
ADD_EXECUTABLE(bug25714 bug25714.c)
TARGET_LINK_LIBRARIES(bug25714 ${CLIENT_LIB})
ADD_DEPENDENCIES(bug25714 GenError mariadb_connector_c)
ADD_DEPENDENCIES(bug25714 GenError ${CLIENT_LIB})
ENDIF()
INSTALL(TARGETS mysql_client_test DESTINATION ${INSTALL_BINDIR} COMPONENT Test)
@ -40,5 +42,5 @@ MARK_AS_ADVANCED(EVENT_LIBRARY)
IF(HAVE_EVENT_H AND EVENT_LIBRARY)
ADD_EXECUTABLE(async_queries async_queries.c)
TARGET_LINK_LIBRARIES(async_queries ${CLIENT_LIB} ${EVENT_LIBRARY})
ADD_DEPENDENCIES(async_queries GenError mariadb_connector_c)
ADD_DEPENDENCIES(async_queries GenError ${CLIENT_LIB})
ENDIF()