2020-03-15 05:43:23 +01:00
|
|
|
cmake_minimum_required(VERSION 3.7)
|
2020-02-06 01:21:02 +01:00
|
|
|
|
|
|
|
project(liblokimq CXX)
|
|
|
|
|
2020-03-05 06:00:35 +01:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2020-03-13 15:37:31 +01:00
|
|
|
set(LOKIMQ_VERSION_MAJOR 1)
|
1.1.0: invocation-time SN auth; failure responses
This replaces the recognition of SN status to be checked per-command
invocation rather than on connection. As this breaks the API quite
substantially, though doesn't really affect the functionality, it seems
suitable to bump the minor version.
This requires a fundamental shift in how the calling application tells
LokiMQ about service nodes: rather than using a callback invoked on
connection, the application now has to call set_active_sns() (or the
more efficient update_active_sns(), if changes are readily available) to
update the list whenever it changes. LokiMQ then keeps this list
internally and uses it when determining whether to invoke.
This release also brings better request responses on errors: when a
request fails, the data argument will now be set to the failure reason,
one of:
- TIMEOUT
- UNKNOWNCOMMAND
- NOT_A_SERVICE_NODE (the remote isn't running in SN mode)
- FORBIDDEN (auth level denies the request)
- FORBIDDEN_SN (SN required and the remote doesn't see us as a SN)
Some of these (UNKNOWNCOMMAND, NOT_A_SERVICE_NODE, FORBIDDEN) were
already sent by remotes, but there was no connection to a request and so
they would log a warning, but the request would have to time out.
These errors (minus TIMEOUT, plus NO_REPLY_TAG signalling that a command
is a request but didn't include a reply tag) are also sent in response
to regular commands, but they simply result in a log warning showing the
error type and the command that caused the failure when received.
2020-04-13 00:57:19 +02:00
|
|
|
set(LOKIMQ_VERSION_MINOR 1)
|
2020-04-24 02:51:52 +02:00
|
|
|
set(LOKIMQ_VERSION_PATCH 3)
|
2020-03-13 15:37:31 +01:00
|
|
|
set(LOKIMQ_VERSION "${LOKIMQ_VERSION_MAJOR}.${LOKIMQ_VERSION_MINOR}.${LOKIMQ_VERSION_PATCH}")
|
|
|
|
message(STATUS "lokimq v${LOKIMQ_VERSION}")
|
|
|
|
|
|
|
|
set(LOKIMQ_LIBVERSION 0)
|
|
|
|
|
2020-03-13 18:26:36 +01:00
|
|
|
|
|
|
|
option(BUILD_SHARED_LIBS "Build shared libraries instead of static ones" ON)
|
|
|
|
|
|
|
|
|
2020-03-05 06:00:35 +01:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
|
|
|
2020-03-13 19:29:30 +01:00
|
|
|
configure_file(lokimq/version.h.in lokimq/version.h @ONLY)
|
2020-03-13 19:31:43 +01:00
|
|
|
configure_file(liblokimq.pc.in liblokimq.pc @ONLY)
|
2020-03-13 19:29:30 +01:00
|
|
|
|
2020-03-02 16:21:52 +01:00
|
|
|
add_library(lokimq
|
2020-03-13 18:02:54 +01:00
|
|
|
lokimq/auth.cpp
|
2020-02-06 01:21:02 +01:00
|
|
|
lokimq/bt_serialize.cpp
|
2020-03-13 18:02:54 +01:00
|
|
|
lokimq/connections.cpp
|
|
|
|
lokimq/jobs.cpp
|
|
|
|
lokimq/lokimq.cpp
|
|
|
|
lokimq/proxy.cpp
|
|
|
|
lokimq/worker.cpp
|
2020-03-02 16:21:52 +01:00
|
|
|
)
|
2020-03-13 15:37:31 +01:00
|
|
|
set_target_properties(lokimq PROPERTIES SOVERSION ${LOKIMQ_LIBVERSION})
|
|
|
|
|
2020-03-13 19:27:29 +01:00
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
target_link_libraries(lokimq PRIVATE Threads::Threads)
|
|
|
|
|
2020-03-14 18:19:13 +01:00
|
|
|
# libzmq is nearly impossible to link statically from a system-installed static library: it depends
|
2020-03-15 05:43:23 +01:00
|
|
|
# on a ton of other libraries, some of which are not all statically available. If the caller wants
|
|
|
|
# to mess with this, so be it: they can set up a libzmq target and we'll use it. Otherwise if they
|
|
|
|
# asked us to do things statically, don't even try to find a system lib and just build it.
|
|
|
|
set(lokimq_build_static_libzmq OFF)
|
|
|
|
if(TARGET libzmq)
|
|
|
|
target_link_libraries(lokimq PUBLIC libzmq)
|
|
|
|
elseif(BUILD_SHARED_LIBS)
|
|
|
|
include(FindPkgConfig)
|
|
|
|
pkg_check_modules(libzmq libzmq>=4.3 IMPORTED_TARGET)
|
2020-04-29 03:52:18 +02:00
|
|
|
# Debian sid includes a -isystem in the mit-krb package that, starting with pkg-config 0.29.2,
|
|
|
|
# breaks cmake's pkgconfig module because it stupidly thinks "-isystem" is a path, so if we find
|
|
|
|
# -isystem in the include dirs then hack it out.
|
|
|
|
get_property(zmq_inc TARGET PkgConfig::libzmq PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
|
|
|
list(FIND zmq_inc "-isystem" broken_isystem)
|
|
|
|
if(NOT broken_isystem EQUAL -1)
|
|
|
|
list(REMOVE_AT zmq_inc ${broken_isystem})
|
|
|
|
set_property(TARGET PkgConfig::libzmq PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${zmq_inc})
|
|
|
|
endif()
|
|
|
|
|
2020-03-15 05:43:23 +01:00
|
|
|
if(libzmq_FOUND)
|
|
|
|
target_link_libraries(lokimq PUBLIC PkgConfig::libzmq)
|
|
|
|
else()
|
|
|
|
set(lokimq_build_static_libzmq ON)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(lokimq_build_static_libzmq ON)
|
2020-03-14 18:19:13 +01:00
|
|
|
endif()
|
2020-03-15 05:43:23 +01:00
|
|
|
|
|
|
|
if(lokimq_build_static_libzmq)
|
|
|
|
message(STATUS "libzmq >= 4.3 not found or static build requested, building bundled 4.3.2")
|
2020-03-05 06:00:35 +01:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/local-libzmq")
|
|
|
|
include(LocalLibzmq)
|
2020-03-15 05:43:23 +01:00
|
|
|
target_link_libraries(lokimq PUBLIC libzmq_vendor)
|
2020-03-05 06:00:35 +01:00
|
|
|
endif()
|
|
|
|
|
2020-03-02 16:21:52 +01:00
|
|
|
target_include_directories(lokimq
|
|
|
|
PUBLIC
|
|
|
|
$<INSTALL_INTERFACE:>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
2020-03-15 05:43:23 +01:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cppzmq>
|
2020-03-02 16:21:52 +01:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/mapbox-variant/include>
|
|
|
|
)
|
2020-02-06 01:21:02 +01:00
|
|
|
|
2020-03-02 16:21:52 +01:00
|
|
|
target_compile_options(lokimq PRIVATE -Wall -Wextra -Werror)
|
2020-03-05 19:52:28 +01:00
|
|
|
set_target_properties(lokimq PROPERTIES
|
|
|
|
CXX_STANDARD 14
|
|
|
|
CXX_STANDARD_REQUIRED ON
|
2020-03-13 19:28:03 +01:00
|
|
|
CXX_EXTENSIONS OFF
|
2020-03-05 19:52:28 +01:00
|
|
|
POSITION_INDEPENDENT_CODE ON
|
|
|
|
)
|
2020-02-06 01:21:02 +01:00
|
|
|
|
2020-03-14 18:19:13 +01:00
|
|
|
function(link_dep_libs target linktype libdirs)
|
2020-03-15 05:43:23 +01:00
|
|
|
foreach(lib ${ARGN})
|
|
|
|
find_library(link_lib-${lib} NAMES ${lib} PATHS ${libdirs})
|
|
|
|
message(STATUS "FIND ${lib} FOUND ${link_lib-${lib}}")
|
|
|
|
if(link_lib-${lib})
|
|
|
|
target_link_libraries(${target} ${linktype} ${link_lib-${lib}})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2020-03-14 18:19:13 +01:00
|
|
|
endfunction()
|
|
|
|
|
2020-03-15 05:43:23 +01:00
|
|
|
# If the caller has already set up a sodium target then we will just link to it, otherwise we go
|
|
|
|
# looking for it.
|
|
|
|
if(TARGET sodium)
|
|
|
|
target_link_libraries(lokimq PRIVATE sodium)
|
|
|
|
if(lokimq_build_static_libzmq)
|
|
|
|
target_link_libraries(libzmq_vendor INTERFACE sodium)
|
|
|
|
endif()
|
2020-03-14 18:19:13 +01:00
|
|
|
else()
|
2020-03-15 05:43:23 +01:00
|
|
|
pkg_check_modules(sodium REQUIRED libsodium IMPORTED_TARGET)
|
|
|
|
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
target_link_libraries(lokimq PRIVATE PkgConfig::sodium)
|
|
|
|
if(lokimq_build_static_libzmq)
|
|
|
|
target_link_libraries(libzmq_vendor INTERFACE PkgConfig::sodium)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
link_dep_libs(lokimq PRIVATE "${sodium_STATIC_LIBRARY_DIRS}" ${sodium_STATIC_LIBRARIES})
|
|
|
|
target_include_directories(lokimq PRIVATE ${sodium_STATIC_INCLUDE_DIRS})
|
|
|
|
if(lokimq_build_static_libzmq)
|
|
|
|
link_dep_libs(libzmq_vendor INTERFACE "${sodium_STATIC_LIBRARY_DIRS}" ${sodium_STATIC_LIBRARIES})
|
|
|
|
target_link_libraries(libzmq_vendor INTERFACE ${sodium_STATIC_INCLUDE_DIRS})
|
|
|
|
endif()
|
|
|
|
endif()
|
2020-03-14 18:19:13 +01:00
|
|
|
endif()
|
2020-03-05 21:00:26 +01:00
|
|
|
|
2020-03-01 19:28:50 +01:00
|
|
|
add_library(lokimq::lokimq ALIAS lokimq)
|
2020-03-02 16:21:52 +01:00
|
|
|
|
|
|
|
export(
|
|
|
|
TARGETS lokimq
|
|
|
|
NAMESPACE lokimq::
|
|
|
|
FILE lokimqTargets.cmake
|
|
|
|
)
|
|
|
|
install(
|
|
|
|
TARGETS lokimq
|
|
|
|
EXPORT lokimqConfig
|
2020-03-13 19:29:59 +01:00
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
2020-03-02 16:21:52 +01:00
|
|
|
)
|
2020-03-01 19:28:50 +01:00
|
|
|
|
2020-03-13 19:29:30 +01:00
|
|
|
install(
|
|
|
|
FILES lokimq/auth.h
|
|
|
|
lokimq/batch.h
|
|
|
|
lokimq/bt_serialize.h
|
|
|
|
lokimq/connections.h
|
|
|
|
lokimq/hex.h
|
|
|
|
lokimq/lokimq.h
|
|
|
|
lokimq/message.h
|
|
|
|
lokimq/string_view.h
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/lokimq/version.h
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lokimq
|
|
|
|
)
|
2020-03-13 22:53:55 +01:00
|
|
|
option(LOKIMQ_INSTALL_MAPBOX_VARIANT "Install mapbox-variant headers with lokimq/ headers" ON)
|
|
|
|
if(LOKIMQ_INSTALL_MAPBOX_VARIANT)
|
|
|
|
install(
|
|
|
|
FILES mapbox-variant/include/mapbox/variant.hpp
|
|
|
|
mapbox-variant/include/mapbox/variant_cast.hpp
|
|
|
|
mapbox-variant/include/mapbox/variant_io.hpp
|
|
|
|
mapbox-variant/include/mapbox/variant_visitor.hpp
|
|
|
|
mapbox-variant/include/mapbox/recursive_wrapper.hpp
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lokimq/mapbox
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(LOKIMQ_INSTALL_CPPZMQ "Install cppzmq header with lokimq/ headers" ON)
|
|
|
|
if(LOKIMQ_INSTALL_CPPZMQ)
|
|
|
|
install(
|
|
|
|
FILES cppzmq/zmq.hpp
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lokimq
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2020-03-13 19:29:30 +01:00
|
|
|
|
2020-03-13 19:31:43 +01:00
|
|
|
install(
|
|
|
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/liblokimq.pc
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
|
|
|
|
)
|
|
|
|
|
2020-03-01 19:28:50 +01:00
|
|
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
|
|
|
set(lokimq_IS_TOPLEVEL_PROJECT TRUE)
|
|
|
|
else()
|
|
|
|
set(lokimq_IS_TOPLEVEL_PROJECT FALSE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(LOKIMQ_BUILD_TESTS "Building and perform lokimq tests" ${lokimq_IS_TOPLEVEL_PROJECT})
|
|
|
|
if(LOKIMQ_BUILD_TESTS)
|
2020-02-06 23:10:26 +01:00
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|
|
|
|
|