Added more build options and README changes

This commit is contained in:
Markus Makela 2014-09-15 11:48:40 +03:00
parent 4c41dea6fb
commit 48012cd571
9 changed files with 56 additions and 15 deletions

View File

@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 2.6)
include(macros.cmake)
enable_testing()
set(INSTALL_DIR "/usr/local/skysql/" CACHE PATH "MaxScale installation directory.")
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "Prefix prepended to install directories." FORCE)
set(BUILD_TYPE "Release" CACHE STRING "Build type, possible values are: Debug Release.")
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)
project(MaxScale)
set_maxscale_version()
@ -109,3 +113,11 @@ set(CPACK_RPM_PACKAGE_VENDOR "SkySQL Ab")
set(CPACK_RPM_PACKAGE_AUTOREQPROV " no")
include(CPack)
#add_test(PrepareTests ${CMAKE_COMMAND} -DBUILD_TESTS=Y -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DINSTALL_SYSTEM_FILES=N ${CMAKE_SOURCE_DIR})
#set_tests_properties(PrepareTests PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
#set_tests_properties(PrepareTests PROPERTIES COST 1000)
#add_test(BuildTests ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target install)
#set_tests_properties(BuildTests PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
#set_tests_properties(BuildTests PROPERTIES DEPENDS PrepareTests)
#set_tests_properties(BuildTests PROPERTIES COST 900)

27
README
View File

@ -157,32 +157,45 @@ Please check errmsg.sys is found in the MaxScale install_dir DEST/MaxScale/mysql
You can also build MaxScale with CMake which makes the build process a bit more simple.
All the same dependencies are required as with the normal MaxScale build with the addition of CMake
version 2.6 for regular builds and 2.8 or newer for package generation.
version 2.6 for regular builds and 2.8 or newer if you wish to generate packages.
CMake tries to find all the required directories and files on its own but if it can't find them or you wish to
explicitly state the locations you can pass additional options to CMake by using the -D flag. To confirm the variable
values, you can run CMake in interactive mode by using the -i flag or use the ccmake GUI.
values, you can run CMake in interactive mode by using the -i flag or use a CMake GUI (for example, ccmake for command line).
For example, to build MaxScale using CMake with a custom install location:
It is highly recommended to make a separate build directory to build into. This keeps the source and build trees clean and
makes it easy to get rid of everything you built.
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/skysql <path to MaxScale source>
By default, MaxScale installs to /usr/local/skysql and places init.d scripts and ldconfig files into their folders. Change the INSTALL_DIR
variable to your desired installation directory and set INSTALL_SYSTEM_FILES=N to prevent the init.d script and ldconfig file installation.
To build and install MaxScale using CMake with a custom install location and a separate build directory:
cmake -D_INSTALL_DIR=<install destination> <path to MaxScale source>
make
make install
This generates the required makefiles in the current directory, compiles and links all the programs and installs
all the required files in their right places.
To build MaxScale using the ccmake GUI:
ccmake <path to MaxScale source>
All the parameters affecting CMake can be found in 'macros.cmake'. This file also has the parameters CMake uses for testing.
Variables controlling the CMake build process:
CMAKE_INSTALL_PREFIX=<path> Install destination prefix, same as DEST
CMAKE_BUILD_TYPE=[Debug|Release] Type of the build
INSTALL_DIR=<path> Installation directory
CMAKE_BUILD_TYPE=[Debug|Release] Type of the build, defaults to Release
INSTALL_SYSTEM_FILES=[Y|N] Install startup scripts and ld configuration files
EMBEDDED_LIB=<path> Path to the embedded library, filename included
MYSQL_DIR=<path> Path to MySQL headers
STATIC_EMBEDDED=[Y|N] Link the static or the dynamic verson of the library
GCOV=[Y|N] Generate gcov output
BUILD_TESTS=[Y|N] Build tests
\section Running Running MaxScale

View File

@ -2,5 +2,6 @@ cmake_minimum_required(VERSION 2.6)
add_library(log_manager SHARED log_manager.cc)
target_link_libraries(log_manager utils)
install(TARGETS log_manager DESTINATION lib)
add_subdirectory(test)
if(BUILD_TESTS)
add_subdirectory(test)
endif()

View File

@ -43,4 +43,8 @@ macro(set_variables)
# Install init.d scripts and ldconf configuration files
set(INSTALL_SYSTEM_FILES TRUE CACHE BOOL "Install init.d scripts and ldconf configuration files")
endmacro()
# Build tests
set(BUILD_TESTS TRUE CACHE BOOL "Build tests")
endmacro()

View File

@ -1,4 +1,6 @@
set(QUERY_CLASSIFIER_HEADERS query_classifier.h)
add_library(query_classifier SHARED query_classifier.cc ${MYSQL_HEADERS})
install(TARGETS query_classifier DESTINATION lib)
add_subdirectory(test)
if(BUILD_TESTS)
add_subdirectory(test)
endif()

View File

@ -1,4 +1,6 @@
add_subdirectory(core)
add_subdirectory(modules)
add_subdirectory(inih)
add_subdirectory(test)
if(BUILD_TESTS)
add_subdirectory(test)
endif()

View File

@ -20,4 +20,6 @@ set_target_properties(maxpasswd PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:
target_link_libraries(maxpasswd utils log_manager ssl aio pthread crypt dl ${EMBEDDED_LIB} crypto inih z rt m)
install(TARGETS maxpasswd DESTINATION bin)
add_subdirectory(test)
if(BUILD_TESTS)
add_subdirectory(test)
endif()

View File

@ -2,4 +2,6 @@ add_library(readwritesplit SHARED readwritesplit.c)
set_target_properties(readwritesplit PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib)
target_link_libraries(readwritesplit utils ssl pthread log_manager query_classifier mysqld)
install(TARGETS readwritesplit DESTINATION modules)
add_subdirectory(test)
if(BUILD_TESTS)
add_subdirectory(test)
endif()

View File

@ -1,5 +1,8 @@
file(COPY MaxScale_test.cnf DESTINATION ${CMAKE_BINARY_DIR}/etc)
file(RENAME ${CMAKE_BINARY_DIR}/etc/MaxScale_test.cnf ${CMAKE_BINARY_DIR}/etc/MaxScale.cnf)
add_test(NAME RunExecutable COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/startmaxscale.sh "$<TARGET_FILE_DIR:maxscale>" "-c ${CMAKE_BINARY_DIR}")
set_tests_properties(RunExecutable PROPERTIES TIMEOUT 10)
set_tests_properties(RunExecutable PROPERTIES TIMEOUT 5)
set_tests_properties(RunExecutable PROPERTIES WILL_FAIL TRUE)
add_test(NAME KillExecutable COMMAND killall -KILL maxscale)
set_tests_properties(KillExecutable PROPERTIES COST 0.00001)