From fdf12711386ad62fd4b9063280c473b129f0ca26 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 16 Sep 2014 11:34:05 +0300 Subject: [PATCH] Cleaned up RabbitMQ component building. --- CMakeLists.txt | 25 ++++++++++++++++++++----- rabbitmq_consumer/CMakeLists.txt | 18 +++++++----------- server/modules/filter/CMakeLists.txt | 12 ++++++++---- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88574b363..21055593f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,11 @@ enable_testing() set_variables() set_maxscale_version() set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "Prefix prepended to install directories." FORCE) -set(CMAKE_BUILD_TYPE "${BUILD_TYPE}" CACHE INTERNAL "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel. " FORCE) +if(NOT ( BUILD_TYPE STREQUAL "None" ) ) + set(CMAKE_BUILD_TYPE "${BUILD_TYPE}" CACHE INTERNAL "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel. " FORCE) +else() + set(CMAKE_BUILD_TYPE "") +endif() project(MaxScale) @@ -74,16 +78,27 @@ include_directories(server/include) include_directories(server/inih) include_directories(server/modules/include) +if(BUILD_RABBITMQ) + + find_path(RABBITMQ_HEADERS amqp.h DOC "Path to the librabbitmq-c headers.") + find_library(RABBITMQ_LIB rabbitmq DOC "Path to the librabbitmq-c libraries.") + if(RABBITMQ_HEADERS AND RABBITMQ_LIB) + message(STATUS "Building RabbitMQ components") + include_directories(${RABBITMQ_HEADERS}) + link_directories(${RABBITMQ_LIB}) + add_subdirectory(rabbitmq_consumer) + else() + message(ERROR "Error: Cannot find the librabbitmq-c headers or libraries.") + endif() +endif() + + add_subdirectory(utils) add_subdirectory(log_manager) add_subdirectory(query_classifier) add_subdirectory(server) add_subdirectory(client) -if(BUILD_RABBITMQ) - message(STATUS "Building RabbitMQ components") - add_subdirectory(rabbitmq_consumer) -endif(BUILD_RABBITMQ) file(GLOB DOCS Documentation/*.pdf) diff --git a/rabbitmq_consumer/CMakeLists.txt b/rabbitmq_consumer/CMakeLists.txt index e57f715a7..5b9ed09d5 100644 --- a/rabbitmq_consumer/CMakeLists.txt +++ b/rabbitmq_consumer/CMakeLists.txt @@ -1,25 +1,21 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8) project (consumer) -find_path(RABBITMQ_C_DIRS amqp.h) -find_library(RABBITMQ_C_LIB NAMES rabbitmq) find_library(MYSQL_CLIENT_LIB NAMES mysqlclient PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql mariadb) -include_directories(${RABBITMQ_C_DIRS}) +if( ( RABBITMQ_LIB AND RABBITMQ_HEADERS ) AND MYSQL_CLIENT_LIB ) -if( ( RABBITMQ_C_LIB AND RABBITMQ_C_DIRS ) AND MYSQL_CLIENT_LIB ) - - add_executable (consumer consumer.c ${MYSQL_CLIENT_LIB} ${RABBITMQ_C_LIBRARIES}) - target_link_libraries(consumer mysqlclient) - target_link_libraries(consumer rabbitmq) - target_link_libraries(consumer inih) + add_executable (consumer consumer.c) + target_link_libraries(consumer ${MYSQL_CLIENT_LIB} rabbitmq inih) install(TARGETS consumer DESTINATION bin) install(FILES consumer.cnf DESTINATION etc) else() - message(FATAL_ERROR "Error: Can not find requred libraries.") + + message(FATAL_ERROR "Error: Can not find requred libraries and headers: librabbitmq libmysqlclient") + endif() # Packaging of RabbitMQ disabled for now diff --git a/server/modules/filter/CMakeLists.txt b/server/modules/filter/CMakeLists.txt index 8df69f41f..895b9eb20 100644 --- a/server/modules/filter/CMakeLists.txt +++ b/server/modules/filter/CMakeLists.txt @@ -1,8 +1,12 @@ if(BUILD_RABBITMQ) - add_library(mqfilter SHARED mqfilter.c) - target_link_libraries(mqfilter utils query_classifier log_manager rabbitmq) - install(TARGETS mqfilter DESTINATION modules) -endif(BUILD_RABBITMQ) + if(RABBITMQ_LIB AND RABBITMQ_HEADERS) + add_library(mqfilter SHARED mqfilter.c) + target_link_libraries(mqfilter utils query_classifier log_manager rabbitmq) + install(TARGETS mqfilter DESTINATION modules) + else() + message(ERROR "Error: Cannot find the required librabbitmq-c locations, please check that you have them configured correctly.") + endif() +endif() add_library(regexfilter SHARED regexfilter.c) target_link_libraries(regexfilter utils log_manager)