Added the platform check back and added linker flags for PCRE if the embedded library does not have them.

This commit is contained in:
Markus Makela
2015-04-03 22:14:51 +03:00
parent 2471ebf55f
commit e9aa692acd
5 changed files with 134 additions and 69 deletions

View File

@ -19,7 +19,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
project(MaxScale)
#Disabled for now pending evaluation
#include(CheckPlatform.cmake)
include(cmake/CheckPlatform.cmake)
check_deps()
check_dirs()

View File

@ -1,6 +1,7 @@
#Checks for all the C system headers found in all the files
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckIncludeFiles)
check_include_files(arpa/inet.h HAVE_ARPA_INET)

View File

@ -3,7 +3,7 @@
# The following variables are set:
# MYSQL_VERSION - The MySQL version number
# MYSQL_PROVIDER - The MySQL provider e.g. MariaDB
# EMBEDDED_LIB - The MySQL embedded library
find_file(MYSQL_VERSION_H mysql_version.h PATH_SUFFIXES mysql)
if(MYSQL_VERSION_H MATCHES "MYSQL_VERSION_H-NOTFOUND")
@ -33,5 +33,69 @@ if(NOT MYSQL_PROVIDER STREQUAL "MariaDB")
message(WARNING "Not using MariaDB server.")
endif()
if(MYSQL_VERSION VERSION_LESS 5.5.41)
message(WARNING "MySQL version is ${MYSQL_VERSION}. Minimum supported version is 5.5.41")
message(WARNING "MySQL version is ${MYSQL_VERSION}. Minimum supported version is 5.5.41.")
endif()
if (DEFINED EMBEDDED_LIB)
if( NOT (IS_DIRECTORY ${EMBEDDED_LIB}) )
debugmsg("EMBEDDED_LIB is not a directory: ${EMBEDDED_LIB}")
if(${CMAKE_VERSION} VERSION_LESS 2.8.12 )
set(COMP_VAR PATH)
else()
set(COMP_VAR DIRECTORY)
endif()
get_filename_component(EMBEDDED_LIB ${EMBEDDED_LIB} ${COMP_VAR})
debugmsg("EMBEDDED_LIB directory component: ${EMBEDDED_LIB}")
endif()
debugmsg("Searching for the embedded library at: ${EMBEDDED_LIB}")
endif()
if(STATIC_EMBEDDED)
debugmsg("Using the static embedded library...")
set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
if (DEFINED EMBEDDED_LIB)
debugmsg("Searching for libmysqld.a at: ${EMBEDDED_LIB}")
find_library(EMBEDDED_LIB_STATIC libmysqld.a PATHS ${EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
else()
find_library(EMBEDDED_LIB_STATIC libmysqld.a PATH_SUFFIXES mysql mariadb)
endif()
debugmsg("Search returned: ${EMBEDDED_LIB_STATIC}")
set(EMBEDDED_LIB ${EMBEDDED_LIB_STATIC} CACHE FILEPATH "Path to libmysqld" FORCE)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
else()
debugmsg("Using the dynamic embedded library...")
set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".so")
if (DEFINED EMBEDDED_LIB)
debugmsg("Searching for libmysqld.so at: ${EMBEDDED_LIB}")
find_library(EMBEDDED_LIB_DYNAMIC mysqld PATHS ${EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
else()
find_library(EMBEDDED_LIB_DYNAMIC mysqld PATH_SUFFIXES mysql mariadb)
endif()
debugmsg("Search returned: ${EMBEDDED_LIB_DYNAMIC}")
set(EMBEDDED_LIB ${EMBEDDED_LIB_DYNAMIC} CACHE FILEPATH "Path to libmysqld" FORCE)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
endif()
unset(EMBEDDED_LIB_DYNAMIC)
unset(EMBEDDED_LIB_STATIC)
unset(OLD_SUFFIXES)
check_library_exists(${EMBEDDED_LIB} pcre_stack_guard ${EMBEDDED_LIB} HAVE_EMBEDDED_PCRE)
if(HAVE_EMBEDDED_PCRE)
set(PCRE_LINK_FLAGS "" CACHE INTERNAL "pcre linker flags")
else()
message(STATUS "Embedded mysqld does not have pcre_stack_guard, linking with system pcre.")
set(PCRE_LINK_FLAGS "pcre" CACHE INTERNAL "pcre linker flags")
endif()
if( (${EMBEDDED_LIB} MATCHES "NOTFOUND") OR (${EMBEDDED_LIB} MATCHES "NOTFOUND"))
message(FATAL_ERROR "Library not found: libmysqld. If your install of MySQL is in a non-default location, please provide the location with -DEMBEDDED_LIB=<path to library>")
else()
message(STATUS "Using embedded library: ${EMBEDDED_LIB}")
endif()

View File

@ -10,14 +10,14 @@ macro(set_maxscale_version)
#MaxScale version number
set(MAXSCALE_VERSION_MAJOR "1")
set(MAXSCALE_VERSION_MINOR "1")
set(MAXSCALE_VERSION_PATCH "0")
set(MAXSCALE_VERSION_PATCH "0")
set(MAXSCALE_VERSION_NUMERIC "${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}.${MAXSCALE_VERSION_PATCH}")
set(MAXSCALE_VERSION "${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}.${MAXSCALE_VERSION_PATCH}")
endmacro()
macro(set_variables)
# hostname or IP address of MaxScale's host
set(TEST_HOST "127.0.0.1" CACHE STRING "hostname or IP address of MaxScale's host")
@ -50,7 +50,7 @@ macro(set_variables)
# Build RabbitMQ components
set(BUILD_RABBITMQ FALSE CACHE BOOL "Build RabbitMQ components")
# Build the binlog router
set(BUILD_BINLOG TRUE CACHE BOOL "Build binlog router")
@ -99,7 +99,7 @@ macro(check_dirs)
set(DEPS_OK TRUE CACHE BOOL "If all the dependencies were found.")
# Find the MySQL headers if they were not defined
if(DEFINED MYSQL_DIR)
debugmsg("Searching for MySQL headers at: ${MYSQL_DIR}")
list(APPEND CMAKE_INCLUDE_PATH ${MYSQL_DIR})
@ -107,9 +107,9 @@ macro(check_dirs)
else()
find_path(MYSQL_DIR_LOC mysql.h PATH_SUFFIXES mysql mariadb)
endif()
debugmsg("Search returned: ${MYSQL_DIR_LOC}")
debugmsg("Search returned: ${MYSQL_DIR_LOC}")
if(${MYSQL_DIR_LOC} MATCHES "NOTFOUND")
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
message(FATAL_ERROR "Fatal Error: MySQL headers were not found.")
@ -123,7 +123,7 @@ debugmsg("Search returned: ${MYSQL_DIR_LOC}")
# Find the errmsg.sys file if it was not defied
if( DEFINED ERRMSG )
debugmsg("Looking for errmsg.sys at: ${ERRMSG}")
if(NOT(IS_DIRECTORY ${ERRMSG}))
if(NOT(IS_DIRECTORY ${ERRMSG}))
get_filename_component(ERRMSG ${ERRMSG} PATH)
debugmsg("Path to file is: ${ERRMSG}")
endif()
@ -146,65 +146,65 @@ debugmsg("Search returned: ${MYSQL_DIR_LOC}")
unset(ERRMSG_FILE)
# Find the embedded mysql library
if (DEFINED EMBEDDED_LIB)
if( NOT (IS_DIRECTORY ${EMBEDDED_LIB}) )
debugmsg("EMBEDDED_LIB is not a directory: ${EMBEDDED_LIB}")
if(${CMAKE_VERSION} VERSION_LESS 2.8.12 )
set(COMP_VAR PATH)
else()
set(COMP_VAR DIRECTORY)
endif()
get_filename_component(EMBEDDED_LIB ${EMBEDDED_LIB} ${COMP_VAR})
debugmsg("EMBEDDED_LIB directory component: ${EMBEDDED_LIB}")
endif()
debugmsg("Searching for the embedded library at: ${EMBEDDED_LIB}")
endif()
if(STATIC_EMBEDDED)
debugmsg("Using the static embedded library...")
set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
if (DEFINED EMBEDDED_LIB)
debugmsg("Searching for libmysqld.a at: ${EMBEDDED_LIB}")
find_library(EMBEDDED_LIB_STATIC libmysqld.a PATHS ${EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
else()
find_library(EMBEDDED_LIB_STATIC libmysqld.a PATH_SUFFIXES mysql mariadb)
endif()
debugmsg("Search returned: ${EMBEDDED_LIB_STATIC}")
set(EMBEDDED_LIB ${EMBEDDED_LIB_STATIC} CACHE FILEPATH "Path to libmysqld" FORCE)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
# if (DEFINED EMBEDDED_LIB)
# if( NOT (IS_DIRECTORY ${EMBEDDED_LIB}) )
# debugmsg("EMBEDDED_LIB is not a directory: ${EMBEDDED_LIB}")
# if(${CMAKE_VERSION} VERSION_LESS 2.8.12 )
# set(COMP_VAR PATH)
# else()
# set(COMP_VAR DIRECTORY)
# endif()
# get_filename_component(EMBEDDED_LIB ${EMBEDDED_LIB} ${COMP_VAR})
# debugmsg("EMBEDDED_LIB directory component: ${EMBEDDED_LIB}")
# endif()
# debugmsg("Searching for the embedded library at: ${EMBEDDED_LIB}")
# endif()
else()
debugmsg("Using the dynamic embedded library...")
set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".so")
if (DEFINED EMBEDDED_LIB)
debugmsg("Searching for libmysqld.so at: ${EMBEDDED_LIB}")
find_library(EMBEDDED_LIB_DYNAMIC mysqld PATHS ${EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
else()
find_library(EMBEDDED_LIB_DYNAMIC mysqld PATH_SUFFIXES mysql mariadb)
endif()
debugmsg("Search returned: ${EMBEDDED_LIB_DYNAMIC}")
set(EMBEDDED_LIB ${EMBEDDED_LIB_DYNAMIC} CACHE FILEPATH "Path to libmysqld" FORCE)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
endif()
unset(EMBEDDED_LIB_DYNAMIC)
unset(EMBEDDED_LIB_STATIC)
unset(OLD_SUFFIXES)
# if(STATIC_EMBEDDED)
# Inform the user about the embedded library
if( (${EMBEDDED_LIB} MATCHES "NOTFOUND") OR (${EMBEDDED_LIB} MATCHES "NOTFOUND"))
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
message(FATAL_ERROR "Library not found: libmysqld. If your install of MySQL is in a non-default location, please provide the location with -DEMBEDDED_LIB=<path to library>")
else()
get_filename_component(EMBEDDED_LIB ${EMBEDDED_LIB} REALPATH)
message(STATUS "Using embedded library: ${EMBEDDED_LIB}")
endif()
# debugmsg("Using the static embedded library...")
# set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
# set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
# if (DEFINED EMBEDDED_LIB)
# debugmsg("Searching for libmysqld.a at: ${EMBEDDED_LIB}")
# find_library(EMBEDDED_LIB_STATIC libmysqld.a PATHS ${EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
# else()
# find_library(EMBEDDED_LIB_STATIC libmysqld.a PATH_SUFFIXES mysql mariadb)
# endif()
# debugmsg("Search returned: ${EMBEDDED_LIB_STATIC}")
# set(EMBEDDED_LIB ${EMBEDDED_LIB_STATIC} CACHE FILEPATH "Path to libmysqld" FORCE)
# set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
# else()
# debugmsg("Using the dynamic embedded library...")
# set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
# set(CMAKE_FIND_LIBRARY_SUFFIXES ".so")
# if (DEFINED EMBEDDED_LIB)
# debugmsg("Searching for libmysqld.so at: ${EMBEDDED_LIB}")
# find_library(EMBEDDED_LIB_DYNAMIC mysqld PATHS ${EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
# else()
# find_library(EMBEDDED_LIB_DYNAMIC mysqld PATH_SUFFIXES mysql mariadb)
# endif()
# debugmsg("Search returned: ${EMBEDDED_LIB_DYNAMIC}")
# set(EMBEDDED_LIB ${EMBEDDED_LIB_DYNAMIC} CACHE FILEPATH "Path to libmysqld" FORCE)
# set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
# endif()
# unset(EMBEDDED_LIB_DYNAMIC)
# unset(EMBEDDED_LIB_STATIC)
# unset(OLD_SUFFIXES)
# # Inform the user about the embedded library
# if( (${EMBEDDED_LIB} MATCHES "NOTFOUND") OR (${EMBEDDED_LIB} MATCHES "NOTFOUND"))
# set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
# message(FATAL_ERROR "Library not found: libmysqld. If your install of MySQL is in a non-default location, please provide the location with -DEMBEDDED_LIB=<path to library>")
# else()
# get_filename_component(EMBEDDED_LIB ${EMBEDDED_LIB} REALPATH)
# message(STATUS "Using embedded library: ${EMBEDDED_LIB}")
# endif()
# Check which init.d script to install

View File

@ -1,7 +1,7 @@
if(BUILD_TESTS OR BUILD_TOOLS)
file(GLOB FULLCORE_SRC *.c)
add_library(fullcore STATIC ${FULLCORE_SRC})
target_link_libraries(fullcore ${CURL_LIBRARIES} log_manager utils pthread ${EMBEDDED_LIB} ssl aio rt crypt dl crypto inih z m stdc++)
target_link_libraries(fullcore ${CURL_LIBRARIES} log_manager utils pthread ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} ssl aio rt crypt dl crypto inih z m stdc++)
endif()
add_executable(maxscale atomic.c buffer.c spinlock.c gateway.c
@ -9,7 +9,7 @@ add_executable(maxscale atomic.c buffer.c spinlock.c gateway.c
poll.c config.c users.c hashtable.c dbusers.c thread.c gwbitmask.c
monitor.c adminusers.c secrets.c filter.c modutil.c hint.c
housekeeper.c memlog.c resultset.c)
target_link_libraries(maxscale ${EMBEDDED_LIB} ${CURL_LIBRARIES} log_manager utils ssl aio pthread crypt dl crypto inih z rt m stdc++)
target_link_libraries(maxscale ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} ${CURL_LIBRARIES} log_manager utils ssl aio pthread crypt dl crypto inih z rt m stdc++)
install(TARGETS maxscale DESTINATION bin)
add_executable(maxkeys maxkeys.c secrets.c utils.c)