From: Michael Wallner Date: Wed, 5 Feb 2020 17:47:17 +0000 (+0100) Subject: cmake X-Git-Tag: post_cmake~23 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=cbec7a4b9613b8ae3807539fae3a29ed8aff4984;p=awesomized%2Flibmemcached cmake --- diff --git a/.gitignore b/.gitignore index 1786a72d..7b63c298 100644 --- a/.gitignore +++ b/.gitignore @@ -52,7 +52,7 @@ clients/memrm clients/memslap clients/memstat clients/memtouch -cmake-build-debug/ +cmake-build-*/ config.cache config.log config.status @@ -120,10 +120,6 @@ man/.doctrees/ mem_config.h mem_config.h.in mem_config.in -memcached/.git -memcached/.gitignore -memcached/memcached -memcached/memcached.spec out patch patch2 diff --git a/CMake/CheckDebug.cmake b/CMake/CheckDebug.cmake new file mode 100644 index 00000000..749e188b --- /dev/null +++ b/CMake/CheckDebug.cmake @@ -0,0 +1,64 @@ +include(CMakePushCheckState) +include(CheckCXXCompilerFlag) + +function(check_debug) + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + add_compile_options(-O1) + add_compile_definitions(DEBUG=1) + foreach(FLAG IN ITEMS + -fno-inline + -fno-omit-frame-pointer + -fno-eliminate-unused-debug-types + -funsafe-loop-optimizations + + -g3 + + -Wall + -Wextra + + -Wdouble-promotion + -Wduplicated-cond + -Wduplicated-branches + -Wformat=2 + -Wlogical-op + -Wnull-dereference + -Wrestrict + -Wshadow + -Wunknown-pragmas + -Wunsafe-loop-optimizations + ) + unset(FLAG_CONSTANT) + string(MAKE_C_IDENTIFIER CXX${FLAG} FLAG_CONSTANT) + check_cxx_compiler_flag(${FLAG} ${FLAG_CONSTANT}) + if(${FLAG_CONSTANT}) + add_compile_options(${FLAG}) + endif() + endforeach() + + if(ENABLE_SANITIZERS) + if(address IN_LIST ENABLE_SANITIZERS OR asan IN_LIST ENABLE_SANITIZERS) + cmake_push_check_state(RESET) + set(CMAKE_REQUIRED_LIBRARIES asan) + check_cxx_compiler_flag(-fsanitize=address HAVE_ASAN) + cmake_pop_check_state() + if(HAVE_ASAN) + add_compile_options(-fsanitize=address) + add_link_options(-lasan) + endif() + endif() + + if(undefined IN_LIST ENABLE_SANITIZERS OR ubsan IN_LIST ENABLE_SANITIZERS) + cmake_push_check_state(RESET) + set(CMAKE_REQUIRED_LIBRARIES ubsan) + check_cxx_compiler_flag(-fsanitize=undefined HAVE_UBSAN) + cmake_pop_check_state() + if(HAVE_UBSAN) + add_compile_options(-fsanitize=undefined) + add_link_options(-lubsan) + endif() + endif() + endif() + else() + add_compile_definitions(DEBUG=0) + endif() +endfunction() diff --git a/CMake/CheckDecl.cmake b/CMake/CheckDecl.cmake new file mode 100644 index 00000000..dac8065b --- /dev/null +++ b/CMake/CheckDecl.cmake @@ -0,0 +1,7 @@ +include(CheckCXXSymbolExists) + +# check for symbol and set HAVE_SYMBOL +function(check_decl DECL HEADER) + safe_string(${DECL} DECL_CONST) + check_cxx_symbol_exists(${DECL} ${HEADER} HAVE_${DECL_CONST}) +endfunction(check_decl) diff --git a/CMake/CheckDependency.cmake b/CMake/CheckDependency.cmake new file mode 100644 index 00000000..e1bdd5b9 --- /dev/null +++ b/CMake/CheckDependency.cmake @@ -0,0 +1,42 @@ +find_package(PkgConfig) + +include(SafeString) +include(CheckHeader) + +function(check_dependency NAME LIB HEADER) + if(PKG_CONFIG_FOUND) + pkg_check_modules(${NAME} lib${LIB}${ARGN}) + if(NOT ${NAME}_FOUND) + pkg_check_modules(${NAME} ${LIB}${ARGN}) + endif() + set(${NAME} ${${NAME}_FOUND} PARENT_SCOPE) + set(${NAME}_LIBRARIES ${${NAME}_LIBRARIES} PARENT_SCOPE) + set(${NAME}_INCLUDEDIR ${${NAME}_INCLUDEDIR}} PARENT_SCOPE) + + safe_string(${LIB} LIB_CONST) + set(HAVE_${NAME} ${${NAME}_FOUND} PARENT_SCOPE) + safe_string(${HEADER} HEADER_CONST) + find_path(HAVE_${HEADER_CONST} ${HEADER} PATHS ${${NAME}_INCLUDEDIR}) + else() + set(FOUND 1) + find_library(LIB${LIB} NAMES ${LIB}) + if(NOT LIB${LIB}) + set(FOUND 0) + endif() + if(HEADER) + safe_string(${HEADER} HEADER_CONST) + check_header(${HEADER}) + if(NOT HAVE_${HEADER_CONST}) + set(FOUND 0) + else() + find_path(${HEADER_CONST}_ROOT ${HEADER}) + if(NOT ${HEADER_CONST}_ROOT) + set(FOUND 0) + endif() + endif() + endif() + set(${NAME} ${FOUND} PARENT_SCOPE) + set(${NAME}_LIBRARIES ${LIB${LIB}} PARENT_SCOPE) + set(${NAME}_INCLUDEDIR ${${HEADER_CONST}_ROOT} PARENT_SCOPE) + endif() +endfunction() diff --git a/CMake/CheckHeader.cmake b/CMake/CheckHeader.cmake new file mode 100644 index 00000000..cc36ceff --- /dev/null +++ b/CMake/CheckHeader.cmake @@ -0,0 +1,10 @@ +include(CheckIncludeFileCXX) + +include(SafeString) + +# check for header.h and set HAVE_HEADER_H +function(check_header HEADER_PATH) + safe_string(${HEADER_PATH} HEADER_CONST) + check_include_file_cxx(${HEADER_PATH} HAVE_${HEADER_CONST}) +endfunction(check_header) + diff --git a/CMake/CheckStdatomic.cmake b/CMake/CheckStdatomic.cmake new file mode 100644 index 00000000..cd9953bf --- /dev/null +++ b/CMake/CheckStdatomic.cmake @@ -0,0 +1,21 @@ +include(CheckCSourceRuns) +include(CheckCXXSourceRuns) + +# check for C11 stdatomic and C++11 std::atomic, set HAVE_C_STDATOMIC and/or HAVE_CXX_STDATOMIC +function(check_stdatomic) + check_cxx_source_runs( + "#include + int main() { + std::atomic i(0); + return atomic_fetch_add(&i,1); + }" + HAVE_CXX_STDATOMIC) + check_c_source_runs( + "#include + int main() { + atomic_int i; + atomic_init(&i, 0); + return atomic_fetch_add(&i,1); + }" + HAVE_C_STDATOMIC) +endfunction( ) diff --git a/CMake/CheckType.cmake b/CMake/CheckType.cmake new file mode 100644 index 00000000..56d4bea3 --- /dev/null +++ b/CMake/CheckType.cmake @@ -0,0 +1,11 @@ +include(CheckTypeSize) + +include(SafeString) + +# check for type (possibly in header.h) and set HAVE_TYPE +function(check_type TYPE HEADER) + safe_string(${TYPE} TYPE_CONST) + SET(CMAKE_EXTRA_INCLUDE_FILES ${HEADER}) + check_type_size(${TYPE} ${TYPE_CONST} LANGUAGE CXX) + SET(CMAKE_EXTRA_INCLUDE_FILES) +endfunction(check_type) diff --git a/CMake/SafeString.cmake b/CMake/SafeString.cmake new file mode 100644 index 00000000..8b84622c --- /dev/null +++ b/CMake/SafeString.cmake @@ -0,0 +1,8 @@ + +# replace any non-alnum characters with underscore and uppercase the result +function(safe_string STRING OUTPUT) + string(REGEX REPLACE "[^0-9a-zA-Z_]" "_" HEADER_SAFE ${STRING}) + string(TOUPPER "${HEADER_SAFE}" HEADER_DEFN) + set(${OUTPUT} ${HEADER_DEFN} PARENT_SCOPE) +endfunction(safe_string) + diff --git a/CMake/_Include.cmake b/CMake/_Include.cmake new file mode 100644 index 00000000..9e73358a --- /dev/null +++ b/CMake/_Include.cmake @@ -0,0 +1,102 @@ +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake) + +set(THREADS_PREFER_PTHREAD_FLAG ON) + +# globals +include(CTest) +include(GNUInstallDirs) + +find_package(PkgConfig) +find_package(Threads REQUIRED) + +# locals +include(SafeString) +include(CheckDebug) +include(CheckDecl) +include(CheckDependency) +include(CheckHeader) +include(CheckType) +include(CheckStdatomic) + +# configuration + +## debug +check_debug() + +## memaslap +if(ENABLE_MEMASLAP) + check_stdatomic() + check_dependency(LIBEVENT event event.h) + check_decl(getline stdio.h) +endif() + +## dtrace +if(ENABLE_DTRACE) + set(HAVE_DTRACE 1) +endif() + +##uuid +if(BUILD_TESTING) + check_dependency(LIBUUID uuid uuid/uuid.h) +endif() + +## sasl +if(ENABLE_SASL) + check_dependency(LIBSASL sasl2 sasl/sasl.h) + if(LIBSASL) + set(LIBMEMCACHED_WITH_SASL_SUPPORT 1) + endif() +endif() + +## hashes +if(ENABLE_FNV64_HASH) + set(HAVE_FNV64_HASH 1) +endif() +if(ENABLE_MURMUR_HASH) + set(HAVE_MURMUR_HASH 1) +endif() +if(ENABLE_HSIEH_HASH) + set(HAVE_HSIEH_HASH 1) +endif() + +# system checks + +check_header(arpa/inet.h) +check_header(dlfcn.h) +check_header(errno.h) +check_header(execinfo.h) +check_header(fcntl.h) +check_header(io.h) +check_header(limits.h) +check_header(netdb.h) +check_header(poll.h) +check_header(stddef.h) +check_header(stdlib.h) +check_header(strings.h) +check_header(sys/socket.h) +check_header(sys/time.h) +check_header(sys/types.h) +check_header(sys/un.h) +check_header(sys/wait.h) +check_header(time.h) +check_header(umem.h) +check_header(unistd.h) +check_header(winsock2.h) +check_header(ws2tcpip.h) + +check_decl(fcntl fcntl.h) +check_decl(htonll arpa/inet.h) +check_decl(MSG_DONTWAIT sys/socket.h) +check_decl(MSG_MORE sys/socket.h) +check_decl(MSG_NOSIGNAL sys/socket.h) +check_decl(rcvtimeo sys/socket.h) +check_decl(sndtimeo sys/socket.h) +check_decl(strerror_r string.h) +check_decl(strerror string.h) +check_decl(abi::__cxa_demangle cxxabi.h) +set(HAVE_GCC_ABI_DEMANGLE ${HAVE_ABI____CXA_DEMANGLE}) + +check_type(in_port_t netinet/in.h) + +check_header(cstdint) +check_header(cinttypes) diff --git a/CMakeConfig.txt b/CMakeConfig.txt new file mode 100644 index 00000000..1ea464f0 --- /dev/null +++ b/CMakeConfig.txt @@ -0,0 +1,59 @@ +set(CMAKE_BUILD_TYPE Release + CACHE STRING "build type (Release, Debug, ...)") +set(CMAKE_INSTALL_PREFIX /usr/local + CACHE PATH "install prefix") + +# make test + +set(BUILD_TESTING ON + CACHE STRING "whether to enable build of the test suite") + +set(ENABLE_SANITIZERS "" + CACHE STRING "sanitizers to enable (e.g. address undefined ...)") + +# sasl + +set(ENABLE_SASL OFF + CACHE BOOL "enable SASL support") + +# hashes + +set(ENABLE_FNV64_HASH ON + CACHE BOOL "enable fnv64 hash support") +set(ENABLE_MURMUR_HASH ON + CACHE BOOL "enable murmur hash support") +set(ENABLE_HSIEH_HASH OFF + CACHE BOOL "enable hsieh hash support") + +# memaslap, needs libevent and stdatomic +set(ENABLE_MEMASLAP ON + CACHE BOOL "enable memaslap client") + +# dtrace + +set(ENABLE_DTRACE OFF + CACHE BOOL "enable dtrace support") + +# sphinx + +set(SPHINX_OPTIONS "" + CACHE STRING "additional sphinx-build command line options") +set(SPHINX_THEME "sphinx_rtd_theme" + CACHE STRING "sphinx HTML theme") +set(SPHINX_THEME_OPTIONS "'collapse_navigation':False, 'navigation_depth':2, 'titles_only':False, 'includehidden':False" + CACHE STRING "sphinx HTML theme options") +set(SPHINX_EXTENSIONS "" + CACHE STRING "comma separated list of quoted sphinx extensions") +set(SPHINX_CONF_APPEND "" + CACHE STRING "append verbatim code to sphinx' conf.py") + +# legacy + +set(HAVE_VISIBILITY 1) +set(HAVE_SHARED_ENABLED 1) +set(HAVE_GCC_BUILTIN_ATOMIC 1) + +# modules + + +include(CMake/_Include.cmake) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4993d05d..1f12aaca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,8 +4,10 @@ if(${CMAKE_VERSION} VERSION_LESS 3.12) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) endif() +include(CMakeVersions.txt) + project(libmemcached - VERSION 1.99 + VERSION "${LIBMEMCACHED_VERSION}" DESCRIPTION "libmemcached https://github.com/m6w6/libmemcached" ) @@ -13,56 +15,7 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) -include(Config.cmake) -include(Include.cmake) - -find_package(Threads REQUIRED) -set(THREADS_PREFER_PTHREAD_FLAG ON) - -find_library(HAVE_LIBSASL NAMES sasl sasl2) -check_header(sasl/sasl.h) - -check_header(arpa/inet.h) -check_header(dlfcn.h) -check_header(errno.h) -check_header(execinfo.h) -check_header(fcntl.h) -check_header(io.h) -check_header(limits.h) -check_header(netdb.h) -check_header(poll.h) -check_header(stddef.h) -check_header(stdlib.h) -check_header(strings.h) -check_header(sys/socket.h) -check_header(sys/time.h) -check_header(sys/types.h) -check_header(sys/un.h) -check_header(sys/wait.h) -check_header(time.h) -check_header(umem.h) -check_header(unistd.h) -check_header(winsock2.h) -check_header(ws2tcpip.h) - -check_decl(fcntl fcntl.h) -check_decl(htonll arpa/inet.h) -check_decl(MSG_DONTWAIT sys/socket.h) -check_decl(MSG_MORE sys/socket.h) -check_decl(MSG_NOSIGNAL sys/socket.h) -check_decl(rcvtimeo sys/socket.h) -check_decl(sndtimeo sys/socket.h) -check_decl(strerror_r string.h) -check_decl(strerror string.h) -check_decl(abi::__cxa_demangle cxxabi.h) -set(HAVE_GCC_ABI_DEMANGLE ${HAVE_ABI____CXA_DEMANGLE}) - -check_type(in_port_t netinet/in.h) - -check_header(cstdint) -check_header(cinttypes) - -check_debug() +include(CMakeConfig.txt) include_directories(${CMAKE_BINARY_DIR}) set(AUTOHEADER_FILE mem_config.h) @@ -89,14 +42,15 @@ add_subdirectory(libhashkit-1.0) add_subdirectory(libmemcached) add_subdirectory(libmemcached-1.0) add_subdirectory(libmemcachedutil) +add_subdirectory(libmemcachedutil-1.0) - -include(CTest) -enable_testing() -add_subdirectory(libtest) -add_subdirectory(tests) +if(BUILD_TESTING) + add_subdirectory(libtest) + add_subdirectory(tests) +endif() add_subdirectory(docs) +add_subdirectory(support) # keep last configure_file(mem_config.h.in ${CMAKE_BINARY_DIR}/${AUTOHEADER_FILE} @ONLY) diff --git a/CMakeVersions.txt b/CMakeVersions.txt new file mode 100644 index 00000000..683f43e7 --- /dev/null +++ b/CMakeVersions.txt @@ -0,0 +1,44 @@ + +set(LIBMEMCACHED_VERSION_MAJOR 1) +set(LIBMEMCACHED_VERSION_MINOR 0) +set(LIBMEMCACHED_VERSION_PATCH 99) + +set(LIBMEMCACHED_VERSION ${LIBMEMCACHED_VERSION_MAJOR}.${LIBMEMCACHED_VERSION_MINOR}.${LIBMEMCACHED_VERSION_PATCH}) + +set(LIBMEMCACHED_VERSION_HEX) +math(EXPR LIBMEMCACHED_VERSION_HEX "(${LIBMEMCACHED_VERSION_MAJOR}<<16) + (${LIBMEMCACHED_VERSION_MINOR}<<8) + ${LIBMEMCACHED_VERSION_PATCH}+0" + OUTPUT_FORMAT HEXADECIMAL) + +set(LIBMEMCACHED_SO_VERSION_CUR 12) +set(LIBMEMCACHED_SO_VERSION_REV 0) +set(LIBMEMCACHED_SO_VERSION_AGE 0) + +set(LIBMEMCACHED_SO_VERSION ${LIBMEMCACHED_SO_VERSION_CUR}.${LIBMEMCACHED_SO_VERSION_REV}.${LIBMEMCACHED_SO_VERSION_AGE}) + +set(LIBMEMCACHEDUTIL_SO_VERSION_CUR 2) +set(LIBMEMCACHEDUTIL_SO_VERSION_REV 0) +set(LIBMEMCACHEDUTIL_SO_VERSION_AGE 0) + +set(LIBMEMCACHEDUTIL_SO_VERSION ${LIBMEMCACHEDUTIL_SO_VERSION_CUR}.${LIBMEMCACHEDUTIL_SO_VERSION_REV}.${LIBMEMCACHEDUTIL_SO_VERSION_AGE}) + +set(LIBMEMCACHEDPROTOCOL_SO_VERSION_CUR 0) +set(LIBMEMCACHEDPROTOCOL_SO_VERSION_REV 0) +set(LIBMEMCACHEDPROTOCOL_SO_VERSION_AGE 0) + +set(LIBMEMCACHEDPROTOCOL_SO_VERSION ${LIBMEMCACHEDPROTOCOL_SO_VERSION_CUR}.${LIBMEMCACHEDPROTOCOL_SO_VERSION_REV}.${LIBMEMCACHEDPROTOCOL_SO_VERSION_AGE}) + +set(LIBHASHKIT_VERSION_MAJOR 1) +set(LIBHASHKIT_VERSION_MINOR 0) +set(LIBHASHKIT_VERSION_PATCH 0) + +set(LIBHASHKIT_VERSION ${LIBHASHKIT_VERSION_MAJOR}.${LIBHASHKIT_VERSION_MINOR}.${LIBHASHKIT_VERSION_PATCH}) + +set(LIBHASHKIT_VERSION_HEX) +math(EXPR LIBHASHKIT_VERSION_HEX "(${LIBHASHKIT_VERSION_MAJOR}<<16) + (${LIBHASHKIT_VERSION_MINOR}<<8) + ${LIBHASHKIT_VERSION_PATCH}+0" + OUTPUT_FORMAT HEXADECIMAL) + +set(LIBHASHKIT_SO_VERSION_CUR 2) +set(LIBHASHKIT_SO_VERSION_REV 0) +set(LIBHASHKIT_SO_VERSION_AGE 0) + +set(LIBHASHKIT_SO_VERSION ${LIBHASHKIT_SO_VERSION_CUR}.${LIBHASHKIT_SO_VERSION_REV}.${LIBHASHKIT_SO_VERSION_AGE}) diff --git a/Config.cmake b/Config.cmake deleted file mode 100644 index 502201ea..00000000 --- a/Config.cmake +++ /dev/null @@ -1,20 +0,0 @@ -#set(CMAKE_INSTALL_PREFIX /usr) - -set(LIBMEMCACHED_WITH_SASL_SUPPORT 0) - -set(HAVE_FNV64_HASH 1) -set(HAVE_MURMUR_HASH 1) -set(HAVE_HSIEH_HASH 0) - -#set(SPHINX_OPTIONS) -#set(SPHINX_THEME) -#set(SPHINX_THEME_DIR) -#set(SPHINX_THEME_OPTIONS) -#set(SPHINX_CONF_APPEND) -#set(SPHINX_EXTENSIONS "''") -#set(SPHINX_CONF_APPEND) - -set(HAVE_DTRACE 0) -set(HAVE_VISIBILITY 1) -set(HAVE_GCC_BUILTIN_ATOMIC 1) -set(HAVE_SHARED_ENABLED 1) diff --git a/Include.cmake b/Include.cmake deleted file mode 100644 index 919fc630..00000000 --- a/Include.cmake +++ /dev/null @@ -1,68 +0,0 @@ - -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake) - -function(set_test_target TARGET2) - foreach(TEST IN LISTS TESTS) - add_custom_command(TARGET ${TARGET2} POST_BUILD COMMAND ${TEST}) - endforeach() -endfunction() - -include(CheckTypeSize) -include(CheckCSourceRuns) -include(CheckIncludeFileCXX) -include(CheckCXXSymbolExists) -include(CheckCXXCompilerFlag) -include(CheckCXXSourceRuns) - -function(safe_string STRING OUTPUT) - string(REGEX REPLACE "[^0-9a-zA-Z_]" "_" HEADER_SAFE ${STRING}) - string(TOUPPER "${HEADER_SAFE}" HEADER_DEFN) - set(${OUTPUT} ${HEADER_DEFN} PARENT_SCOPE) -endfunction(safe_string) - -function(define_cpp DEF) - safe_string(${DEF} CNST) - add_compile_definitions(HAVE_${CNST}=1) -endfunction(define_cpp) - -function(check_header HEADER_PATH) - safe_string(${HEADER_PATH} HEADER_CONST) - check_include_file_cxx(${HEADER_PATH} HAVE_${HEADER_CONST}) -endfunction(check_header) - -function(check_decl DECL HEADER) - safe_string(${DECL} DECL_CONST) - check_cxx_symbol_exists(${DECL} ${HEADER} HAVE_${DECL_CONST}) -endfunction(check_decl) - -function(check_type TYPE HEADER) - safe_string(${TYPE} TYPE_CONST) - SET(CMAKE_EXTRA_INCLUDE_FILES ${HEADER}) - check_type_size(${TYPE} ${TYPE_CONST} LANGUAGE CXX) - SET(CMAKE_EXTRA_INCLUDE_FILES) -endfunction(check_type) - -function(check_debug) - if(${CMAKE_BUILD_TYPE} STREQUAL Debug) - add_compile_definitions(DEBUG=1) - add_compile_options(-Wall -Wextra) - endif() -endfunction(check_debug) - -function(check_stdatomic) - check_cxx_source_runs( - "#include - int main() { - std::atomic i(0); - return atomic_fetch_add(&i,1); - }" - HAVE_CXX_STDATOMIC) - check_c_source_runs( - "#include - int main() { - atomic_int i; - atomic_init(&i, 0); - return atomic_fetch_add(&i,1); - }" - HAVE_C_STDATOMIC) -endfunction(check_atomic_builtins) diff --git a/clients/CMakeLists.txt b/clients/CMakeLists.txt index 9f753f20..25815a54 100644 --- a/clients/CMakeLists.txt +++ b/clients/CMakeLists.txt @@ -8,6 +8,7 @@ foreach(CLIENT IN LISTS CLIENTS) add_executable(${CLIENT} ${CLIENT}.cc) target_include_directories(${CLIENT} PRIVATE ..) target_link_libraries(${CLIENT} libclient_utilities) + install(TARGETS ${CLIENT}) endforeach() # extra sources @@ -22,13 +23,12 @@ target_link_libraries(memslap Threads::Threads) # memaslap is special -find_library(LIBEVENT event) -check_stdatomic() - -if(LIBEVENT AND HAVE_C_STDATOMIC) - check_decl(getline stdio.h) - add_executable(memaslap memaslap.c - ms_conn.c ms_setting.c ms_sigsegv.c ms_stats.c ms_task.c ms_thread.c) - target_include_directories(memaslap PRIVATE ..) - target_link_libraries(memaslap libclient_utilities ${LIBEVENT} Threads::Threads) +if(ENABLE_MEMASLAP) + if(LIBEVENT AND HAVE_C_STDATOMIC) + add_executable(memaslap memaslap.c + ms_conn.c ms_setting.c ms_sigsegv.c ms_stats.c ms_task.c ms_thread.c) + target_include_directories(memaslap PRIVATE .. ${LIBEVENT_INCLUDEDIR}) + target_link_libraries(memaslap libclient_utilities ${LIBEVENT_LIBRARIES} Threads::Threads) + install(TARGETS memaslap) + endif() endif() diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index ace24785..269fae04 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,20 +1,20 @@ find_package(Sphinx) -if(SPHINX_EXECUTABLE) +if(NOT SPHINX_EXECUTABLE) - if(NOT DEFINED SPHINX_THEME) - set(SPHINX_THEME sphinx_rtd_theme) - set(SPHINX_THEME_OPTIONS "'collapse_navigation':False, 'navigation_depth':2, 'titles_only':False, 'includehidden':False") - endif() + message(WARNING "The sphinx-build command is required to build manpages.") - if(NOT DEFINED SPHINX_THEME_DIR) - set(SPHINX_THEME_DIR) - endif() +else() if(NOT DEFINED SPHINX_OPTIONS) set(SPHINX_OPTIONS) endif() + if(NOT DEFINED SPHINX_THEME) + set(SPHINX_THEME sphinx_rtd_theme) + set(SPHINX_THEME_OPTIONS "'collapse_navigation':False, 'navigation_depth':2, 'titles_only':False, 'includehidden':False") + endif() + set(SPHINX_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/source") # configured documentation tools and intermediate build results @@ -36,22 +36,31 @@ if(SPHINX_EXECUTABLE) add_custom_target(html ${SPHINX_EXECUTABLE} - -q -a -b html + -q -b html -c "${SPHINX_BUILD_DIR}" -d "${SPHINX_CACHE_DIR}" ${SPHINX_OPTIONS} "${SPHINX_SOURCE_DIR}" "${SPHINX_HTML_DIR}" BYPRODUCTS ${SPHINX_HTML_DIR} - COMMENT "Build HTML documentation with Sphinx") - add_custom_target(man + ) + add_custom_target(man ALL ${SPHINX_EXECUTABLE} - -q -a -b man + -q -b man -c "${SPHINX_BUILD_DIR}" -d "${SPHINX_CACHE_DIR}" ${SPHINX_OPTIONS} "${SPHINX_SOURCE_DIR}" "${SPHINX_MAN_DIR}" BYPRODUCTS ${SPHINX_MAN_DIR} - COMMENT "Build manpage documentation with Sphinx") + ) + + install(DIRECTORY ${SPHINX_MAN_DIR}/ + DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 + FILES_MATCHING PATTERN *.1 + ) + install(DIRECTORY ${SPHINX_MAN_DIR}/ + DESTINATION ${CMAKE_INSTALL_MANDIR}/man3 + FILES_MATCHING PATTERN *.3 + ) endif() diff --git a/libhashkit-1.0/CMakeLists.txt b/libhashkit-1.0/CMakeLists.txt index 8fa3e9a2..d4fb6a49 100644 --- a/libhashkit-1.0/CMakeLists.txt +++ b/libhashkit-1.0/CMakeLists.txt @@ -1,2 +1,7 @@ configure_file(configure.h.in configure.h @ONLY) + +install(DIRECTORY ../libhashkit-1.0 + TYPE INCLUDE + FILES_MATCHING REGEX "\\.h(pp)?$" + ) diff --git a/libhashkit-1.0/configure.h.in b/libhashkit-1.0/configure.h.in index a2f70f92..508ff7bc 100644 --- a/libhashkit-1.0/configure.h.in +++ b/libhashkit-1.0/configure.h.in @@ -41,7 +41,7 @@ #pragma once -#define LIBHASHKIT_VERSION_STRING "@LIBHASHKIT_VERSION_STRING@" +#define LIBHASHKIT_VERSION_STRING "@LIBHASHKIT_VERSION@" #define LIBHASHKIT_VERSION_HEX @LIBHASHKIT_VERSION_HEX@ #ifdef __cplusplus diff --git a/libhashkit/CMakeLists.txt b/libhashkit/CMakeLists.txt index fa871600..b9b500f0 100644 --- a/libhashkit/CMakeLists.txt +++ b/libhashkit/CMakeLists.txt @@ -36,3 +36,12 @@ target_include_directories(libhashkit PRIVATE ..) target_compile_options(libhashkit PRIVATE -DBUILDING_HASHKIT) configure_file(hashkitcon.h.in hashkitcon.h @ONLY) + +set_target_properties(libhashkit PROPERTIES SOVERSION ${LIBHASHKIT_SO_VERSION}) +install(TARGETS libhashkit EXPORT libhashkit) +export(EXPORT libhashkit) +install(EXPORT libhashkit DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + TYPE INCLUDE + FILES_MATCHING PATTERN hashkit.h + ) diff --git a/libmemcached-1.0/CMakeLists.txt b/libmemcached-1.0/CMakeLists.txt index 8fa3e9a2..094cffb2 100644 --- a/libmemcached-1.0/CMakeLists.txt +++ b/libmemcached-1.0/CMakeLists.txt @@ -1,2 +1,8 @@ configure_file(configure.h.in configure.h @ONLY) + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + TYPE INCLUDE + FILES_MATCHING REGEX "\\.h(pp)?$" + PATTERN t EXCLUDE + ) diff --git a/libmemcached-1.0/configure.h.in b/libmemcached-1.0/configure.h.in index 70b5e1dd..07d84429 100644 --- a/libmemcached-1.0/configure.h.in +++ b/libmemcached-1.0/configure.h.in @@ -41,10 +41,10 @@ extern "C" { #endif -#cmakedefine DEPRECATED -#cmakedefine LIBMEMCACHED_WITH_SASL_SUPPORT +#cmakedefine01 LIBMEMCACHED_ENABLE_DEPRECATED +#cmakedefine01 LIBMEMCACHED_WITH_SASL_SUPPORT -#define LIBMEMCACHED_VERSION_STRING "@LIBMEMCACHED_VERSION_STRING@" +#define LIBMEMCACHED_VERSION_STRING "@LIBMEMCACHED_VERSION@" #define LIBMEMCACHED_VERSION_HEX @LIBMEMCACHED_VERSION_HEX@ #ifdef __cplusplus diff --git a/libmemcached/CMakeLists.txt b/libmemcached/CMakeLists.txt index 708b637d..19f93a99 100644 --- a/libmemcached/CMakeLists.txt +++ b/libmemcached/CMakeLists.txt @@ -2,6 +2,7 @@ find_package(FLEX) find_package(BISON) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/csl) bison_target(CSL_PARSER csl/parser.yy ${CMAKE_CURRENT_BINARY_DIR}/csl/parser.cc DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/csl/parser.h ) @@ -66,14 +67,29 @@ add_library(libmemcached SHARED ${LIBMEMCACHED_SOURCES}) add_library(memcached ALIAS libmemcached) set_target_properties(libmemcached PROPERTIES LIBRARY_OUTPUT_NAME memcached) -target_link_libraries(libmemcached libhashkit Threads::Threads ${CMAKE_DL_LIBS}) -target_include_directories(libmemcached PRIVATE ..) +target_link_libraries(libmemcached libhashkit Threads::Threads ${LIBSASL_LIBRARIES} ${CMAKE_DL_LIBS}) +target_include_directories(libmemcached PRIVATE .. ${LIBSASL_INCLUDEDIR}) target_compile_definitions(libmemcached PRIVATE -DBUILDING_LIBMEMCACHED) +set_target_properties(libmemcached PROPERTIES SOVERSION ${LIBMEMCACHED_SO_VERSION}) +install(TARGETS libmemcached EXPORT libmemcached) +export(EXPORT libmemcached) +install(EXPORT libmemcached DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake) + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + TYPE INCLUDE + FILES_MATCHING REGEX "(memcached|util)\\.h(pp)?" + PATTERN csl EXCLUDE + PATTERN memcached EXCLUDE + PATTERN util EXCLUDE + ) + +# FIXME: dtrace + add_library(libmemcachedinternal STATIC ${LIBMEMCACHED_SOURCES}) add_library(memcachedinternal ALIAS libmemcachedinternal) set_target_properties(libmemcachedinternal PROPERTIES LIBRARY_OUTPUT_NAME memcachedinternal) -target_link_libraries(libmemcachedinternal libhashkit Threads::Threads ${CMAKE_DL_LIBS}) -target_include_directories(libmemcachedinternal PRIVATE ..) +target_link_libraries(libmemcachedinternal libhashkit Threads::Threads ${LIBSASL_LIBRARIES} ${CMAKE_DL_LIBS}) +target_include_directories(libmemcachedinternal PRIVATE .. ${LIBSASL_INCLUDEDIR}) target_compile_definitions(libmemcachedinternal PRIVATE -DBUILDING_LIBMEMCACHEDINTERNAL) diff --git a/libmemcached/verbosity.cc b/libmemcached/verbosity.cc index ed0e2440..43d73744 100644 --- a/libmemcached/verbosity.cc +++ b/libmemcached/verbosity.cc @@ -58,8 +58,7 @@ static memcached_return_t _set_verbosity(const Memcached *, { memcached_instance_st* instance= memcached_instance_fetch(memc_ptr, 0); - - rc= memcached_vdo(instance, vector, 4, true); + rc= memcached_vdo(instance, vector, 2, true); if (rc == MEMCACHED_SUCCESS) { @@ -86,7 +85,7 @@ memcached_return_t memcached_verbosity(memcached_st *shell, uint32_t verbosity) char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; - int send_length= snprintf(buffer, sizeof(buffer), "%u", verbosity); + int send_length= snprintf(buffer, sizeof(buffer), "verbosity %u\r\n", verbosity); if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE or send_length < 0) { return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, @@ -96,9 +95,7 @@ memcached_return_t memcached_verbosity(memcached_st *shell, uint32_t verbosity) libmemcached_io_vector_st vector[]= { { NULL, 0 }, - { memcached_literal_param("verbosity ") }, { buffer, size_t(send_length) }, - { memcached_literal_param("\r\n") } }; callbacks[0]= _set_verbosity; diff --git a/libmemcachedutil-1.0/CMakeLists.txt b/libmemcachedutil-1.0/CMakeLists.txt new file mode 100644 index 00000000..c74a6492 --- /dev/null +++ b/libmemcachedutil-1.0/CMakeLists.txt @@ -0,0 +1,5 @@ + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + TYPE INCLUDE + FILES_MATCHING REGEX "\\.h(pp)?$" + ) diff --git a/libmemcachedutil/CMakeLists.txt b/libmemcachedutil/CMakeLists.txt index 694a6cfd..1cc32fe3 100644 --- a/libmemcachedutil/CMakeLists.txt +++ b/libmemcachedutil/CMakeLists.txt @@ -12,3 +12,8 @@ set_target_properties(libmemcachedutil PROPERTIES LIBRARY_OUTPUT_NAME memcachedu target_include_directories(libmemcachedutil PRIVATE ..) target_compile_definitions(libmemcachedutil PRIVATE -DBUILDING_LIBMEMCACHED) target_link_libraries(libmemcachedutil libmemcached Threads::Threads) + +set_target_properties(libmemcachedutil PROPERTIES SOVERSION ${LIBMEMCACHEDUTIL_SO_VERSION}) +install(TARGETS libmemcachedutil EXPORT libmemcachedutil) +export(EXPORT libmemcachedutil) +install(EXPORT libmemcachedutil DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake) diff --git a/libtest/CMakeLists.txt b/libtest/CMakeLists.txt index 24686a3c..675d40c2 100644 --- a/libtest/CMakeLists.txt +++ b/libtest/CMakeLists.txt @@ -6,7 +6,9 @@ shift exec $@ ") if(UNIX) - execute_process(COMMAND chmod +x ${CMAKE_BINARY_DIR}/libtool) + if (EXISTS ${CMAKE_BINARY_DIR}/libtool) + execute_process(COMMAND chmod +x ${CMAKE_BINARY_DIR}/libtool) + endif() endif() add_library(libtest STATIC @@ -64,7 +66,6 @@ target_include_directories(wait PRIVATE ..) add_executable(core_count core_count.cc cpu.cc) target_include_directories(core_count PRIVATE ..) -add_executable(abort abort.cc) add_executable(backtrace backtrace_test.cc ../libmemcached/backtrace.cc) target_link_libraries(backtrace PRIVATE ${CMAKE_DL_LIBS}) target_include_directories(backtrace PRIVATE ..) diff --git a/libtest/abort.cc b/libtest/abort.cc deleted file mode 100644 index 117c4312..00000000 --- a/libtest/abort.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Data Differential YATL (i.e. libtest) library - * - * Copyright (C) 2012 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -int main(void) -{ - if (1) - { - abort(); - } - - return 0; -} diff --git a/libtest/collection.cc b/libtest/collection.cc index 040dd8b4..ff9c8869 100644 --- a/libtest/collection.cc +++ b/libtest/collection.cc @@ -147,11 +147,11 @@ test_return_t Collection::exec() auto output = server->output(); if (output.first.size()) { - err << "Server stdout:\n" << output.first << "\n"; + err << "Server(" << server->port() << ") stdout:\n" << output.first << "\n"; } if (output.second.size()) { - err << "Server stderr:\n" << output.second << "\n"; + err << "Server(" << server->port() << ") stderr:\n" << output.second << "\n"; } } throw; @@ -172,11 +172,11 @@ test_return_t Collection::exec() auto output = server->output(); if (output.first.size()) { - Out << "Server stdout:\n" << output.first << "\n"; + Out << "Server(" << server->port() << ") stdout:\n" << output.first << "\n"; } if (output.second.size()) { - Out << "Server stderr:\n" << output.second << "\n"; + Out << "Server(" << server->port() << ") stderr:\n" << output.second << "\n"; } } break; diff --git a/m4/ax_libmemcached.m4 b/m4/ax_libmemcached.m4 deleted file mode 100644 index 95e5c9f7..00000000 --- a/m4/ax_libmemcached.m4 +++ /dev/null @@ -1,138 +0,0 @@ -# =========================================================================== -# https//libmemcached.org/ -# =========================================================================== -# -# SYNOPSIS -# -# AX_LIBMEMCACHED, AX_LIBMEMCACHED_UTIL, AX_ENABLE_LIBMEMCACHED -# -# DESCRIPTION -# -# Checked for installation of libmemcached -# -# AC_SUBST(LIBMEMCACHED_CFLAGS) -# AC_SUBST(LIBMEMCACHED_LDFLAGS) -# AC_SUBST(LIBMEMCACHED_UTIL_LDFLAGS) -# -# NOTE: Implementation uses AC_CHECK_HEADER. -# -# LICENSE -# -# Copyright (C) 2012 Brian Aker -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# -# * The names of its contributors may not be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#serial 1 - -AC_DEFUN([AX_LIBMEMCACHED], [ - AC_CHECK_HEADER([libmemcached-1.0/memcached.h], [ - AC_CACHE_CHECK([check for -lmemcached], [ax_cv_libmemcached], [ - AC_LANG_PUSH([C]) - AX_SAVE_FLAGS - LIBS="-lmemcached $LIBS" - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([#include ], [ - memcached_st *memc; - memc= memcached(NULL, 0); - memcached_free(memc); - ])], - [ax_cv_libmemcached=yes], - [ax_cv_libmemcached=no], - [AC_MSG_WARN([test program execution failed])]) - AC_LANG_POP - AX_RESTORE_FLAGS - ]) - ]) - - AS_IF([test "x$ax_cv_libmemcached" = "xyes"], [ - AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H], [1], [Have libmemcached-1.0/memcached.h]) - ],[ - AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H], [0], [Have libmemcached-1.0/memcached.h]) - ]) - ]) - - AC_DEFUN([AX_LIBMEMCACHED_UTIL], [ - AC_REQUIRE([AX_LIBMEMCACHED]) - AS_IF([test "$ax_cv_libmemcached" = yes], [ - AC_CHECK_HEADER([libmemcachedutil-1.0/util.h], [ - AC_CACHE_CHECK([check for -lmemcachedutil], [ax_cv_libmemcached_util], [ - AX_SAVE_FLAGS - AC_LANG_PUSH([C]) - LIBS="-lmemcachedutil -lmemcached $LIBS" - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([#include ], [ - memcached_pool_st *memc_pool= memcached_pool_create(NULL, 0, 3); - memcached_pool_destroy(memc_pool); - ])], - [ax_cv_libmemcached_util=yes], - [ax_cv_libmemcached_util=no], - [AC_MSG_WARN([test program execution failed])]) - AC_LANG_POP - AX_RESTORE_FLAGS - ]) - ]) - ]) - - AS_IF([test "x$ax_cv_libmemcached_util" = "xyes"], [ - AC_DEFINE([HAVE_LIBMEMCACHED_UTIL_H], [1], [Have libmemcachedutil-1.0/util.h]) - ],[ - AC_DEFINE([HAVE_LIBMEMCACHED_UTIL_H], [0], [Have libmemcachedutil-1.0/util.h]) - ]) - ]) - -AC_DEFUN([_ENABLE_LIBMEMCACHED], [ - AC_REQUIRE([AX_LIBMEMCACHED_UTIL]) - AC_ARG_ENABLE([libmemcached], - [AS_HELP_STRING([--disable-libmemcached], - [Build with libmemcached support @<:@default=on@:>@])], - [ax_enable_libmemcached="$enableval"], - [ax_enable_libmemcached="yes"]) - - AS_IF([test "x$ax_cv_libmemcached" != "xyes"], [ - ax_enable_libmemcached="not found" - ]) - - AS_IF([test "x$ax_enable_libmemcached" = "xyes"], [ - AC_DEFINE([HAVE_LIBMEMCACHED], [1], [Enable libmemcached support]) - LIBMEMCACHED_CFLAGS= - AC_SUBST([LIBMEMCACHED_CFLAGS]) - LIBMEMCACHED_LDFLAGS="-lmemcached" - AC_SUBST([LIBMEMCACHED_LDFLAGS]) - AS_IF([test "x$ax_cv_libmemcached_util" = "xyes"], [ - LIBMEMCACHED_UTIL_LDFLAGS="-lmemcached -lmemcachedutil" - AC_SUBST([LIBMEMCACHED_UTIL_LDFLAGS]) - ]) - ],[ - AC_DEFINE([HAVE_LIBMEMCACHED], [0], [Enable libmemcached support]) - ]) - AM_CONDITIONAL(HAVE_LIBMEMCACHED, test "x${ax_enable_libmemcached}" = "xyes") - ]) - -AC_DEFUN([AX_ENABLE_LIBMEMCACHED], [ AC_REQUIRE([_ENABLE_LIBMEMCACHED]) ]) diff --git a/support/CMakeLists.txt b/support/CMakeLists.txt new file mode 100644 index 00000000..a49ff67c --- /dev/null +++ b/support/CMakeLists.txt @@ -0,0 +1,14 @@ + +install(FILES ax_libmemcached.m4 + DESTINATION ${CMAKE_INSTALL_DATADIR}/aclocal + ) + +configure_file(example.cnf.in example.cnf @ONLY) +install(FILES example.cnf + DESTINATION ${CMAKE_INSTALL_DATADIR} + ) + +configure_file(libmemcached.pc.in libmemcached.pc @ONLY) +install(FILES libmemcached.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig + ) diff --git a/support/ax_libmemcached.m4 b/support/ax_libmemcached.m4 new file mode 100644 index 00000000..95e5c9f7 --- /dev/null +++ b/support/ax_libmemcached.m4 @@ -0,0 +1,138 @@ +# =========================================================================== +# https//libmemcached.org/ +# =========================================================================== +# +# SYNOPSIS +# +# AX_LIBMEMCACHED, AX_LIBMEMCACHED_UTIL, AX_ENABLE_LIBMEMCACHED +# +# DESCRIPTION +# +# Checked for installation of libmemcached +# +# AC_SUBST(LIBMEMCACHED_CFLAGS) +# AC_SUBST(LIBMEMCACHED_LDFLAGS) +# AC_SUBST(LIBMEMCACHED_UTIL_LDFLAGS) +# +# NOTE: Implementation uses AC_CHECK_HEADER. +# +# LICENSE +# +# Copyright (C) 2012 Brian Aker +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# +# * The names of its contributors may not be used to endorse or +# promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#serial 1 + +AC_DEFUN([AX_LIBMEMCACHED], [ + AC_CHECK_HEADER([libmemcached-1.0/memcached.h], [ + AC_CACHE_CHECK([check for -lmemcached], [ax_cv_libmemcached], [ + AC_LANG_PUSH([C]) + AX_SAVE_FLAGS + LIBS="-lmemcached $LIBS" + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([#include ], [ + memcached_st *memc; + memc= memcached(NULL, 0); + memcached_free(memc); + ])], + [ax_cv_libmemcached=yes], + [ax_cv_libmemcached=no], + [AC_MSG_WARN([test program execution failed])]) + AC_LANG_POP + AX_RESTORE_FLAGS + ]) + ]) + + AS_IF([test "x$ax_cv_libmemcached" = "xyes"], [ + AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H], [1], [Have libmemcached-1.0/memcached.h]) + ],[ + AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H], [0], [Have libmemcached-1.0/memcached.h]) + ]) + ]) + + AC_DEFUN([AX_LIBMEMCACHED_UTIL], [ + AC_REQUIRE([AX_LIBMEMCACHED]) + AS_IF([test "$ax_cv_libmemcached" = yes], [ + AC_CHECK_HEADER([libmemcachedutil-1.0/util.h], [ + AC_CACHE_CHECK([check for -lmemcachedutil], [ax_cv_libmemcached_util], [ + AX_SAVE_FLAGS + AC_LANG_PUSH([C]) + LIBS="-lmemcachedutil -lmemcached $LIBS" + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([#include ], [ + memcached_pool_st *memc_pool= memcached_pool_create(NULL, 0, 3); + memcached_pool_destroy(memc_pool); + ])], + [ax_cv_libmemcached_util=yes], + [ax_cv_libmemcached_util=no], + [AC_MSG_WARN([test program execution failed])]) + AC_LANG_POP + AX_RESTORE_FLAGS + ]) + ]) + ]) + + AS_IF([test "x$ax_cv_libmemcached_util" = "xyes"], [ + AC_DEFINE([HAVE_LIBMEMCACHED_UTIL_H], [1], [Have libmemcachedutil-1.0/util.h]) + ],[ + AC_DEFINE([HAVE_LIBMEMCACHED_UTIL_H], [0], [Have libmemcachedutil-1.0/util.h]) + ]) + ]) + +AC_DEFUN([_ENABLE_LIBMEMCACHED], [ + AC_REQUIRE([AX_LIBMEMCACHED_UTIL]) + AC_ARG_ENABLE([libmemcached], + [AS_HELP_STRING([--disable-libmemcached], + [Build with libmemcached support @<:@default=on@:>@])], + [ax_enable_libmemcached="$enableval"], + [ax_enable_libmemcached="yes"]) + + AS_IF([test "x$ax_cv_libmemcached" != "xyes"], [ + ax_enable_libmemcached="not found" + ]) + + AS_IF([test "x$ax_enable_libmemcached" = "xyes"], [ + AC_DEFINE([HAVE_LIBMEMCACHED], [1], [Enable libmemcached support]) + LIBMEMCACHED_CFLAGS= + AC_SUBST([LIBMEMCACHED_CFLAGS]) + LIBMEMCACHED_LDFLAGS="-lmemcached" + AC_SUBST([LIBMEMCACHED_LDFLAGS]) + AS_IF([test "x$ax_cv_libmemcached_util" = "xyes"], [ + LIBMEMCACHED_UTIL_LDFLAGS="-lmemcached -lmemcachedutil" + AC_SUBST([LIBMEMCACHED_UTIL_LDFLAGS]) + ]) + ],[ + AC_DEFINE([HAVE_LIBMEMCACHED], [0], [Enable libmemcached support]) + ]) + AM_CONDITIONAL(HAVE_LIBMEMCACHED, test "x${ax_enable_libmemcached}" = "xyes") + ]) + +AC_DEFUN([AX_ENABLE_LIBMEMCACHED], [ AC_REQUIRE([_ENABLE_LIBMEMCACHED]) ]) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f983db9a..f73dacdb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -34,12 +34,12 @@ endforeach() add_executable(testhashkit hashkit_functions.cc) target_link_libraries(testhashkit PRIVATE libtest libhashkit) target_include_directories(testhashkit PRIVATE ..) -add_test(hashkit testhashkit) +add_test(testhashkit testhashkit) add_executable(hash_plus hash_plus.cc) target_link_libraries(hash_plus PRIVATE libtest libhashkit) target_include_directories(hash_plus PRIVATE ..) -add_test(hashplus hash_plus) +add_test(testhashplus hash_plus) foreach(CLIENT IN LISTS CLIENTS) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${CLIENT}.cc) diff --git a/tests/libmemcached-1.0/CMakeLists.txt b/tests/libmemcached-1.0/CMakeLists.txt index 72bee1c0..11e7b309 100644 --- a/tests/libmemcached-1.0/CMakeLists.txt +++ b/tests/libmemcached-1.0/CMakeLists.txt @@ -4,7 +4,7 @@ target_link_libraries(internals PRIVATE libtest libmemcachedinternal Threads::Th target_include_directories(internals PRIVATE ../..) add_test(internals internals) -add_executable(sasl +add_executable(testsasl basic.cc debug.cc deprecated.cc @@ -21,7 +21,7 @@ add_executable(sasl fetch_all_results.cc generate.cc ) -target_link_libraries(sasl PRIVATE +target_link_libraries(testsasl PRIVATE libclient_utilities libhashkit libmemcached @@ -29,8 +29,8 @@ target_link_libraries(sasl PRIVATE libtest Threads::Threads ) -target_include_directories(sasl PRIVATE ../..) -add_test(sasl sasl) +target_include_directories(testsasl PRIVATE ../..) +add_test(testsasl testsasl) add_executable(atomsmasher atomsmasher.cc) add_executable(testplus plus.cpp) @@ -55,8 +55,6 @@ foreach(TEST IN ITEMS atomsmasher testplus) endforeach() -find_library(LIBUUID uuid REQUIRED) - add_executable(testapp all_tests.cc) add_executable(testsocket all_tests_socket.cc) @@ -95,8 +93,8 @@ foreach(TEST IN ITEMS testapp testsocket) libmemcachedutil libtest Threads::Threads - ${LIBUUID} + ${LIBUUID_LIBRARIES} ) - target_include_directories(${TEST} PRIVATE ../..) + target_include_directories(${TEST} PRIVATE ../.. ${LIBUUID_INCLUDEDIR}) add_test(${TEST} ${TEST}) endforeach() diff --git a/tests/libmemcached-1.0/mem_functions.cc b/tests/libmemcached-1.0/mem_functions.cc index 9c6ab3de..8290e268 100644 --- a/tests/libmemcached-1.0/mem_functions.cc +++ b/tests/libmemcached-1.0/mem_functions.cc @@ -4462,7 +4462,7 @@ test_return_t test_multiple_get_last_disconnect(memcached_st *) test_return_t test_verbosity(memcached_st *memc) { - memcached_verbosity(memc, 3); + test_compare(MEMCACHED_SUCCESS, memcached_verbosity(memc, 0)); return TEST_SUCCESS; } diff --git a/tests/mem_udp.cc b/tests/mem_udp.cc index 53584146..9c9fd0a3 100644 --- a/tests/mem_udp.cc +++ b/tests/mem_udp.cc @@ -382,7 +382,7 @@ static test_return_t udp_verbosity_test(memcached_st *memc) increment_request_id(&expected_ids[x]); } - test_compare(MEMCACHED_SUCCESS, memcached_verbosity(memc, 3)); + test_compare(MEMCACHED_SUCCESS, memcached_verbosity(memc, 0)); return post_udp_op_check(memc, expected_ids); }