Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "external/oxen-encoding"]
path = external/oxen-encoding
url = https://github.com/session-foundation/oxen-encoding.git
[submodule "cmake/session-deps"]
path = cmake/session-deps
url = https://github.com/session-foundation/session-deps.git
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ else()
endif()

option(BUILD_SHARED_LIBS "Build as shared library" OFF)
option(BUILD_STATIC_DEPS "Download, build, and statically link against core dependencies" OFF)
option(WARNINGS_AS_ERRORS "treat all warnings as errors. turn off for development, on for release" OFF)
option(LIBQUIC_WARN_DEPRECATED "warn deprecated" ON)
option(LIBQUIC_BUILD_TESTS "Build libquic test suite" ${libquic_IS_TOPLEVEL_PROJECT})
Expand All @@ -49,6 +48,8 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

include(cmake/session-deps/Deps.cmake)

set(default_lto ON)
if(WIN32 OR BUILD_STATIC_DEPS)
set(default_lto OFF)
Expand Down Expand Up @@ -76,10 +77,6 @@ endif()

include(GNUInstallDirs)

if(BUILD_STATIC_DEPS)
include(cmake/StaticBuild.cmake)
endif()

# Interface target for any general includes, flags, etc. that is meant to be inherited publicly.
add_library(libquic_external INTERFACE)

Expand Down
5 changes: 0 additions & 5 deletions cmake/FindXXX.cmake.template

This file was deleted.

442 changes: 0 additions & 442 deletions cmake/StaticBuild.cmake

This file was deleted.

7 changes: 0 additions & 7 deletions cmake/add_static_target.cmake

This file was deleted.

46 changes: 0 additions & 46 deletions cmake/build_external.cmake

This file was deleted.

28 changes: 0 additions & 28 deletions cmake/check_submodule.cmake

This file was deleted.

1 change: 1 addition & 0 deletions cmake/session-deps
Submodule session-deps added at d7ad06
21 changes: 0 additions & 21 deletions cmake/system_or_submodule.cmake

This file was deleted.

76 changes: 11 additions & 65 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,84 +16,30 @@ set(BUILD_SHARED_LIBS OFF)

include_directories(BEFORE SYSTEM ${DEPS_DESTDIR}/include)

include(build_external)
include(add_static_target)
include(system_or_submodule)

find_package(Git)
if(GIT_FOUND)
message(STATUS "Checking submodules")
include(check_submodule)
check_submodule(oxen-logging fmt spdlog)
check_submodule(oxen-encoding)
endif()

if(NOT BUILD_STATIC_DEPS)
find_package(PkgConfig REQUIRED)
endif()

if(NOT TARGET ngtcp2::ngtcp2)
pkg_check_modules(NGTCP2 libngtcp2>=1.1.0 IMPORTED_TARGET REQUIRED)
add_library(ngtcp2 INTERFACE)
target_link_libraries(ngtcp2 INTERFACE PkgConfig::NGTCP2)
add_library(ngtcp2::ngtcp2 ALIAS ngtcp2)
endif()

if(NOT TARGET ngtcp2::crypto_gnutls)
pkg_check_modules(NGTCP2_GNUTLS libngtcp2_crypto_gnutls>=1.1.0 IMPORTED_TARGET REQUIRED)
add_library(ngtcp2_crypto_gnutls INTERFACE)
target_link_libraries(ngtcp2_crypto_gnutls INTERFACE ngtcp2::ngtcp2 PkgConfig::NGTCP2_GNUTLS)
add_library(ngtcp2::crypto_gnutls ALIAS ngtcp2_crypto_gnutls)
endif()
check_submodule(oxen-logging fmt spdlog)
check_submodule(oxen-encoding)

# oxen-logging
if (NOT TARGET oxen::logging)
if(BUILD_STATIC_DEPS)
set(OXEN_LOGGING_FORCE_SUBMODULES ON CACHE INTERNAL "")
endif()
system_or_submodule(OXENLOGGING oxen-logging liboxen-logging>=1.2.0 oxen-logging)
if(OXENLOGGING_FOUND)
sessiondep_or_submodule(liboxen-logging 1.2.0 oxen-logging oxen::logging)
if(NOT TARGET oxen-logging)
# If we load oxen-logging via system lib then we won't necessarily have fmt/spdlog targets,
# but this script will give us them:
include(oxen-logging/cmake/load_fmt_spdlog.cmake)

add_library(oxen-logging-fmt-spdlog INTERFACE)
target_link_libraries(oxen-logging-fmt-spdlog INTERFACE oxen-logging ${OXEN_LOGGING_FMT_TARGET} ${OXEN_LOGGING_SPDLOG_TARGET})
add_library(oxen::logging ALIAS oxen-logging-fmt-spdlog)
target_link_libraries(oxen-logging-fmt-spdlog INTERFACE oxen::logging ${OXEN_LOGGING_FMT_TARGET} ${OXEN_LOGGING_SPDLOG_TARGET})
add_library(oxen::logging-fmt ALIAS oxen-logging-fmt-spdlog)
else()
# Otherwise oxen-logging from the submodule will already publicly provide fmt/spdlog:
add_library(oxen::logging-fmt ALIAS oxen-logging)
endif()
endif()

# oxenc
if (NOT TARGET oxenc)
system_or_submodule(OXENC oxenc liboxenc>=1.4.0 oxen-encoding)
endif()

# libevent
if(NOT TARGET libevent::core)
add_library(libevent_core INTERFACE)
pkg_check_modules(LIBEVENT_core libevent_core>=2.1 IMPORTED_TARGET REQUIRED)
target_link_libraries(libevent_core INTERFACE PkgConfig::LIBEVENT_core)
add_library(libevent::core ALIAS libevent_core)

add_library(libevent_threads INTERFACE)
if(NOT WIN32)
pkg_check_modules(LIBEVENT_pthreads libevent_pthreads>=2.1 IMPORTED_TARGET REQUIRED)
target_link_libraries(libevent_threads INTERFACE PkgConfig::LIBEVENT_pthreads)
endif()
add_library(libevent::threads ALIAS libevent_threads)
endif()

# gnutls
if(NOT TARGET gnutls::gnutls)
add_library(gnutls INTERFACE)
pkg_check_modules(GNUTLS gnutls>=3.7.2 IMPORTED_TARGET REQUIRED)
target_link_libraries(gnutls INTERFACE PkgConfig::GNUTLS)
add_library(gnutls::gnutls ALIAS gnutls)
endif()

if(NOT TARGET nettle::nettle)
add_library(nettle INTERFACE)
pkg_check_modules(NETTLE nettle IMPORTED_TARGET REQUIRED)
target_link_libraries(nettle INTERFACE PkgConfig::NETTLE)
add_library(nettle::nettle ALIAS nettle)
if (NOT TARGET oxenc::oxenc)
sessiondep_or_submodule(liboxenc 1.4.0 oxen-encoding oxenc::oxenc)
endif()
19 changes: 12 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ set(libquic_send_allowed "gso, sendmmsg, sendmsg")

configure_file(version.cpp.in version.cpp @ONLY)

session_dep(libngtcp2 1.1.0 WITH libngtcp2_crypto_gnutls)
session_dep(gnutls 3.7.2)
session_dep(nettle 3.5)
session_dep(libevent_core 2.1 WITH libevent_pthreads)

add_library(quic
address.cpp
btstream.cpp
Expand All @@ -25,16 +30,16 @@ add_library(quic

target_link_libraries(quic
PUBLIC
ngtcp2::crypto_gnutls
gnutls::gnutls
oxen::logging
sessiondep::libngtcp2
sessiondep::libngtcp2_crypto_gnutls
sessiondep::gnutls
oxen::logging-fmt
libquic_external
oxenc
oxenc::oxenc
sessiondep::libevent_core sessiondep::libevent_pthreads
PRIVATE
libevent::core
libevent::threads
libquic_internal
nettle::nettle
sessiondep::nettle
)

target_compile_features(quic INTERFACE cxx_std_20)
Expand Down
19 changes: 5 additions & 14 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,15 @@ add_subdirectory(CLI11)


add_library(tests_common STATIC utils.cpp)
target_link_libraries(tests_common PUBLIC
quic CLI11::CLI11 libquic_internal-warnings gnutls::gnutls)

macro(link_test_dep x)
string(TOUPPER "${x}" BIG_X)
if(TARGET ${x}::${x})
target_link_libraries(tests_common INTERFACE ${x}::${x})
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(${BIG_X} ${x} REQUIRED IMPORTED_TARGET)
target_link_libraries(tests_common INTERFACE PkgConfig::${BIG_X})
endif()
endmacro()

# We need hogweed for generating Ed25519 keys (this is already a gnutls dependency, so we
# shouldn't be adding any new dep by requiring it)
link_test_dep(hogweed)
link_test_dep(nettle)
session_dep(nettle 0 WITH hogweed)

target_link_libraries(tests_common PUBLIC
quic CLI11::CLI11 libquic_internal-warnings sessiondep::gnutls sessiondep::hogweed sessiondep::nettle)


function(extra_linking target)
if(WIN32 AND NOT BUILD_SHARED_LIBS)
Expand Down