Moved CMake modules to a separate directory and disabled local installs of system files when building packages.

The building of packages with CMake now requires the -DPACKAGE=Y flag to be set when configuring CMake.
This commit is contained in:
Markus Makela
2015-01-30 15:45:33 +02:00
parent bbe73d78fd
commit 5d6b805d6e
10 changed files with 75 additions and 59 deletions

37
cmake/FindMySQL.cmake Normal file
View File

@ -0,0 +1,37 @@
# 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
find_file(MYSQL_VERSION_H mysql_version.h PATH_SUFFIXES mysql)
if(MYSQL_VERSION_H MATCHES "MYSQL_VERSION_H-NOTFOUND")
message(FATAL_ERROR "Cannot find the mysql_version.h header")
else()
message(STATUS "Found mysql_version.h: ${MYSQL_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.+\"(.+)\".*" "\\1" MYSQL_PROVIDER ${MYSQL_VERSION_CONTENTS})
string(TOLOWER ${MYSQL_PROVIDER} MYSQL_PROVIDER)
if(MYSQL_PROVIDER MATCHES "mariadb")
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")
else()
set(MYSQL_PROVIDER "Unknown" CACHE INTERNAL "The MySQL provider")
endif()
message(STATUS "MySQL version: ${MYSQL_VERSION}")
message(STATUS "MySQL provider: ${MYSQL_PROVIDER}")
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")
endif()

View File

@ -0,0 +1,33 @@
# This CMake file tries to find the the MySQL client library
# The following variables are set:
# MYSQLCLIENT_FOUND - System has MySQL client
# MYSQLCLIENT_STATIC_FOUND - System has statically linked MySQL client
# MYSQLCLIENT_LIBRARIES - The MySQL client library
# MYSQLCLIENT_STATIC_LIBRARIES - The static MySQL client library
# MYSQLCLIENT_HEADERS - The MySQL client headers
find_library(MYSQLCLIENT_LIBRARIES NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
if(${MYSQLCLIENT_LIBRARIES} MATCHES "NOTFOUND")
set(MYSQLCLIENT_FOUND FALSE CACHE INTERNAL "")
message(STATUS "Dynamic MySQL client library not found.")
unset(MYSQLCLIENT_LIBRARIES)
else()
set(MYSQLCLIENT_FOUND TRUE CACHE INTERNAL "")
message(STATUS "Found dynamic MySQL client library: ${MYSQLCLIENT_LIBRARIES}")
endif()
set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
find_library(MYSQLCLIENT_STATIC_LIBRARIES NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
if(${MYSQLCLIENT_STATIC_LIBRARIES} MATCHES "NOTFOUND")
set(MYSQLCLIENT_STATIC_FOUND FALSE CACHE INTERNAL "")
message(STATUS "Static MySQL client library not found.")
unset(MYSQLCLIENT_STATIC_LIBRARIES)
else()
set(MYSQLCLIENT_STATIC_FOUND TRUE CACHE INTERNAL "")
message(STATUS "Found statc MySQL client library: ${MYSQLCLIENT_STATIC_LIBRARIES}")
endif()
find_path(MYSQLCLIENT_HEADERS mysql.h PATH_SUFFIXES mysql mariadb)

23
cmake/FindRabbitMQ.cmake Normal file
View File

@ -0,0 +1,23 @@
# This CMake file tries to find the the RabbitMQ library
# The following variables are set:
# RABBITMQ_FOUND - System has RabbitMQ client
# RABBITMQ_LIBRARIES - The RabbitMQ client library
# RABBITMQ_HEADERS - The RabbitMQ client headers
include(CheckCSourceCompiles)
find_library(RABBITMQ_LIBRARIES NAMES rabbitmq)
find_path(RABBITMQ_HEADERS amqp.h PATH_SUFFIXES mysql mariadb)
if(${RABBITMQ_LIBRARIES} MATCHES "NOTFOUND")
set(RABBITMQ_FOUND FALSE CACHE INTERNAL "")
message(STATUS "RabbitMQ library not found.")
unset(RABBITMQ_LIBRARIES)
else()
set(RABBITMQ_FOUND TRUE CACHE INTERNAL "")
message(STATUS "Found RabbitMQ library: ${RABBITMQ_LIBRARIES}")
endif()
set(CMAKE_REQUIRED_INCLUDES ${RABBITMQ_HEADERS})
check_c_source_compiles("#include <amqp.h>\n int main(){if(AMQP_DELIVERY_PERSISTENT){return 0;}return 1;}" HAVE_RABBITMQ50)
if(NOT HAVE_RABBITMQ50)
message(FATAL_ERROR "Old version of RabbitMQ-C library found. Version 0.5 or newer is required.")
endif()

13
cmake/FindValgrind.cmake Normal file
View File

@ -0,0 +1,13 @@
# This CMake file tries to find the Valgrind executable
# The following variables are set:
# VALGRIND_FOUND - System has Valgrind
# VALGRIND_EXECUTABLE - The Valgrind executable file
find_program(VALGRIND_EXECUTABLE valgrind)
if(VALGRIND_EXECUTABLE STREQUAL "VALGRIND_EXECUTABLE-NOTFOUND")
message(STATUS "Valgrind not found.")
set(VALGRIND_FOUND FALSE CACHE INTERNAL "")
unset(VALGRIND_EXECUTABLE)
else()
message(STATUS "Valgrind found: ${VALGRIND_EXECUTABLE}")
set(VALGRIND_FOUND TRUE CACHE INTERNAL "")
endif()

View File

@ -0,0 +1,24 @@
# "make uninstall" helper
# see http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)