Added find_package modules for MySQLClient and RabbitMQ and fixed an error in consumer.c
This commit is contained in:
@ -1,19 +1,17 @@
|
||||
if (NOT ( DEFINED MYSQL_CLIENT_LIB ) )
|
||||
find_library(MYSQL_CLIENT_LIB NAMES mysqlclient PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql mariadb)
|
||||
endif()
|
||||
if(RABBITMQ_FOUND AND MYSQLCLIENT_FOUND)
|
||||
|
||||
if (NOT ( DEFINED MYSQL_CLIENT_HEADERS ) )
|
||||
find_path(MYSQL_CLIENT_HEADERS NAMES mysql.h PATH_SUFFIXES mysql mariadb)
|
||||
endif()
|
||||
|
||||
if( ( RABBITMQ_LIB AND RABBITMQ_HEADERS ) AND ( NOT ( ${MYSQL_CLIENT_LIB} STREQUAL "MYSQL_CLIENT_LIB-NOTFOUND" ) ) AND ( NOT ( ${MYSQL_CLIENT_HEADERS} STREQUAL "MYSQL_CLIENT_HEADERS-NOTFOUND" ) ) )
|
||||
include_directories(${MYSQL_CLIENT_HEADERS})
|
||||
include_directories(${MYSQLCLIENT_HEADERS})
|
||||
add_executable (consumer consumer.c)
|
||||
target_link_libraries(consumer ${MYSQL_CLIENT_LIB} rabbitmq inih)
|
||||
|
||||
if(MYSQLCLIENT_FOUND)
|
||||
target_link_libraries(consumer ${MYSQLCLIENT_LIBRARIES} rabbitmq inih)
|
||||
elseif(MYSQLCLIENT_STATIC_FOUND)
|
||||
target_link_libraries(consumer ${MYSQLCLIENT_STATIC_LIBRARIES} rabbitmq inih)
|
||||
endif()
|
||||
|
||||
install(TARGETS consumer DESTINATION bin)
|
||||
install(FILES consumer.cnf DESTINATION etc)
|
||||
|
||||
|
||||
else()
|
||||
|
||||
message(FATAL_ERROR "Error: Can not find requred libraries and headers: librabbitmq libmysqlclient")
|
||||
|
@ -143,7 +143,7 @@ int connectToServer(MYSQL* server)
|
||||
}
|
||||
|
||||
memset(qstr,0,bsz);
|
||||
sprintf(qstr,DB_TABLE);
|
||||
sprintf(qstr,"%s",DB_TABLE);
|
||||
if(mysql_query(server,qstr)){
|
||||
fprintf(stderr,"Error: Could not send query MySQL server: %s\n",mysql_error(server));
|
||||
}
|
||||
|
Reference in New Issue
Block a user