diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2016-08-19 15:27:37 +0000 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2016-08-19 15:27:37 +0000 |
commit | 7b89b9f5108c80f4f270da922d7e6c182a663719 (patch) | |
tree | 858a3873942f07610fb26685781e8bdbd3ab2c7f /cmake | |
parent | daff133ddf9a9d120050703c0b5753979c6190e0 (diff) | |
download | mariadb-git-7b89b9f5108c80f4f270da922d7e6c182a663719.tar.gz |
MDEV-9293 Connector/C integration
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/iconv.cmake | 78 | ||||
-rw-r--r-- | cmake/make_dist.cmake.in | 12 | ||||
-rw-r--r-- | cmake/mariadb_connector_c.cmake | 27 |
3 files changed, 115 insertions, 2 deletions
diff --git a/cmake/iconv.cmake b/cmake/iconv.cmake new file mode 100644 index 00000000000..f6afd9d102a --- /dev/null +++ b/cmake/iconv.cmake @@ -0,0 +1,78 @@ +# +# Copyright (c) 2010 Michael Bell <michael.bell@web.de> +# 2015-2016 MariaDB Corporation AB + +if (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + # Already in cache, be silent + set(ICONV_FIND_QUIETLY TRUE) +endif (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + + +IF(CMAKE_SYSTEM_NAME MATCHES "SunOS") + # There is some libiconv.so in /usr/local that must + # be avoided, iconv routines are in libc + find_library(ICONV_LIBRARIES NAMES c) +ELSEIF(APPLE) + find_path(ICONV_INCLUDE_DIR iconv.h PATHS + /usr/include/ + /opt/local/include/ + ) + find_library(ICONV_LIBRARIES NAMES iconv libiconv PATHS + /usr/lib/ + /opt/local/lib/ + ) + SET(ICONV_EXTERNAL TRUE) +ELSE() + find_path(ICONV_INCLUDE_DIR iconv.h) + find_library(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2) + IF(ICONV_LIBRARIES) + SET(ICONV_EXTERNAL TRUE) + ELSE() + find_library(ICONV_LIBRARIES NAMES c) + ENDIF() +ENDIF() + +if (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + set (ICONV_FOUND TRUE) +endif (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + +set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) +IF(ICONV_EXTERNAL) + set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) +ENDIF() + +if (ICONV_FOUND) + include(CheckCSourceCompiles) + CHECK_C_SOURCE_COMPILES(" + #include <iconv.h> + int main(){ + iconv_t conv = 0; + const char* in = 0; + size_t ilen = 0; + char* out = 0; + size_t olen = 0; + iconv(conv, &in, &ilen, &out, &olen); + return 0; + } +" ICONV_SECOND_ARGUMENT_IS_CONST ) +endif (ICONV_FOUND) + +set (CMAKE_REQUIRED_INCLUDES) +set (CMAKE_REQUIRED_LIBRARIES) + +if (ICONV_FOUND) + if (NOT ICONV_FIND_QUIETLY) + message (STATUS "Found Iconv: ${ICONV_LIBRARIES}") + endif (NOT ICONV_FIND_QUIETLY) +else (ICONV_FOUND) + if (Iconv_FIND_REQUIRED) + message (FATAL_ERROR "Could not find Iconv") + endif (Iconv_FIND_REQUIRED) +endif (ICONV_FOUND) + +MARK_AS_ADVANCED( + ICONV_INCLUDE_DIR + ICONV_LIBRARIES + ICONV_EXTERNAL + ICONV_SECOND_ARGUMENT_IS_CONST +) diff --git a/cmake/make_dist.cmake.in b/cmake/make_dist.cmake.in index f35d16834b6..32ea5b130ad 100644 --- a/cmake/make_dist.cmake.in +++ b/cmake/make_dist.cmake.in @@ -28,6 +28,7 @@ SET(TAR_EXECUTABLE "@TAR_EXECUTABLE@") SET(CMAKE_GENERATOR "@CMAKE_GENERATOR@") SET(CMAKE_MAKE_PROGRAM "@CMAKE_MAKE_PROGRAM@") SET(CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@") +SET(CONNECTOR_C_GIT_TAG "@CONNECTOR_C_GIT_TAG@") SET(VERSION "@VERSION@") @@ -46,9 +47,16 @@ IF(GIT_EXECUTABLE) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} RESULT_VARIABLE RESULT ) - + IF(RESULT EQUAL 0) + MESSAGE(STATUS "Cloning Connector/C ") + EXECUTE_PROCESS( + COMMAND "${GIT_EXECUTABLE}" clone https://github.com/MariaDB/mariadb-connector-c -b ${CONNECTOR_C_GIT_TAG} + WORKING_DIRECTORY ${PACKAGE_DIR} + RESULT_VARIABLE RESULT + ) + ENDIF() IF(NOT RESULT EQUAL 0) - SET(GIT_EXECUTABLE) + SET(GIT_EXECUTABLE) ENDIF() ENDIF() diff --git a/cmake/mariadb_connector_c.cmake b/cmake/mariadb_connector_c.cmake new file mode 100644 index 00000000000..33062c011bd --- /dev/null +++ b/cmake/mariadb_connector_c.cmake @@ -0,0 +1,27 @@ +# +# Configuration options for Connector/C +# +IF(WIN32) + # todo: libcurl for windows +ELSE() + SET(CC_LIBS ${LIBDL} ${LIBM} ${LIBPTHREAD}) + FIND_PACKAGE(OpenSSL) + #FIND_PACKAGE(GnuTLS) + IF(OPENSSL_FOUND) + SET(CC_LIBS ${CC_LIBS} ${OPENSSL_LIBRARIES} ${OPENSSL_CRYPTO_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") + ELSE() + SET(CC_CMAKE_OPTS "-DWITH_SSL=OFF") + ENDIF() + INCLUDE(${CMAKE_SOURCE_DIR}/cmake/iconv.cmake) + IF(ICONV_FOUND) + IF(ICONV_EXTERNAL) + SET(CC_LIBS ${CC_LIBS} ${ICONV_LIBRARIES}) + ENDIF() + ENDIF() +ENDIF() +MARK_AS_ADVANCED(CC_LIBS CC_CMAKE_OPTS) + |