From 081bacdc64c2f243824f2cf2d7095c10d5cab3be Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 1 Feb 2016 11:52:47 +0200 Subject: [PATCH] Switched to MySQL client library headers for MaxScale The include directories previously used by MaxScale were from the embedded library. All parts of MaxScale apart from the query classifier now use the client libraries. --- CMakeLists.txt | 2 +- ...lient.cmake => FindMariaDBConnector.cmake} | 22 +-- cmake/FindMySQL.cmake | 138 ++++++++++++------ cmake/macros.cmake | 62 ++------ .../qc_mysqlembedded/CMakeLists.txt | 10 +- query_classifier/test/CMakeLists.txt | 7 +- server/CMakeLists.txt | 3 +- server/core/CMakeLists.txt | 1 + server/modules/routing/binlog/CMakeLists.txt | 2 +- .../routing/binlog/test/CMakeLists.txt | 2 +- 10 files changed, 124 insertions(+), 125 deletions(-) rename cmake/{FindMySQLClient.cmake => FindMariaDBConnector.cmake} (54%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 51735eda8..0c276ea6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ check_deps() check_dirs() find_package(OpenSSL) find_package(Valgrind) -find_package(MySQLClient) +find_package(MariaDBConnector) find_package(MySQL) find_package(Pandoc) find_package(TCMalloc) diff --git a/cmake/FindMySQLClient.cmake b/cmake/FindMariaDBConnector.cmake similarity index 54% rename from cmake/FindMySQLClient.cmake rename to cmake/FindMariaDBConnector.cmake index a08c9692c..b425f8976 100644 --- a/cmake/FindMySQLClient.cmake +++ b/cmake/FindMariaDBConnector.cmake @@ -1,18 +1,18 @@ -# This CMake file tries to find the the MySQL client library +# This CMake file tries to find the the MariaDB Connector-C # The following variables are set: -# MYSQLCLIENT_FOUND - System has MySQL client -# MYSQLCLIENT_STATIC_FOUND - System has statically linked MySQL client -# MARIADB_CONNECTOR_LIB - The MySQL client library -# MARIADB_CONNECTOR_STATIC_LIB - The static MySQL client library -# MYSQLCLIENT_HEADERS - The MySQL client headers +# MARIADB_CONNECTOR_FOUND - System has the connector +# MARIADB_CONNECTOR_STATIC_FOUND - System has static version of the connector library +# MARIADB_CONNECTOR_LIBRARIES - The dynamic connector libraries +# MARIADB_CONNECTOR_STATIC_LIBRARIES - The static connector libraries +# MARIADB_CONNECTOR_INCLUDE_DIR - The connector headers find_library(MARIADB_CONNECTOR_LIB NAMES mysqlclient PATH_SUFFIXES mysql mariadb) if(${MARIADB_CONNECTOR_LIB} MATCHES "NOTFOUND") - set(MYSQLCLIENT_FOUND FALSE CACHE INTERNAL "") + set(MARIADB_CONNECTOR_FOUND FALSE CACHE INTERNAL "") message(STATUS "Dynamic MySQL client library not found.") unset(MARIADB_CONNECTOR_LIB) else() - set(MYSQLCLIENT_FOUND TRUE CACHE INTERNAL "") + set(MARIADB_CONNECTOR_FOUND TRUE CACHE INTERNAL "") message(STATUS "Found dynamic MySQL client library: ${MARIADB_CONNECTOR_LIB}") endif() @@ -22,12 +22,12 @@ find_library(MARIADB_CONNECTOR_STATIC_LIB NAMES mysqlclient PATH_SUFFIXES mysql set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES}) if(${MARIADB_CONNECTOR_STATIC_LIB} MATCHES "NOTFOUND") - set(MYSQLCLIENT_STATIC_FOUND FALSE CACHE INTERNAL "") + set(MARIADB_CONNECTOR_STATIC_FOUND FALSE CACHE INTERNAL "") message(STATUS "Static MySQL client library not found.") unset(MARIADB_CONNECTOR_STATIC_LIB) else() - set(MYSQLCLIENT_STATIC_FOUND TRUE CACHE INTERNAL "") + set(MARIADB_CONNECTOR_STATIC_FOUND TRUE CACHE INTERNAL "") message(STATUS "Found statc MySQL client library: ${MARIADB_CONNECTOR_STATIC_LIB}") endif() -find_path(MYSQLCLIENT_HEADERS mysql.h PATH_SUFFIXES mysql mariadb) +find_path(MARIADB_CONNECTOR_INCLUDE_DIR mysql.h PATH_SUFFIXES mysql mariadb) diff --git a/cmake/FindMySQL.cmake b/cmake/FindMySQL.cmake index a3cbfe8ec..2eb83155c 100644 --- a/cmake/FindMySQL.cmake +++ b/cmake/FindMySQL.cmake @@ -1,42 +1,43 @@ # This CMake file tries to find the the mysql_version.h header # and to parse it for version and provider strings # The following variables are set: -# MYSQL_VERSION - The MySQL version number -# MYSQL_PROVIDER - The MySQL provider e.g. MariaDB -# MYSQL_EMBEDDED_LIB - The MySQL embedded library +# MYSQL_EMBEDDED_VERSION - The MySQL version number +# MYSQL_EMBEDDED_PROVIDER - The MySQL provider e.g. MariaDB +# MYSQL_EMBEDDED_LIBRARIES - The MySQL embedded library +# MYSQL_EMBEDDED_INCLUDE_DIR - Path to MySQL headers -find_file(MYSQL_VERSION_H mysql_version.h PATH_SUFFIXES mysql) -if(MYSQL_VERSION_H MATCHES "MYSQL_VERSION_H-NOTFOUND") +find_file(MYSQL_EMBEDDED_VERSION_H mysql_version.h PATH_SUFFIXES mysql) +if(MYSQL_EMBEDDED_VERSION_H MATCHES "MYSQL_EMBEDDED_VERSION_H-NOTFOUND") message(FATAL_ERROR "Cannot find the mysql_version.h header") else() - message(STATUS "Found mysql_version.h: ${MYSQL_VERSION_H}") + message(STATUS "Found mysql_version.h: ${MYSQL_EMBEDDED_VERSION_H}") endif() -file(READ ${MYSQL_VERSION_H} MYSQL_VERSION_CONTENTS) -string(REGEX REPLACE ".*MYSQL_SERVER_VERSION[^0-9.]+([0-9.]+).*" "\\1" MYSQL_VERSION ${MYSQL_VERSION_CONTENTS}) -string(REGEX REPLACE ".*MYSQL_COMPILATION_COMMENT[[:space:]]+\"(.+)\".*" "\\1" MYSQL_PROVIDER ${MYSQL_VERSION_CONTENTS}) -string(TOLOWER ${MYSQL_PROVIDER} MYSQL_PROVIDER) -if(MYSQL_PROVIDER MATCHES "[mM]aria[dD][bB]") - set(MYSQL_PROVIDER "MariaDB" CACHE INTERNAL "The MySQL provider") -elseif(MYSQL_PROVIDER MATCHES "mysql") - set(MYSQL_PROVIDER "MySQL" CACHE INTERNAL "The MySQL provider") -elseif(MYSQL_PROVIDER MATCHES "percona") - set(MYSQL_PROVIDER "Percona" CACHE INTERNAL "The MySQL provider") +file(READ ${MYSQL_EMBEDDED_VERSION_H} MYSQL_EMBEDDED_VERSION_CONTENTS) +string(REGEX REPLACE ".*MYSQL_SERVER_VERSION[^0-9.]+([0-9.]+).*" "\\1" MYSQL_EMBEDDED_VERSION ${MYSQL_EMBEDDED_VERSION_CONTENTS}) +string(REGEX REPLACE ".*MYSQL_COMPILATION_COMMENT[[:space:]]+\"(.+)\".*" "\\1" MYSQL_EMBEDDED_PROVIDER ${MYSQL_EMBEDDED_VERSION_CONTENTS}) +string(TOLOWER ${MYSQL_EMBEDDED_PROVIDER} MYSQL_EMBEDDED_PROVIDER) +if(MYSQL_EMBEDDED_PROVIDER MATCHES "[mM]aria[dD][bB]") + set(MYSQL_EMBEDDED_PROVIDER "MariaDB" CACHE INTERNAL "The MySQL provider") +elseif(MYSQL_EMBEDDED_PROVIDER MATCHES "mysql") + set(MYSQL_EMBEDDED_PROVIDER "MySQL" CACHE INTERNAL "The MySQL provider") +elseif(MYSQL_EMBEDDED_PROVIDER MATCHES "percona") + set(MYSQL_EMBEDDED_PROVIDER "Percona" CACHE INTERNAL "The MySQL provider") else() - set(MYSQL_PROVIDER "Unknown" CACHE INTERNAL "The MySQL provider") + set(MYSQL_EMBEDDED_PROVIDER "Unknown" CACHE INTERNAL "The MySQL provider") endif() -message(STATUS "MySQL version: ${MYSQL_VERSION}") -message(STATUS "MySQL provider: ${MYSQL_PROVIDER}") +message(STATUS "MySQL version: ${MYSQL_EMBEDDED_VERSION}") +message(STATUS "MySQL provider: ${MYSQL_EMBEDDED_PROVIDER}") -if(NOT MYSQL_PROVIDER STREQUAL "MariaDB") -message(WARNING "Not using a release version of MariaDB server. If this is intentional, please ignore this warning. Otherwise make sure the right libraries are installed and CMake finds the right libraries.") +if(NOT MYSQL_EMBEDDED_PROVIDER STREQUAL "MariaDB") + message(WARNING "Not using a release version of MariaDB server. If this is intentional, please ignore this warning. Otherwise make sure the right libraries are installed and CMake finds the right libraries.") endif() -if(MYSQL_VERSION VERSION_LESS 5.5.41) -message(WARNING "MySQL version is ${MYSQL_VERSION}. Minimum supported version is 5.5.41.") +if(MYSQL_EMBEDDED_VERSION VERSION_LESS 5.5.41) + message(WARNING "MySQL version is ${MYSQL_EMBEDDED_VERSION}. Minimum supported version is 5.5.41.") endif() -if(NOT (MYSQL_VERSION VERSION_LESS 10.1)) +if(NOT (MYSQL_EMBEDDED_VERSION VERSION_LESS 10.1)) # 10.1 needs lzma find_library(HAVE_LIBLZMA NAMES lzma) @@ -47,18 +48,18 @@ if(NOT (MYSQL_VERSION VERSION_LESS 10.1)) endif() -if (DEFINED MYSQL_EMBEDDED_LIB) - if( NOT (IS_DIRECTORY ${MYSQL_EMBEDDED_LIB}) ) - debugmsg("MYSQL_EMBEDDED_LIB is not a directory: ${MYSQL_EMBEDDED_LIB}") +if (DEFINED MYSQL_EMBEDDED_LIBRARIES) + if( NOT (IS_DIRECTORY ${MYSQL_EMBEDDED_LIBRARIES}) ) + debugmsg("MYSQL_EMBEDDED_LIBRARIES is not a directory: ${MYSQL_EMBEDDED_LIBRARIES}") if(${CMAKE_VERSION} VERSION_LESS 2.8.12 ) set(COMP_VAR PATH) else() set(COMP_VAR DIRECTORY) endif() - get_filename_component(MYSQL_EMBEDDED_LIB ${MYSQL_EMBEDDED_LIB} ${COMP_VAR}) - debugmsg("MYSQL_EMBEDDED_LIB directory component: ${MYSQL_EMBEDDED_LIB}") + get_filename_component(MYSQL_EMBEDDED_LIBRARIES ${MYSQL_EMBEDDED_LIBRARIES} ${COMP_VAR}) + debugmsg("MYSQL_EMBEDDED_LIBRARIES directory component: ${MYSQL_EMBEDDED_LIBRARIES}") endif() - debugmsg("Searching for the embedded library at: ${MYSQL_EMBEDDED_LIB}") + debugmsg("Searching for the embedded library at: ${MYSQL_EMBEDDED_LIBRARIES}") endif() if(STATIC_EMBEDDED) @@ -66,38 +67,38 @@ if(STATIC_EMBEDDED) debugmsg("Using the static embedded library...") set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") - if (DEFINED MYSQL_EMBEDDED_LIB) - debugmsg("Searching for libmysqld.a at: ${MYSQL_EMBEDDED_LIB}") - find_library(MYSQL_EMBEDDED_LIB_STATIC libmysqld.a PATHS ${MYSQL_EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH) + if (DEFINED MYSQL_EMBEDDED_LIBRARIES) + debugmsg("Searching for libmysqld.a at: ${MYSQL_EMBEDDED_LIBRARIES}") + find_library(MYSQL_EMBEDDED_LIBRARIES_STATIC libmysqld.a PATHS ${MYSQL_EMBEDDED_LIBRARIES} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH) else() - find_library(MYSQL_EMBEDDED_LIB_STATIC libmysqld.a PATH_SUFFIXES mysql mariadb) + find_library(MYSQL_EMBEDDED_LIBRARIES_STATIC libmysqld.a PATH_SUFFIXES mysql mariadb) endif() - debugmsg("Search returned: ${MYSQL_EMBEDDED_LIB_STATIC}") + debugmsg("Search returned: ${MYSQL_EMBEDDED_LIBRARIES_STATIC}") - set(MYSQL_EMBEDDED_LIB ${MYSQL_EMBEDDED_LIB_STATIC} CACHE FILEPATH "Path to libmysqld" FORCE) + set(MYSQL_EMBEDDED_LIBRARIES ${MYSQL_EMBEDDED_LIBRARIES_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 MYSQL_EMBEDDED_LIB) - debugmsg("Searching for libmysqld.so at: ${MYSQL_EMBEDDED_LIB}") - find_library(MYSQL_EMBEDDED_LIB_DYNAMIC mysqld PATHS ${MYSQL_EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH) + if (DEFINED MYSQL_EMBEDDED_LIBRARIES) + debugmsg("Searching for libmysqld.so at: ${MYSQL_EMBEDDED_LIBRARIES}") + find_library(MYSQL_EMBEDDED_LIBRARIES_DYNAMIC mysqld PATHS ${MYSQL_EMBEDDED_LIBRARIES} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH) else() - find_library(MYSQL_EMBEDDED_LIB_DYNAMIC mysqld PATH_SUFFIXES mysql mariadb) + find_library(MYSQL_EMBEDDED_LIBRARIES_DYNAMIC mysqld PATH_SUFFIXES mysql mariadb) endif() - debugmsg("Search returned: ${MYSQL_EMBEDDED_LIB_DYNAMIC}") - set(MYSQL_EMBEDDED_LIB ${MYSQL_EMBEDDED_LIB_DYNAMIC} CACHE FILEPATH "Path to libmysqld" FORCE) + debugmsg("Search returned: ${MYSQL_EMBEDDED_LIBRARIES_DYNAMIC}") + set(MYSQL_EMBEDDED_LIBRARIES ${MYSQL_EMBEDDED_LIBRARIES_DYNAMIC} CACHE FILEPATH "Path to libmysqld" FORCE) set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES}) endif() -unset(MYSQL_EMBEDDED_LIB_DYNAMIC) -unset(MYSQL_EMBEDDED_LIB_STATIC) +unset(MYSQL_EMBEDDED_LIBRARIES_DYNAMIC) +unset(MYSQL_EMBEDDED_LIBRARIES_STATIC) unset(OLD_SUFFIXES) -check_library_exists(${MYSQL_EMBEDDED_LIB} pcre_stack_guard ${MYSQL_EMBEDDED_LIB} HAVE_EMBEDDED_PCRE) +check_library_exists(${MYSQL_EMBEDDED_LIBRARIES} pcre_stack_guard ${MYSQL_EMBEDDED_LIBRARIES} HAVE_EMBEDDED_PCRE) if(HAVE_EMBEDDED_PCRE) set(PCRE_LINK_FLAGS "" CACHE INTERNAL "pcre linker flags") @@ -110,8 +111,49 @@ else() message(FATAL_ERROR "Could not find PCRE libraries.") endif() endif() -if( (${MYSQL_EMBEDDED_LIB} MATCHES "NOTFOUND") OR (${MYSQL_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 -DMYSQL_EMBEDDED_LIB=") +if( (${MYSQL_EMBEDDED_LIBRARIES} MATCHES "NOTFOUND") OR (${MYSQL_EMBEDDED_LIBRARIES} 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 -DMYSQL_EMBEDDED_LIBRARIES=") else() - message(STATUS "Using embedded library: ${MYSQL_EMBEDDED_LIB}") + message(STATUS "Using embedded library: ${MYSQL_EMBEDDED_LIBRARIES}") endif() + +# Find the MySQL headers if they were not defined +if(DEFINED MYSQL_EMBEDDED_INCLUDE_DIR) + list(APPEND CMAKE_INCLUDE_PATH ${MYSQL_EMBEDDED_INCLUDE_DIR}) + find_path(MYSQL_EMBEDDED_INCLUDE_DIR_LOC mysql.h PATHS ${MYSQL_EMBEDDED_INCLUDE_DIR} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH) +else() + find_path(MYSQL_EMBEDDED_INCLUDE_DIR_LOC mysql.h PATH_SUFFIXES mysql mariadb) +endif() + +if(${MYSQL_EMBEDDED_INCLUDE_DIR_LOC} MATCHES "NOTFOUND") + message(FATAL_ERROR "Fatal Error: MySQL headers were not found.") +else() + set(MYSQL_EMBEDDED_INCLUDE_DIR ${MYSQL_EMBEDDED_INCLUDE_DIR_LOC} CACHE PATH "Path to MySQL headers" FORCE) + message(STATUS "Using MySQL headers found at: ${MYSQL_EMBEDDED_INCLUDE_DIR}") +endif() + +unset(MYSQL_EMBEDDED_INCLUDE_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})) + get_filename_component(ERRMSG ${ERRMSG} PATH) + debugmsg("Path to file is: ${ERRMSG}") + endif() + find_file(ERRMSG_FILE errmsg.sys PATHS ${ERRMSG} NO_DEFAULT_PATH) + if(${ERRMSG_FILE} MATCHES "NOTFOUND") + message(FATAL_ERROR "Fatal Error: The errmsg.sys file was not found at ${ERRMSG}") + else() + message(STATUS "Using custom errmsg.sys found at: ${ERRMSG_FILE}") + endif() +else() + find_file(ERRMSG_FILE errmsg.sys PATHS /usr/share /usr/share/mysql /usr/local/share/mysql PATH_SUFFIXES english mysql/english) + if(${ERRMSG_FILE} MATCHES "NOTFOUND") + message(FATAL_ERROR "Fatal Error: The errmsg.sys file was not found, please define the path to it by using -DERRMSG=") + else() + message(STATUS "Using errmsg.sys found at: ${ERRMSG_FILE}") + endif() +endif() +set(ERRMSG ${ERRMSG_FILE} CACHE FILEPATH "Path to the errmsg.sys file." FORCE) +unset(ERRMSG_FILE) diff --git a/cmake/macros.cmake b/cmake/macros.cmake index 3999cbe72..b49747f5d 100644 --- a/cmake/macros.cmake +++ b/cmake/macros.cmake @@ -144,60 +144,15 @@ macro(check_deps) endmacro() macro(check_dirs) - # 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}) - find_path(MYSQL_DIR_LOC mysql.h PATHS ${MYSQL_DIR} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH) - else() - find_path(MYSQL_DIR_LOC mysql.h PATH_SUFFIXES mysql mariadb) - endif() - -debugmsg("Search returned: ${MYSQL_DIR_LOC}") - - if(${MYSQL_DIR_LOC} MATCHES "NOTFOUND") - message(FATAL_ERROR "Fatal Error: MySQL headers were not found.") - else() - set(MYSQL_DIR ${MYSQL_DIR_LOC} CACHE PATH "Path to MySQL headers" FORCE) - message(STATUS "Using MySQL headers found at: ${MYSQL_DIR}") - endif() - - unset(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})) - get_filename_component(ERRMSG ${ERRMSG} PATH) - debugmsg("Path to file is: ${ERRMSG}") - endif() - find_file(ERRMSG_FILE errmsg.sys PATHS ${ERRMSG} NO_DEFAULT_PATH) - if(${ERRMSG_FILE} MATCHES "NOTFOUND") - message(FATAL_ERROR "Fatal Error: The errmsg.sys file was not found at ${ERRMSG}") - else() - message(STATUS "Using custom errmsg.sys found at: ${ERRMSG_FILE}") - endif() - else() - find_file(ERRMSG_FILE errmsg.sys PATHS /usr/share /usr/share/mysql /usr/local/share/mysql PATH_SUFFIXES english mysql/english) - if(${ERRMSG_FILE} MATCHES "NOTFOUND") - message(FATAL_ERROR "Fatal Error: The errmsg.sys file was not found, please define the path to it by using -DERRMSG=") - else() - message(STATUS "Using errmsg.sys found at: ${ERRMSG_FILE}") - endif() - endif() - set(ERRMSG ${ERRMSG_FILE} CACHE FILEPATH "Path to the errmsg.sys file." FORCE) - unset(ERRMSG_FILE) - # Check which init.d script to install if(WITH_SCRIPTS) find_file(RPM_FNC functions PATHS /etc/rc.d/init.d) if(${RPM_FNC} MATCHES "RPM_FNC-NOTFOUND") find_file(DEB_FNC init-functions PATHS /lib/lsb) if(${DEB_FNC} MATCHES "DEB_FNC-NOTFOUND") - message(FATAL_ERROR "Cannot find required init-functions in /lib/lsb/ or /etc/rc.d/init.d/, please confirm that your system files are OK.") + message(FATAL_ERROR "Cannot find required init-functions in /lib/lsb/ or /etc/rc.d/init.d/, please confirm that your system files are OK.") else() - set(DEB_BASED TRUE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.") + set(DEB_BASED TRUE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.") endif() else() set(DEB_BASED FALSE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.") @@ -215,16 +170,17 @@ endmacro() function(subdirs VAR DIRPATH) -if(${CMAKE_VERSION} VERSION_LESS 2.8.12 ) -set(COMP_VAR PATH) -else() -set(COMP_VAR DIRECTORY) -endif() + if(${CMAKE_VERSION} VERSION_LESS 2.8.12 ) + set(COMP_VAR PATH) + else() + set(COMP_VAR DIRECTORY) + endif() file(GLOB_RECURSE SDIR ${DIRPATH}/*) foreach(LOOP ${SDIR}) get_filename_component(LOOP ${LOOP} ${COMP_VAR}) list(APPEND ALLDIRS ${LOOP}) endforeach() list(REMOVE_DUPLICATES ALLDIRS) - set(${VAR} "${ALLDIRS}" CACHE PATH " " FORCE) + set(${VAR} "${ALLDIRS}" CACHE PATH " " FORCE) + endfunction() diff --git a/query_classifier/qc_mysqlembedded/CMakeLists.txt b/query_classifier/qc_mysqlembedded/CMakeLists.txt index d2fc724f1..202f99c30 100644 --- a/query_classifier/qc_mysqlembedded/CMakeLists.txt +++ b/query_classifier/qc_mysqlembedded/CMakeLists.txt @@ -1,12 +1,14 @@ -subdirs(MYSQL_DIR_ALL ${MYSQL_DIR}) -foreach(DIR ${MYSQL_DIR_ALL}) +# Include the embedded library headers +subdirs(MYSQL_INCLUDE_DIR_ALL ${MYSQL_EMBEDDED_INCLUDE_DIR}) +foreach(DIR ${MYSQL_INCLUDE_DIR_ALL}) include_directories(${DIR}) endforeach() -include_directories(${MYSQL_INCLUDE}) +include_directories(${MYSQL_EMMBEDDED_INCLUDE_DIR}/..) add_library(qc_mysqlembedded SHARED qc_mysqlembedded.cc) -target_link_libraries(qc_mysqlembedded ${MYSQL_EMBEDDED_LIB} aio crypt crypto dl m ${PCRE_LINK_FLAGS} ssl stdc++ z) +include_directories(${MYSQL_INCLUDE_DIR}) +target_link_libraries(qc_mysqlembedded ${MYSQL_EMBEDDED_LIBRARIES} aio crypt crypto dl m ${PCRE_LINK_FLAGS} ssl stdc++ z) set_target_properties(qc_mysqlembedded PROPERTIES VERSION "1.0.0") set_target_properties(qc_mysqlembedded PROPERTIES LINK_FLAGS -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/qc_mysqlembedded.map) #set_target_properties(qc_mysqlembedded PROPERTIES LINK_FLAGS -Wl,-z,defs) diff --git a/query_classifier/test/CMakeLists.txt b/query_classifier/test/CMakeLists.txt index f1c36e080..59ec4d7a8 100644 --- a/query_classifier/test/CMakeLists.txt +++ b/query_classifier/test/CMakeLists.txt @@ -1,8 +1,5 @@ -subdirs(MYSQL_DIR_ALL ${MYSQL_DIR}) -foreach(DIR ${MYSQL_DIR_ALL}) - include_directories(${DIR}) -endforeach() -include_directories(${MYSQL_INCLUDE}) +# Use the client libraries in the tests +include_directories(${MYSQLCLIENT_INCLUDE_DIR}) if(${ERRMSG} MATCHES "ERRMSG-NOTFOUND") message(FATAL_ERROR "The errmsg.sys file was not found, please define the path with -DERRMSG=") diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index f4f9d1aca..69361c9d6 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -1,4 +1,5 @@ -include_directories(${MARIADB_CONNECTOR_INCLUDE}) +# Use the client libraries in MaxScale core +include_directories(${MARIADB_CONNECTOR_INCLUDE_DIR}) add_subdirectory(core) add_subdirectory(modules) diff --git a/server/core/CMakeLists.txt b/server/core/CMakeLists.txt index 173a2347a..7eae4fdeb 100644 --- a/server/core/CMakeLists.txt +++ b/server/core/CMakeLists.txt @@ -10,6 +10,7 @@ endif() add_dependencies(maxscale-common pcre2) install(TARGETS maxscale-common DESTINATION ${MAXSCALE_LIBDIR}) +set_target_properties(maxscale-common PROPERTIES VERSION "1.0.0") add_executable(maxscale gateway.c) add_dependencies(maxscale pcre2) diff --git a/server/modules/routing/binlog/CMakeLists.txt b/server/modules/routing/binlog/CMakeLists.txt index 0eaf5c27b..6eace29d0 100644 --- a/server/modules/routing/binlog/CMakeLists.txt +++ b/server/modules/routing/binlog/CMakeLists.txt @@ -6,7 +6,7 @@ install(TARGETS binlogrouter DESTINATION ${MAXSCALE_LIBDIR}) add_executable(maxbinlogcheck maxbinlogcheck.c blr_file.c blr_cache.c blr_master.c blr_slave.c blr.c) # maxbinlogcheck refers to my_uuid_init and my_uuin. They are non-public functions and # should not be used. They are found only from the embedded lib. -target_link_libraries(maxbinlogcheck maxscale-common query_classifier ${MYSQL_EMBEDDED_LIB}) +target_link_libraries(maxbinlogcheck maxscale-common query_classifier ${MYSQL_EMBEDDED_LIBRARIES}) install(TARGETS maxbinlogcheck DESTINATION bin) diff --git a/server/modules/routing/binlog/test/CMakeLists.txt b/server/modules/routing/binlog/test/CMakeLists.txt index 0f967487d..418b8f6b9 100644 --- a/server/modules/routing/binlog/test/CMakeLists.txt +++ b/server/modules/routing/binlog/test/CMakeLists.txt @@ -2,6 +2,6 @@ if(BUILD_TESTS) add_executable(testbinlogrouter testbinlog.c ../blr.c ../blr_slave.c ../blr_master.c ../blr_file.c ../blr_cache.c) # testbinlogrouter refers to my_uuid_init and my_uuin. They are non-public functions and # should not be used. They are found only from the embedded lib. - target_link_libraries(testbinlogrouter maxscale-common query_classifier ${MYSQL_EMBEDDED_LIB}) + target_link_libraries(testbinlogrouter maxscale-common query_classifier ${MYSQL_EMBEDDED_LIBRARIES}) add_test(TestBinlogRouter ${CMAKE_CURRENT_BINARY_DIR}/testbinlogrouter) endif()