From 48012cd5710a6cd642a378fb2b4f5b43ae638f76 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 15 Sep 2014 11:48:40 +0300 Subject: [PATCH] Added more build options and README changes --- CMakeLists.txt | 12 +++++++++ README | 27 ++++++++++++++----- log_manager/CMakeLists.txt | 5 ++-- macros.cmake | 6 ++++- query_classifier/CMakeLists.txt | 4 ++- server/CMakeLists.txt | 4 ++- server/core/CMakeLists.txt | 4 ++- .../routing/readwritesplit/CMakeLists.txt | 4 ++- server/test/CMakeLists.txt | 5 +++- 9 files changed, 56 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43caf1cea..a8d655a41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/README b/README index aba2ceb4c..83ddc2c2f 100644 --- a/README +++ b/README @@ -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 +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= 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 + +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= Install destination prefix, same as DEST -CMAKE_BUILD_TYPE=[Debug|Release] Type of the build +INSTALL_DIR= 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 to the embedded library, filename included MYSQL_DIR= 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 diff --git a/log_manager/CMakeLists.txt b/log_manager/CMakeLists.txt index c451500b5..b0b17bd24 100644 --- a/log_manager/CMakeLists.txt +++ b/log_manager/CMakeLists.txt @@ -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) \ No newline at end of file +if(BUILD_TESTS) +add_subdirectory(test) +endif() \ No newline at end of file diff --git a/macros.cmake b/macros.cmake index 2311d00c1..a8c887641 100644 --- a/macros.cmake +++ b/macros.cmake @@ -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() \ No newline at end of file + # Build tests + set(BUILD_TESTS TRUE CACHE BOOL "Build tests") + + +endmacro() diff --git a/query_classifier/CMakeLists.txt b/query_classifier/CMakeLists.txt index 87c67ef62..ee0912ae9 100644 --- a/query_classifier/CMakeLists.txt +++ b/query_classifier/CMakeLists.txt @@ -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) \ No newline at end of file +if(BUILD_TESTS) +add_subdirectory(test) +endif() \ No newline at end of file diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 883541d53..a42c625ae 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -1,4 +1,6 @@ add_subdirectory(core) add_subdirectory(modules) add_subdirectory(inih) -add_subdirectory(test) \ No newline at end of file +if(BUILD_TESTS) +add_subdirectory(test) +endif() \ No newline at end of file diff --git a/server/core/CMakeLists.txt b/server/core/CMakeLists.txt index 91dd5878b..12a30f8b5 100644 --- a/server/core/CMakeLists.txt +++ b/server/core/CMakeLists.txt @@ -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) \ No newline at end of file +if(BUILD_TESTS) +add_subdirectory(test) +endif() \ No newline at end of file diff --git a/server/modules/routing/readwritesplit/CMakeLists.txt b/server/modules/routing/readwritesplit/CMakeLists.txt index 1deb361d3..141dcbe94 100644 --- a/server/modules/routing/readwritesplit/CMakeLists.txt +++ b/server/modules/routing/readwritesplit/CMakeLists.txt @@ -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) \ No newline at end of file +if(BUILD_TESTS) +add_subdirectory(test) +endif() \ No newline at end of file diff --git a/server/test/CMakeLists.txt b/server/test/CMakeLists.txt index bf3c339bd..27a8c5efd 100644 --- a/server/test/CMakeLists.txt +++ b/server/test/CMakeLists.txt @@ -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 "$" "-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)