Clean up sys-or-submodule code, support system fmt, rename loki-mq

Synced up with oxen-storage-server.

Also rename loki-mq submodule to oxen-mq.
This commit is contained in:
Jason Rhinelander 2022-05-30 15:23:06 -03:00
parent 507a9d22ea
commit 6b785958b4
No known key found for this signature in database
GPG Key ID: C4992CE7A88D4262
4 changed files with 27 additions and 29 deletions

2
.gitmodules vendored
View File

@ -8,7 +8,7 @@
path = external/randomx
url = https://github.com/oxen-io/loki-randomXL
[submodule "external/loki-mq"]
path = external/loki-mq
path = external/oxen-mq
url = https://github.com/oxen-io/loki-mq.git
[submodule "external/googletest"]
path = external/googletest

View File

@ -287,7 +287,7 @@ if(NOT MANUAL_SUBMODULES)
check_submodule(external/rapidjson)
check_submodule(external/trezor-common)
check_submodule(external/randomx)
check_submodule(external/loki-mq cppzmq)
check_submodule(external/oxen-mq cppzmq)
check_submodule(external/SQLiteCpp)
if(BUILD_TESTS)
check_submodule(external/googletest)
@ -460,7 +460,7 @@ if(NOT TARGET sodium)
target_link_libraries(sodium INTERFACE sodium_vendor)
endif()
# Need this target export so that loki-mq properly picks up sodium
# Need this target export so that oxen-mq properly picks up sodium
export(TARGETS sodium NAMESPACE sodium:: FILE sodium-exports.cmake)
endif()

View File

@ -35,39 +35,37 @@
if(NOT STATIC AND NOT BUILD_STATIC_DEPS)
find_package(PkgConfig REQUIRED)
pkg_check_modules(OXENC liboxenc>=1.0.3 IMPORTED_TARGET)
pkg_check_modules(OXENMQ liboxenmq>=1.2.3 IMPORTED_TARGET)
endif()
macro(system_or_submodule BIGNAME smallname pkgconf subdir)
option(FORCE_${BIGNAME}_SUBMODULE "force using ${smallname} submodule" OFF)
if(NOT STATIC AND NOT FORCE_${BIGNAME}_SUBMODULE)
pkg_check_modules(${BIGNAME} ${pkgconf} IMPORTED_TARGET)
endif()
if(${BIGNAME}_FOUND)
add_library(${smallname} INTERFACE)
if(NOT TARGET PkgConfig::${BIGNAME} AND CMAKE_VERSION VERSION_LESS "3.21")
# Work around cmake bug 22180 (PkgConfig::THING not set if no flags needed)
else()
target_link_libraries(${smallname} INTERFACE PkgConfig::${BIGNAME})
endif()
message(STATUS "Found system ${smallname} ${${BIGNAME}_VERSION}")
else()
message(STATUS "using ${smallname} submodule")
add_subdirectory(${subdir})
endif()
if(NOT TARGET ${smallname}::${smallname})
add_library(${smallname}::${smallname} ALIAS ${smallname})
endif()
endmacro()
if(NOT OXENC_FOUND)
message(STATUS "Using in-tree oxen-encoding")
add_subdirectory(oxen-encoding)
add_library(oxenc::oxenc ALIAS oxenc)
elseif(NOT TARGET PkgConfig::OXENC AND CMAKE_VERSION VERSION_LESS "3.21")
# Work around cmake bug 22180 (PkgConfig::OXENC not set if no flags needed):
add_library(_empty_oxenc INTERFACE)
add_library(oxenc::oxenc ALIAS _empty_oxenc)
else()
target_link_libraries(oxenc INTERFACE PkgConfig::OXENC)
add_library(oxenc::oxenc ALIAS oxenc)
message(STATUS "Found liboxenc ${OXENC_VERSION}")
endif()
if(NOT OXENMQ_FOUND)
message(STATUS "Using in-tree oxenmq")
add_subdirectory(loki-mq)
else()
add_library(oxenmq INTERFACE)
target_link_libraries(oxenmq INTERFACE PkgConfig::OXENMQ)
add_library(oxenmq::oxenmq ALIAS oxenmq)
message(STATUS "Found liboxenmq ${OXENMQ_VERSION}")
endif()
system_or_submodule(OXENC oxenc liboxenc>=1.0.3 oxen-encoding)
system_or_submodule(OXENMQ oxenmq liboxenmq>=1.2.12 oxen-mq)
system_or_submodule(FMT fmt fmt>=8.0.0 fmt)
add_subdirectory(db_drivers)
add_subdirectory(easylogging++ easyloggingpp)
add_subdirectory(randomx EXCLUDE_FROM_ALL)
add_subdirectory(fmt)
# uSockets doesn't really have a proper build system (just a very simple Makefile) so build it
# ourselves.