# globals
include(CTest)
include(GNUInstallDirs)
+include(CMakePackageConfigHelpers)
find_package(PkgConfig)
+set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# locals
set(CMAKE_INSTALL_PREFIX /usr/local
CACHE PATH "install prefix")
+if(APPLE)
+ set(CMAKE_INSTALL_RPATH @loader_path
+ CACHE STRING "set relative rpath")
+elseif(UNIX)
+ # FIXME
+ set(CMAKE_INSTALL_RPATH $ORIGIN
+ CACHE STRING "set relative rpath")
+endif()
+
option(BUILD_TESTING "whether to enable build of the test suite"
OFF)
option(BUILD_DOCSONLY "build *only* documentation"
add_executable(${CLIENT} ${CLIENT}.cc)
target_include_directories(${CLIENT} PRIVATE ..)
target_link_libraries(${CLIENT} PRIVATE libclient_utilities)
- set_target_properties(${CLIENT} PROPERTIES INSTALL_RPATH $ORIGIN/../${CMAKE_INSTALL_LIBDIR})
+ if(CMAKE_INSTALL_RPATH)
+ set_target_properties(${CLIENT} PROPERTIES
+ INSTALL_RPATH ${CMAKE_INSTALL_RPATH}/../${CMAKE_INSTALL_LIBDIR})
+ endif()
install(TARGETS ${CLIENT}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endforeach()
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 PRIVATE libclient_utilities ${LIBEVENT_LIBRARIES} Threads::Threads)
+ if(CMAKE_INSTALL_RPATH)
+ set_target_properties(${CLIENT} PROPERTIES
+ INSTALL_RPATH ${CMAKE_INSTALL_RPATH}/../${CMAKE_INSTALL_LIBDIR})
+ endif()
install(TARGETS memaslap
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
add_library(hashkit ALIAS libhashkit)
set_target_properties(libhashkit PROPERTIES
LIBRARY_OUTPUT_NAME hashkit
- INSTALL_RPATH $ORIGIN
+ LIBRARY_OUTPUT_NAME_DEBUG hashkit-dbg
SOVERSION ${LIBHASHKIT_SO_VERSION}
VERSION v${LIBHASHKIT_VERSION})
target_compile_options(libhashkit PRIVATE -DBUILDING_HASHKIT)
$<INSTALL_INTERFACE:include>)
configure_file(hashkitcon.h.in hashkitcon.h @ONLY)
-install(TARGETS libhashkit EXPORT libhashkit
+install(TARGETS libhashkit EXPORT libhashkit-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-export(EXPORT libhashkit)
-install(EXPORT libhashkit DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
+export(EXPORT libhashkit-targets NAMESPACE libmemcached::)
+install(EXPORT libhashkit-targets NAMESPACE libmemcached:: DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
install_public_headers(
libhashkit
DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/csl/parser.h
COMPILE_FLAGS ${BISON_WARNINGS}
)
+set_source_files_properties(${BISON_CSL_PARSER_OUTPUTS} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
flex_target(CSL_SCANNER csl/scanner.l ${CMAKE_CURRENT_BINARY_DIR}/csl/scanner.cc
DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/csl/scanner.h
)
+set_source_files_properties(${FLEX_CSL_SCANNER_OUTPUTS} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
add_flex_bison_dependency(CSL_SCANNER CSL_PARSER)
if(HAVE_DTRACE)
add_library(memcached ALIAS libmemcached)
set_target_properties(libmemcached PROPERTIES
LIBRARY_OUTPUT_NAME memcached
- INSTALL_RPATH $ORIGIN
+ LIBRARY_OUTPUT_NAME_DEBUG memcached-dbg
SOVERSION ${LIBMEMCACHED_SO_VERSION}
VERSION v${LIBMEMCACHED_VERSION})
target_compile_definitions(libmemcached PRIVATE -DBUILDING_LIBMEMCACHED)
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
-install(TARGETS libmemcached EXPORT libmemcached
+install(TARGETS libmemcached EXPORT libmemcached-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-export(EXPORT libmemcached)
-install(EXPORT libmemcached DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
+export(EXPORT libmemcached-targets NAMESPACE libmemcached::)
+install(EXPORT libmemcached-targets NAMESPACE libmemcached:: DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
install_public_headers(
libmemcached
add_library(memcachedprotocol ALIAS libmemcachedprotocol)
set_target_properties(libmemcachedprotocol PROPERTIES
LIBRARY_OUTPUT_NAME memcachedprotocol
- INSTALL_RPATH $ORIGIN
+ LIBRARY_OUTPUT_NAME_DEBUG memcachedprotocol-dbg
SOVERSION ${LIBMEMCACHEDPROTOCOL_SO_VERSION}
VERSION v${LIBMEMCACHEDPROTOCOL_VERSION})
target_compile_definitions(libmemcachedprotocol PRIVATE -DBUILDING_LIBMEMCACHED)
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
-install(TARGETS libmemcachedprotocol EXPORT libmemcachedprotocol
+install(TARGETS libmemcachedprotocol EXPORT libmemcachedprotocol-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-export(EXPORT libmemcachedprotocol)
-install(EXPORT libmemcachedprotocol DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
+export(EXPORT libmemcachedprotocol-targets NAMESPACE libmemcached::)
+install(EXPORT libmemcachedprotocol-targets NAMESPACE libmemcached:: DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
* @param text the text to spool
* @return status of the spool operation
*/
-static protocol_binary_response_status raw_response_handler(memcached_protocol_client_st *client, const char *text)
+static protocol_binary_response_status ascii_raw_response_handler(memcached_protocol_client_st *client, const char *text)
{
if (client->is_verbose)
{
};
client->mute = false;
- raw_response_handler(client, errmsg[client->ascii_command]);
+ ascii_raw_response_handler(client, errmsg[client->ascii_command]);
}
/**
uint32_t textlen)
{
memcached_protocol_client_st *client= (memcached_protocol_client_st*)cookie;
- raw_response_handler(client, "VERSION ");
+ ascii_raw_response_handler(client, "VERSION ");
client->root->spool(client, text, textlen);
- raw_response_handler(client, "\r\n");
+ ascii_raw_response_handler(client, "\r\n");
return PROTOCOL_BINARY_RESPONSE_SUCCESS;
}
if (key != NULL)
{
- raw_response_handler(client, "STAT ");
+ ascii_raw_response_handler(client, "STAT ");
client->root->spool(client, key, keylen);
- raw_response_handler(client, " ");
+ ascii_raw_response_handler(client, " ");
client->root->spool(client, body, bodylen);
- raw_response_handler(client, "\r\n");
+ ascii_raw_response_handler(client, "\r\n");
}
else
{
- raw_response_handler(client, "END\r\n");
+ ascii_raw_response_handler(client, "END\r\n");
}
return PROTOCOL_BINARY_RESPONSE_SUCCESS;
if (client->root->callback->interface.v1.delete_object == NULL)
{
- raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+ ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
return;
}
if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS)
{
- raw_response_handler(client, "DELETED\r\n");
+ ascii_raw_response_handler(client, "DELETED\r\n");
}
else if (rval == PROTOCOL_BINARY_RESPONSE_KEY_ENOENT)
{
- raw_response_handler(client, "NOT_FOUND\r\n");
+ ascii_raw_response_handler(client, "NOT_FOUND\r\n");
}
else
{
char msg[80];
snprintf(msg, sizeof(msg), "SERVER_ERROR: delete_object failed %u\r\n",(uint32_t)rval);
- raw_response_handler(client, msg);
+ ascii_raw_response_handler(client, msg);
}
}
{
if (client->root->callback->interface.v1.increment == NULL)
{
- raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+ ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
return;
}
rval= client->root->callback->interface.v1.increment(client,
{
if (client->root->callback->interface.v1.decrement == NULL)
{
- raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+ ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
return;
}
rval= client->root->callback->interface.v1.decrement(client,
{
char buffer[80];
snprintf(buffer, sizeof(buffer), "%"PRIu64"\r\n", result);
- raw_response_handler(client, buffer);
+ ascii_raw_response_handler(client, buffer);
}
else
{
- raw_response_handler(client, "NOT_FOUND\r\n");
+ ascii_raw_response_handler(client, "NOT_FOUND\r\n");
}
}
{
if (client->root->callback->interface.v1.stat == NULL)
{
- raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+ ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
return;
}
if (client->root->callback->interface.v1.version == NULL)
{
- raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+ ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
return;
}
if (client->root->callback->interface.v1.flush_object == NULL)
{
- raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+ ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
return;
}
protocol_binary_response_status rval;
rval= client->root->callback->interface.v1.flush_object(client, timeout);
if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS)
- raw_response_handler(client, "OK\r\n");
+ ascii_raw_response_handler(client, "OK\r\n");
else
- raw_response_handler(client, "SERVER_ERROR: internal error\r\n");
+ ascii_raw_response_handler(client, "SERVER_ERROR: internal error\r\n");
}
/**
if (nkey == 0)
{
/* return error */
- raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
+ ascii_raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
return -1;
}
if (errno != 0)
{
/* return error */
- raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
+ ascii_raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
return -1;
}
if (errno != 0)
{
/* return error */
- raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
+ ascii_raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
return -1;
}
if (errno != 0)
{
/* return error */
- raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
+ ascii_raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
return -1;
}
if (errno != 0)
{
/* return error */
- raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
+ ascii_raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
return -1;
}
/* FALLTHROUGH */
if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS)
{
- raw_response_handler(client, "STORED\r\n");
+ ascii_raw_response_handler(client, "STORED\r\n");
}
else
{
{
if (rval == PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS)
{
- raw_response_handler(client, "EXISTS\r\n");
+ ascii_raw_response_handler(client, "EXISTS\r\n");
}
else if (rval == PROTOCOL_BINARY_RESPONSE_KEY_ENOENT)
{
- raw_response_handler(client, "NOT_FOUND\r\n");
+ ascii_raw_response_handler(client, "NOT_FOUND\r\n");
}
else
{
- raw_response_handler(client, "NOT_STORED\r\n");
+ ascii_raw_response_handler(client, "NOT_STORED\r\n");
}
}
else
{
- raw_response_handler(client, "NOT_STORED\r\n");
+ ascii_raw_response_handler(client, "NOT_STORED\r\n");
}
}
if (client->root->callback->interface.v1.replace == NULL)
{
- raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+ ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
return false;
}
if (client->root->callback->interface.v1.set == NULL)
{
- raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+ ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
return false;
}
if (client->root->callback->interface.v1.add == NULL)
{
- raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+ ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
return false;
}
if (client->root->callback->interface.v1.replace == NULL)
{
- raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+ ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
return false;
}
if (client->root->callback->interface.v1.append == NULL)
{
- raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+ ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
return false;
}
if (client->root->callback->interface.v1.prepend == NULL)
{
- raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+ ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
return false;
}
}
else
{
- raw_response_handler(client, "SERVER_ERROR: Command not implemented\n");
+ ascii_raw_response_handler(client, "SERVER_ERROR: Command not implemented\n");
}
}
else
}
else
{
- raw_response_handler(client, "OK\r\n");
+ ascii_raw_response_handler(client, "OK\r\n");
}
break;
* @param response the packet to send
* @return The status of the operation
*/
-static protocol_binary_response_status raw_response_handler(const void *cookie,
+static protocol_binary_response_status binary_raw_response_handler(const void *cookie,
protocol_binary_request_header *request,
protocol_binary_response_header *response)
{
case 0:
if (client->root->callback->interface.v0.comcode[cc] != NULL)
{
- rval= client->root->callback->interface.v0.comcode[cc](client, header, raw_response_handler);
+ rval= client->root->callback->interface.v0.comcode[cc](client, header, binary_raw_response_handler);
}
break;
case 1:
if (comcode_v0_v1_remap[cc] != NULL)
{
- rval= comcode_v0_v1_remap[cc](client, header, raw_response_handler);
+ rval= comcode_v0_v1_remap[cc](client, header, binary_raw_response_handler);
}
break;
if (rval == PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND &&
client->root->callback->unknown != NULL)
{
- rval= client->root->callback->unknown(client, header, raw_response_handler);
+ rval= client->root->callback->unknown(client, header, binary_raw_response_handler);
}
if (rval != PROTOCOL_BINARY_RESPONSE_SUCCESS &&
},
}
};
- rval= raw_response_handler(client, header, (void*)&response);
+ rval= binary_raw_response_handler(client, header, (void *) &response);
}
if (client->root->callback->post_execute != NULL)
memcached_binary_protocol_raw_response_handler memcached_binary_protocol_get_raw_response_handler(const void *cookie)
{
(void)cookie;
- return raw_response_handler;
+ return binary_raw_response_handler;
}
void memcached_binary_protocol_set_pedantic(memcached_protocol_st *instance, bool enable)
add_library(memcachedutil ALIAS libmemcachedutil)
set_target_properties(libmemcachedutil PROPERTIES
LIBRARY_OUTPUT_NAME memcachedutil
- INSTALL_RPATH $ORIGIN
+ LIBRARY_OUTPUT_NAME_DEBUG memcachedutil-dbg
SOVERSION ${LIBMEMCACHEDUTIL_SO_VERSION}
VERSION v${LIBMEMCACHEDUTIL_VERSION})
target_compile_definitions(libmemcachedutil PRIVATE -DBUILDING_LIBMEMCACHED)
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
-install(TARGETS libmemcachedutil EXPORT libmemcachedutil
+install(TARGETS libmemcachedutil EXPORT libmemcachedutil-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-export(EXPORT libmemcachedutil)
-install(EXPORT libmemcachedutil DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
+export(EXPORT libmemcachedutil-targets NAMESPACE libmemcached::)
+install(EXPORT libmemcachedutil-targets NAMESPACE libmemcached:: DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
configure_file(example.cnf.in example.cnf @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/example.cnf
- DESTINATION ${CMAKE_INSTALL_DATADIR}/libmemcached
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}
)
configure_file(libmemcached.pc.in libmemcached.pc @ONLY)
configure_file(memcached.pwdb.in memcached.pwdb @ONLY)
configure_file(memcached.conf.in memcached.conf @ONLY)
endif()
+
+configure_package_config_file(libmemcached-config.cmake.in
+ libmemcached-config.cmake
+ INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake/)
+write_basic_package_version_file(libhashkit-version.cmake
+ VERSION ${LIBHASHKIT_VERSION}
+ COMPATIBILITY SameMajorVersion)
+write_basic_package_version_file(libmemcached-version.cmake
+ VERSION ${LIBMEMCACHED_VERSION}
+ COMPATIBILITY SameMajorVersion)
+write_basic_package_version_file(libmemcachedprotocol-version.cmake
+ VERSION ${LIBMEMCACHEDPROTOCOL_VERSION}
+ COMPATIBILITY SameMajorVersion)
+write_basic_package_version_file(libmemcachedutil-version.cmake
+ VERSION ${LIBMEMCACHEDUTIL_VERSION}
+ COMPATIBILITY SameMajorVersion)
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/libmemcached-config.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/libhashkit-version.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/libmemcached-version.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/libmemcachedprotocol-version.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/libmemcachedutil-version.cmake
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake/)
--- /dev/null
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+find_dependency(Threads)
+
+include(${CMAKE_CURRENT_LIST_DIR}/libhashkit-targets.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/libmemcached-targets.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/libmemcachedprotocol-targets.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/libmemcachedutil-targets.cmake)
+