function(enable_dtrace_for TARGET PROBES_D PROBES_H)
if(HAVE_DTRACE AND NOT CMAKE_CROSSCOMPILING)
- target_sources(${TARGET} PRIVATE ${PROBES_H})
add_custom_command(
OUTPUT
- ${PROBES_H}
+ ${CMAKE_CURRENT_BINARY_DIR}/${PROBES_H}
MAIN_DEPENDENCY
${PROBES_D}
COMMAND
ARGS
-x nolibs -h
-s ${CMAKE_CURRENT_SOURCE_DIR}/${PROBES_D}
- -o ${PROBES_H}
+ -o ${CMAKE_CURRENT_BINARY_DIR}/${PROBES_H}
)
+ target_sources(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${PROBES_H})
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
add_custom_command(
OUTPUT
- ${TARGET}_probes.o
+ ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_probes.o
MAIN_DEPENDENCY
- ${PROBES_H}
+ ${CMAKE_CURRENT_BINARY_DIR}/${PROBES_H}
COMMAND
${DTRACE_EXECUTABLE}
ARGS
-x nolibs -G
-s ${CMAKE_CURRENT_SOURCE_DIR}/${PROBES_D}
- -o ${TARGET}_probes.o
+ -o ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_probes.o
)
target_sources(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_probes.o)
set_source_files_properties(${TARGET}_probes.o PROPERTIES
TARGET ${TARGET}
PRE_LINK
DEPENDS
- ${PROBES_H}
+ ${CMAKE_CURRENT_BINARY_DIR}/${PROBES_H}
COMMAND
rm -f ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET}.dir/${PROBES_C}.o
COMMAND
-function(install_public_headers DIRECTORY)
+macro(install_public_headers DIRECTORY)
# validate current directory
string(FIND ${CMAKE_CURRENT_SOURCE_DIR} /include/ INCDIR REVERSE)
string(FIND ${CMAKE_CURRENT_SOURCE_DIR} /src/ SRCDIR REVERSE)
math(EXPR POSITION "${SRCDIR} + 5")
endif()
string(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${POSITION} -1 CHKDIR)
- if(NOT CHKDIR STREQUAL DIRECTORY)
- message(SEND_ERROR "install_public_headers() directories do not match: ${CHKDIR} != ${DIRECTORY}")
+ if(NOT "${CHKDIR}" STREQUAL "${DIRECTORY}")
+ message(SEND_ERROR "install_public_headers() directories do not match: '${CHKDIR}' != '${DIRECTORY}'")
set(ENV{INVALID_CONFIGURATION} 1)
endif()
endif()
+ string(REGEX MATCH "^[^/-]+" LIBRARY "${DIRECTORY}")
+
# validate public interface version
- get_filename_component(TOP ${DIRECTORY} NAME)
- string(FIND ${TOP} "-" DASH)
+ string(FIND "${DIRECTORY}" "-" DASH)
if(DASH GREATER 0)
- string(SUBSTRING ${TOP} 0 ${DASH} LIBRARY)
- string(TOUPPER ${LIBRARY} LIBRARY_UCASE)
+ string(SUBSTRING "${DIRECTORY}" 0 ${DASH} LIBRARY_BASE)
+ string(TOUPPER ${LIBRARY_BASE} LIBRARY_UCASE)
math(EXPR DASH "${DASH} + 1")
- string(SUBSTRING ${TOP} ${DASH} -1 VERSION)
+ string(SUBSTRING "${DIRECTORY}" ${DASH} -1 VERSION)
if(NOT ${LIBRARY_UCASE}_VERSION_INC VERSION_EQUAL ${VERSION})
- message(SEND_ERROR "${LIBRARY} public include directory version ${VERSION} != " ${${LIBRARY_UCASE}_VERSION_INC})
+ message(SEND_ERROR "${LIBRARY_BASE} public include directory version ${VERSION} != " ${${LIBRARY_UCASE}_VERSION_INC})
set(ENV{INVALID_CONFIGURATION} 1)
endif()
endif()
# change local includes to system includes
- foreach(HEADER IN LISTS ARGN)
+ foreach(HEADER IN ITEMS ${ARGN})
if(HEADER MATCHES "^@")
string(SUBSTRING ${HEADER} 1 -1 HEADER)
configure_file(${HEADER}.in ${HEADER})
set(HEADER "${CMAKE_CURRENT_BINARY_DIR}/${HEADER}")
+ else()
+ set(HEADER "${CMAKE_CURRENT_SOURCE_DIR}/${HEADER}")
endif()
install(FILES ${HEADER}
COMPONENT dev
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${DIRECTORY}
)
+ list(APPEND ${LIBRARY}_includes ${HEADER})
endforeach()
-endfunction()
+ set(${LIBRARY}_includes "${${LIBRARY}_includes}" PARENT_SCOPE)
+endmacro()
memtouch
)
+ add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(contrib)
- add_subdirectory(include)
add_subdirectory(support)
# tests need c++17 support
add_subdirectory(libhashkit-1.0)
+set(libhashkit_includes "${libhashkit_includes}" PARENT_SCOPE)
add_subdirectory(libmemcached-1.0)
+set(libmemcached_includes "${libmemcached_includes}" PARENT_SCOPE)
add_subdirectory(libmemcachedutil-1.0)
+set(libmemcachedutil_includes "${libmemcachedutil_includes}" PARENT_SCOPE)
add_subdirectory(libmemcachedprotocol-0.0)
+set(libmemcachedprotocol_includes "${libmemcachedprotocol_includes}" PARENT_SCOPE)
-install_public_headers(libhashkit-1.0
+install_public_headers(
+ libhashkit-1.0
+
@configure.h
algorithm.h
basic_string.h
-add_library(libhashkit SHARED
+set(libhashkit_sources
aes.cc
algorithm.cc
common.h
strerror.cc
string.cc
)
+add_library(libhashkit SHARED)
add_library(hashkit ALIAS libhashkit)
set_target_properties(libhashkit PROPERTIES
CXX_STANDARD ${CXX_STANDARD}
hashkit.h
)
+
+target_sources(libhashkit PRIVATE
+ ${libhashkit_sources}
+ ${libhashkit_includes})
-
find_package(FLEX)
find_package(BISON 2.3)
if("${BISON_VERSION}" VERSION_GREATER_EQUAL 3.0)
- set(BISON_WARNINGS -Wno-deprecated)
+ set(BISON_WARNINGS -Wno-deprecated)
endif()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/csl)
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)
+set_source_files_properties(${BISON_CSL_PARSER_OUTPUTS} PROPERTIES
+ SKIP_UNITY_BUILD_INCLUSION ON)
if(NOT HAVE_UNISTD_H)
- set(FLEX_FLAGS --nounistd)
+ set(FLEX_FLAGS --nounistd)
endif()
flex_target(CSL_SCANNER csl/scanner.l ${CMAKE_CURRENT_BINARY_DIR}/csl/scanner.cc
DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/csl/scanner.h
COMPILE_FLAGS "${FLEX_FLAGS}"
)
-set_source_files_properties(${FLEX_CSL_SCANNER_OUTPUTS} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
+set_source_files_properties(${FLEX_CSL_SCANNER_OUTPUTS} PROPERTIES
+ SKIP_UNITY_BUILD_INCLUSION ON)
add_flex_bison_dependency(CSL_SCANNER CSL_PARSER)
-set(LIBMEMCACHED_SOURCES
+set(libmemcached_sources
csl/context.cc
- ${BISON_CSL_PARSER_OUTPUTS}
${FLEX_CSL_SCANNER_OUTPUTS}
+ ${BISON_CSL_PARSER_OUTPUTS}
allocators.cc
analyze.cc
array.cc
)
endif()
-add_library(libmemcached SHARED
- ${LIBMEMCACHED_SOURCES})
+add_library(libmemcached SHARED)
add_library(memcached ALIAS libmemcached)
set_target_properties(libmemcached PROPERTIES
CXX_STANDARD ${CXX_STANDARD}
util.h
)
-add_library(libmemcachedinternal STATIC
- ${LIBMEMCACHED_SOURCES})
+target_sources(libmemcached PRIVATE
+ ${libmemcached_sources}
+ ${libmemcached_includes})
+
+# TODO: do we really need this?
+
+add_library(libmemcachedinternal STATIC)
add_library(memcachedinternal ALIAS libmemcachedinternal)
set_target_properties(libmemcachedinternal PROPERTIES CXX_STANDARD ${CXX_STANDARD} LIBRARY_OUTPUT_NAME memcachedinternal)
target_compile_definitions(libmemcachedinternal PRIVATE -DBUILDING_LIBMEMCACHEDINTERNAL)
# let libmemcached depend on libmemcachedinternal to ensure that they do not
# compete for the same generated dependencies
add_dependencies(libmemcached libmemcachedinternal)
+
+target_sources(libmemcachedinternal PRIVATE
+ ${libmemcached_sources}
+ ${libmemcached_includes})
check_include(umem.h)
-add_library(libmemcachedprotocol SHARED
+set(libmemcachedprotocol_sources
ascii_handler.c
binary_handler.c
cache.c
pedantic.c
../libmemcached/byteorder.cc
)
+add_library(libmemcachedprotocol SHARED)
add_library(memcachedprotocol ALIAS libmemcachedprotocol)
set_target_properties(libmemcachedprotocol PROPERTIES
CXX_STANDARD ${CXX_STANDARD}
install(EXPORT libmemcachedprotocol-targets NAMESPACE libmemcached::
COMPONENT dev
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
+
+target_sources(libmemcachedprotocol PRIVATE
+ ${libmemcachedprotocol_sources}
+ ${libmemcachedprotocol_includes}
+ )
-
-add_library(libmemcachedutil SHARED
+set(libmemcachedutil_sources
../libmemcached/backtrace.cc
common.h
flush.cc
ping.cc
version.cc
)
+add_library(libmemcachedutil SHARED)
+add_library(memcachedutil ALIAS libmemcachedutil)
if(CMAKE_USE_PTHREADS_INIT)
target_sources(libmemcachedutil PRIVATE pool.cc)
endif()
-add_library(memcachedutil ALIAS libmemcachedutil)
set_target_properties(libmemcachedutil PROPERTIES
CXX_STANDARD ${CXX_STANDARD}
LIBRARY_OUTPUT_NAME memcachedutil
install(EXPORT libmemcachedutil-targets NAMESPACE libmemcached::
COMPONENT dev
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
+
+target_sources(libmemcachedutil PRIVATE
+ ${libmemcachedutil_sources}
+ ${libmemcachedutil_includes})