2013-06-30 02:34:10 +08:00
|
|
|
# CMake 2.8.9 is required in order to use the new Qt 5 functions.
|
|
|
|
|
cmake_minimum_required(VERSION 2.8.9)
|
|
|
|
|
|
|
|
|
|
project(qredis)
|
|
|
|
|
|
2013-07-02 02:25:12 +08:00
|
|
|
# These options can be used to control the build process.
|
|
|
|
|
option(BUILD_TESTS "Build the QRedis test suite" ON)
|
|
|
|
|
|
2013-06-30 02:34:10 +08:00
|
|
|
# These definitions are used to set the target properties later on.
|
|
|
|
|
set(QREDIS_MAJOR 0)
|
|
|
|
|
set(QREDIS_MINOR 1)
|
|
|
|
|
set(QREDIS_PATCH 0)
|
|
|
|
|
set(QREDIS_VERSION "${QREDIS_MAJOR}.${QREDIS_MINOR}.${QREDIS_PATCH}")
|
|
|
|
|
|
2013-06-30 03:39:34 +08:00
|
|
|
# C++11 support must be enabled in GCC.
|
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
|
# Ensure that we are using at least GCC 4.6+.
|
|
|
|
|
if(${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.6)
|
|
|
|
|
message(FATAL_ERROR "GCC 4.6+ is required (" ${CMAKE_CXX_COMPILER_VERSION} " detected).")
|
|
|
|
|
endif()
|
|
|
|
|
# Enable C++11 features.
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
|
|
|
|
endif()
|
|
|
|
|
|
2013-06-30 02:34:10 +08:00
|
|
|
# The QtCore and QtNetwork libraries are both required.
|
|
|
|
|
find_package(Qt5Core REQUIRED)
|
|
|
|
|
find_package(Qt5Network REQUIRED)
|
|
|
|
|
|
|
|
|
|
# Specify where QRedis includes are located.
|
|
|
|
|
include_directories(include)
|
|
|
|
|
|
|
|
|
|
# QRedis source files.
|
|
|
|
|
set(QREDIS_SRC
|
2013-06-30 14:16:59 +08:00
|
|
|
src/client.cpp
|
2013-07-02 00:00:58 +08:00
|
|
|
src/request.cpp)
|
2013-06-30 02:34:10 +08:00
|
|
|
|
|
|
|
|
# QRedis header files requiring MOC.
|
|
|
|
|
qt5_wrap_cpp(QREDIS_MOC
|
2013-07-02 00:00:58 +08:00
|
|
|
include/qredis/client.h
|
2013-07-02 01:26:38 +08:00
|
|
|
include/qredis/request.h
|
|
|
|
|
src/client_p.h)
|
2013-06-30 02:34:10 +08:00
|
|
|
|
|
|
|
|
# Create the client library.
|
|
|
|
|
add_library(qredis SHARED
|
|
|
|
|
${QREDIS_SRC}
|
|
|
|
|
${QREDIS_MOC})
|
|
|
|
|
|
|
|
|
|
# Set the client library's properties.
|
|
|
|
|
set_target_properties(qredis PROPERTIES
|
|
|
|
|
VERSION ${QREDIS_VERSION}
|
|
|
|
|
SOVERSION ${QREDIS_MAJOR})
|
|
|
|
|
|
|
|
|
|
# This causes the appropriate libraries to be included in the link process.
|
2013-07-02 02:25:12 +08:00
|
|
|
qt5_use_modules(qredis Core Network)
|
2013-06-30 02:34:10 +08:00
|
|
|
|
|
|
|
|
# Specify the proper installation paths.
|
|
|
|
|
install(TARGETS qredis
|
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
|
PUBLIC_HEADER DESTINATION include/qredis)
|
2013-07-02 02:25:12 +08:00
|
|
|
|
|
|
|
|
# If the tests are to be built, then add them to the project.
|
|
|
|
|
if(BUILD_TESTS)
|
|
|
|
|
enable_testing()
|
|
|
|
|
add_subdirectory(tests)
|
|
|
|
|
endif()
|