mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +01:00
350 lines
11 KiB
CMake
350 lines
11 KiB
CMake
# CMakeLists.txt
|
|
|
|
|
|
# This is the LGPL libmariadb project.
|
|
PROJECT(mariadb-connector-c C)
|
|
|
|
# Is C/C built as subproject?
|
|
get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY)
|
|
|
|
# do not inherit include directories from the parent project
|
|
SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
|
|
FOREACH(V WITH_MYSQLCOMPAT WITH_MSI WITH_SIGNCODE WITH_RTC WITH_UNIT_TESTS WITH_EXTERNAL_ZLIB WITH_SQLITE INSTALL_LAYOUT)
|
|
SET(${V} ${${OPT}${V}})
|
|
ENDFOREACH()
|
|
|
|
SET(CC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
SET(CC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
SET(CPACK_PACKAGE_VERSION_MAJOR 2)
|
|
SET(CPACK_PACKAGE_VERSION_MINOR 3)
|
|
SET(CPACK_PACKAGE_VERSION_PATCH 7)
|
|
SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
|
MATH(EXPR MARIADB_PACKAGE_VERSION_ID "${CPACK_PACKAGE_VERSION_MAJOR} * 10000 + ${CPACK_PACKAGE_VERSION_MINOR} * 100 + ${CPACK_PACKAGE_VERSION_PATCH}")
|
|
#Minimum required version is Cmake 2.8.8, since we need to build object libraries
|
|
IF(WIN32)
|
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
|
|
ELSE()
|
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
|
|
ENDIF()
|
|
IF(COMMAND CMAKE_POLICY)
|
|
CMAKE_POLICY(SET CMP0003 NEW)
|
|
ENDIF()
|
|
|
|
#Allow access to non existing targets
|
|
#IF(CMAKE_VERSION VERSION_GREATER "2.9.9")
|
|
#CMAKE_POLICY(SET CMP0026 OLD)
|
|
#CMAKE_POLICY(SET CMP0045 OLD)
|
|
#CMAKE_POLICY(SET CMP0042 OLD)
|
|
#ENDIF()
|
|
|
|
### Options ###
|
|
IF(NOT WIN32)
|
|
OPTION(WITH_MYSQLCOMPAT "creates libmysql* symbolic links" OFF)
|
|
OPTION(WITH_OPENSSL "enables SSL support" ON)
|
|
ELSE()
|
|
OPTION(WITH_OPENSSL "enables SSL support" OFF)
|
|
OPTION(WITH_SIGNCODE "digitally sign files" OFF)
|
|
OPTION(WITH_RTC "enables run time checks for debug builds" OFF)
|
|
ENDIF()
|
|
|
|
OPTION(WITH_UNIT_TESTS "builds unittests" OFF)
|
|
OPTION(WITH_EXTERNAL_ZLIB "Enables use of external zlib" OFF)
|
|
###############
|
|
|
|
IF(WITH_SIGNCODE)
|
|
IF(WIN32 AND NOT SIGN_OPTIONS)
|
|
SET(SIGN_OPTIONS /a /t http://timestamp.verisign.com/scripts/timstamp.dll)
|
|
ELSE()
|
|
SEPARATE_ARGUMENTS(SIGN_OPTIONS)
|
|
ENDIF()
|
|
MARK_AS_ADVANCED(SIGN_OPTIONS)
|
|
ENDIF()
|
|
|
|
IF(WITH_RTC)
|
|
SET(RTC_OPTIONS "/RTC1 /RTCc")
|
|
ENDIF()
|
|
|
|
IF(NOT IS_SUBPROJECT)
|
|
IF(MSVC)
|
|
# Speedup system tests
|
|
INCLUDE(${CC_SOURCE_DIR}/cmake/WindowsCache.cmake)
|
|
IF (MSVC)
|
|
SET(CONFIG_TYPES "DEBUG" "RELEASE" "RELWITHDEBINFO")
|
|
FOREACH(BUILD_TYPE ${CONFIG_TYPES})
|
|
FOREACH(COMPILER CXX C)
|
|
SET(COMPILER_FLAGS "${CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}}")
|
|
IF (NOT COMPILER_FLAGS STREQUAL "")
|
|
STRING(REPLACE "/MD" "/MT" COMPILER_FLAGS ${COMPILER_FLAGS})
|
|
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
SET(COMPILER_FLAGS "${COMPILER_FLAGS} ${RTC_OPTIONS}")
|
|
STRING(REPLACE "/Zi" "/ZI" COMPILER_FLAGS ${COMPILER_FLAGS})
|
|
ENDIF()
|
|
MESSAGE (STATUS "CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}= ${COMPILER_FLAGS}")
|
|
SET(CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE} ${COMPILER_FLAGS} CACHE
|
|
STRING "overwritten by libmariadb" FORCE)
|
|
ENDIF()
|
|
ENDFOREACH()
|
|
ENDFOREACH()
|
|
ENDIF()
|
|
ENDIF()
|
|
ENDIF(NOT IS_SUBPROJECT)
|
|
|
|
# Disable dbug information for release builds
|
|
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDBUG_OFF")
|
|
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF")
|
|
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
|
|
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
|
|
|
|
IF(CMAKE_COMPILER_IS_GNUCC)
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused -Wno-unused-value -Wno-unused-but-set-variable -Wno-incompatible-pointer-types -Wno-uninitialized")
|
|
ENDIF()
|
|
|
|
# If the build type isn't specified, set to Relwithdebinfo as default.
|
|
IF(NOT CMAKE_BUILD_TYPE)
|
|
SET(CMAKE_BUILD_TYPE "Relwithdebinfo")
|
|
ENDIF()
|
|
|
|
# various defines for generating include/mysql_version.h
|
|
|
|
SET(PROTOCOL_VERSION 10) # we adapted new password option from PHP's mysqlnd !
|
|
SET(MYSQL_CLIENT_VERSION_MAJOR "5")
|
|
SET(MYSQL_CLIENT_VERSION_MINOR "5")
|
|
SET(MYSQL_CLIENT_VERSION_PATCH "1")
|
|
SET(MYSQL_CLIENT_VERSION "${MYSQL_CLIENT_VERSION_MAJOR}.${MYSQL_CLIENT_VERSION_MINOR}.${MYSQL_CLIENT_VERSION_PATCH}")
|
|
MATH(EXPR MYSQL_VERSION_ID "${MYSQL_CLIENT_VERSION_MAJOR} * 10000 + ${MYSQL_CLIENT_VERSION_MINOR} * 100 + ${MYSQL_CLIENT_VERSION_PATCH}")
|
|
|
|
IF (NOT MYSQL_PORT)
|
|
SET(MYSQL_PORT 3306)
|
|
ENDIF ()
|
|
IF(NOT MYSQL_UNIX_ADDR)
|
|
SET(MYSQL_UNIX_ADDR "/tmp/mysql.sock")
|
|
ENDIF()
|
|
|
|
INCLUDE(${CC_SOURCE_DIR}/cmake/version_info.cmake)
|
|
INCLUDE(${CC_SOURCE_DIR}/cmake/sign.cmake)
|
|
INCLUDE("${CC_SOURCE_DIR}/cmake/install.cmake")
|
|
|
|
SET(DEFAULT_CHARSET_HOME "${CMAKE_INSTALL_PREFIX}")
|
|
SET(PLUGINDIR "${CMAKE_INSTALL_PREFIX}/lib/plugin")
|
|
|
|
INCLUDE(${CC_SOURCE_DIR}/cmake/SearchLibrary.cmake)
|
|
|
|
IF(WITH_EXTERNAL_ZLIB)
|
|
FIND_PACKAGE(ZLIB QUIET)
|
|
IF(${ZLIB_FOUND})
|
|
SET(LIBZ "-z")
|
|
ENDIF()
|
|
ELSE()
|
|
add_subdirectory(zlib)
|
|
ENDIF()
|
|
|
|
INCLUDE(TestBigEndian)
|
|
TEST_BIG_ENDIAN(HAVE_BIGENDIAN)
|
|
|
|
IF(UNIX)
|
|
SEARCH_LIBRARY(DEFAULT_LIB inet_ntoa "c")
|
|
IF(NOT DEFAULT_LIB)
|
|
SEARCH_LIBRARY(LIBNSL inet_ntoa "nsl_r;nsl")
|
|
ENDIF()
|
|
SEARCH_LIBRARY(DEFAULT_LIB bind "c")
|
|
IF(NOT DEFAULT_LIB)
|
|
SEARCH_LIBRARY(LIBBIND bind "bind;socket")
|
|
ENDIF()
|
|
SEARCH_LIBRARY(DEFAULT_LIB setsockopt "c")
|
|
IF(NOT DEFAULT_LIB)
|
|
SEARCH_LIBRARY(LIBSOCKET setsockopt "socket")
|
|
ENDIF()
|
|
SEARCH_LIBRARY(LIBDL dlopen "dl")
|
|
SEARCH_LIBRARY(LIBM floor m)
|
|
SEARCH_LIBRARY(LIBPTHREAD pthread_getspecific "pthread;pthreads")
|
|
SET(EXTRA_LIBS "${LIBNSL}" "${LIBBIND}" "${LIBSOCKET}" "${LIBDL}" "${LIBM}" "${LIBPTHREAD}")
|
|
FIND_PACKAGE(Threads)
|
|
#remove possible dups from required libraries
|
|
LIST(LENGTH SYS_LIBS rllength)
|
|
IF(${rllength} GREATER 0)
|
|
LIST(REMOVE_DUPLICATES SYS_LIBS)
|
|
ENDIF()
|
|
SET(CMAKE_REQUIRED_LIBRARIES ${SYS_LIBS})
|
|
ENDIF()
|
|
|
|
|
|
IF(CMAKE_HAVE_PTHREAD_H)
|
|
SET(CMAKE_REQUIRED_INCLUDES pthread.h)
|
|
ENDIF()
|
|
|
|
IF(WIN32)
|
|
SET(HAVE_THREADS 1)
|
|
ADD_DEFINITIONS(-DHAVE_DLOPEN)
|
|
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
|
IF(MSVC)
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996" )
|
|
ENDIF()
|
|
ELSEIF()
|
|
SET(HAVE_THREADS ${CMAKE_USE_PTHREADS})
|
|
ENDIF()
|
|
|
|
# check for various include files
|
|
INCLUDE(${CC_SOURCE_DIR}/cmake/CheckIncludeFiles.cmake)
|
|
# check for various functions
|
|
INCLUDE(${CC_SOURCE_DIR}/cmake/CheckFunctions.cmake)
|
|
# check for various types
|
|
INCLUDE(${CC_SOURCE_DIR}/cmake/CheckTypes.cmake)
|
|
|
|
# Check for OpenSSL
|
|
IF(WITH_OPENSSL)
|
|
FIND_PACKAGE(OpenSSL)
|
|
IF(OPENSSL_FOUND)
|
|
ADD_DEFINITIONS(-DHAVE_OPENSSL)
|
|
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
|
|
SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES})
|
|
IF(OPENSSL_CRYPTO_LIBRARIES)
|
|
SET(SSL_LIBRARIES ${SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES})
|
|
ENDIF()
|
|
ELSE()
|
|
MESSAGE(FATAL_ERROR "OpenSSL not found. Please install OpenSSL or disable SSL support via option -DWITH_OPENSSL=Off")
|
|
ENDIF()
|
|
ENDIF()
|
|
|
|
IF(WITH_SQLITE)
|
|
ADD_DEFINITIONS(-DHAVE_SQLITE)
|
|
ENDIF()
|
|
|
|
IF(NOT WIN32)
|
|
INCLUDE(${CC_SOURCE_DIR}/cmake/FindIconv.cmake)
|
|
ENDIF()
|
|
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/mysql_version.h.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/include/mysql_version.h)
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/my_config.h.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/include/my_config.h)
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/mysql_version.h.in
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include/mysql_version.h)
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/my_config.h.in
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include/my_config.h)
|
|
|
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include)
|
|
|
|
IF(WIN32)
|
|
SET(SYSTEM_LIBS ws2_32 advapi32 kernel32)
|
|
ELSE()
|
|
SET(SYSTEM_LIBS ${LIBPTHREAD} ${LIBDL} ${LIBM})
|
|
IF(ICONV_EXTERNAL)
|
|
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${ICONV_LIBRARIES})
|
|
ENDIF()
|
|
ENDIF()
|
|
IF(OPENSSL_FOUND)
|
|
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${SSL_LIBRARIES})
|
|
ENDIF()
|
|
|
|
ADD_SUBDIRECTORY(include)
|
|
ADD_SUBDIRECTORY(libmariadb)
|
|
ADD_SUBDIRECTORY(plugins)
|
|
IF(NOT WIN32)
|
|
ADD_SUBDIRECTORY(mariadb_config)
|
|
ENDIF()
|
|
|
|
IF(IS_DIRECTORY ${CC_SOURCE_DIR}/unittest)
|
|
IF(WITH_UNIT_TESTS)
|
|
ADD_SUBDIRECTORY(unittest/mytap)
|
|
ADD_SUBDIRECTORY(unittest/libmariadb)
|
|
ENDIF()
|
|
ENDIF()
|
|
|
|
IF(CLIENT_DOCS)
|
|
INSTALL(DIRECTORY ${CLIENT_DOCS}
|
|
DESTINATION ${DOCS_INSTALL_DIR_${INSTALL_LAYOUT}})
|
|
ENDIF()
|
|
|
|
|
|
IF(WIN32 AND WITH_MSI AND CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
|
ADD_SUBDIRECTORY(win/packaging)
|
|
ENDIF()
|
|
|
|
SET(CPACK_PACKAGE_VENDOR "MariaDB Corporation Ab")
|
|
SET(CPACK_PACKAGE_DESCRIPTION "MariaDB Connector/C. A library for connecting to MariaDB and MySQL servers")
|
|
SET(CPACK_PACKAGE_NAME "mariadb_connector_c")
|
|
STRING(TOLOWER ${CMAKE_SYSTEM_NAME} system_name)
|
|
SET(CPACK_PACKAGE_FILE_NAME "mariadb-connector-c-${CPACK_PACKAGE_VERSION}-${system_name}-${CMAKE_SYSTEM_PROCESSOR}")
|
|
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.LIB")
|
|
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
|
|
INCLUDE(cmake/ConnectorName.cmake)
|
|
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-connector-c-${CPACK_PACKAGE_VERSION}-src")
|
|
|
|
# Build source packages
|
|
IF(GIT_BUILD_SRCPKG)
|
|
# get branch name
|
|
EXECUTE_PROCESS(COMMAND git show-branch OUTPUT_VARIABLE git_branch)
|
|
STRING(REGEX MATCH "\\[([^]]+)\\]" git_branch ${git_branch})
|
|
STRING(REGEX REPLACE "\\[|\\]" "" GIT_BRANCH ${git_branch})
|
|
MESSAGE(STATUS "${GIT_BRANCH}")
|
|
IF(WIN32)
|
|
EXECUTE_PROCESS(COMMAND git archive ${GIT_BRANCH} --format=zip --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.zip)
|
|
ELSE()
|
|
EXECUTE_PROCESS(COMMAND git archive ${GIT_BRANCH} --format=zip --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.zip)
|
|
EXECUTE_PROCESS(COMMAND git archive ${GIT_BRANCH} --format=tar --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar)
|
|
EXECUTE_PROCESS(COMMAND gzip -9 -f ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar)
|
|
ENDIF()
|
|
ENDIF()
|
|
|
|
SET(CPACK_SOURCE_IGNORE_FILES
|
|
\\\\.git/
|
|
\\\\.gitignore
|
|
\\\\.gitattributes
|
|
CMakeCache.txt
|
|
cmake_dist.cmake
|
|
CPackSourceConfig.cmake
|
|
CPackConfig.cmake
|
|
mariadb_config/mariadb_config.c$
|
|
.build/
|
|
html/
|
|
unittest
|
|
/cmake_install.cmake
|
|
/CTestTestfile.cmake
|
|
/CMakeFiles/
|
|
/version_resources/
|
|
/_CPack_Packages/
|
|
.*gz$
|
|
.*zip$
|
|
.*so$
|
|
.*so.*$
|
|
.*dll$
|
|
.*a$
|
|
.*pdb$
|
|
/CMakeFiles/
|
|
/version_resources/
|
|
/_CPack_Packages/
|
|
Makefile$
|
|
include/my_config.h$
|
|
/autom4te.cache/
|
|
errmsg.sys$
|
|
)
|
|
|
|
IF(WIN32)
|
|
SET(CPACK_GENERATOR "ZIP")
|
|
SET(CPACK_SOURCE_GENERATOR "ZIP")
|
|
ELSE()
|
|
SET(CPACK_GENERATOR "TGZ")
|
|
SET(CPACK_SOURCE_GENERATOR "TGZ")
|
|
ENDIF()
|
|
INCLUDE(CPack)
|
|
|
|
MESSAGE(STATUS "MariaDB Connector/c configuration:")
|
|
MESSAGE(STATUS "CPack generation: ${CPACK_GENERATOR}")
|
|
IF(CLIENT_DOCS)
|
|
MESSAGE(STATUS "Documentation included from ${CLIENT_DOCS}")
|
|
ENDIF()
|
|
MESSAGE(STATUS "SSL support: ${WITH_OPENSSL}")
|
|
MESSAGE(STATUS "Experimental Sqlite support: ${WITH_SQLITE}")
|
|
IF(WITH_EXTERNAL_ZLIB)
|
|
MESSAGE(STATUS "Zlib support: ${WITH_EXTERNAL_ZLIB}")
|
|
ELSE()
|
|
MESSAGE(STATUS "Zlib support: yes (using bundled zlib)")
|
|
ENDIF()
|
|
MESSAGE(STATUS "Installation layout: ${INSTALL_LAYOUT}")
|
|
MESSAGE(STATUS "Include files will be installed in ${PREFIX_INSTALL_DIR}/${INCLUDE_INSTALL_DIR}/${SUFFIX_INSTALL_DIR}")
|
|
MESSAGE(STATUS "Libraries will be installed in ${PREFIX_INSTALL_DIR}/${LIB_INSTALL_DIR}/${LIBSUFFIX_INSTALL_DIR}")
|
|
MESSAGE(STATUS "Binaries will be installed in ${PREFIX_INSTALL_DIR}/${BIN_INSTALL_DIR}")
|
|
|
|
MESSAGE(STATUS "Required: ${CMAKE_REQUIRED_LIBRARIES}")
|