diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b4e8e5..ec6175d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,28 +1,55 @@ # RetroShare decentralized communication platform # # Copyright (C) 2021-2022 Gioacchino Mazzurco +# Copyright (C) 2026 David Bears # # SPDX-License-Identifier: CC0-1.0 -cmake_minimum_required (VERSION 3.15) +cmake_minimum_required(VERSION 3.15) project(bitdht) -set( - RS_DATA_DIR - "${CMAKE_INSTALL_PREFIX}/share/retroshare" - CACHE STRING - "Path where to install RetroShare system wide data" ) +if(NOT DEFINED RS_DATA_DIR) + include(GNUInstallDirs) + set(RS_DATA_DIR "${CMAKE_INSTALL_DATADIR}/retroshare") +endif() -file( - GLOB BITDHT_SOURCES - src/bitdht/*.c src/bitdht/*.cc src/udp/*.cc src/util/*.cc ) - -add_library(${PROJECT_NAME} ${BITDHT_SOURCES}) +add_library(${PROJECT_NAME}) target_include_directories( ${PROJECT_NAME} - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src ) + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src +) + +if(WIN32) + target_compile_definitions(bitdht PRIVATE UNICODE _UNICODE) + + # Some files trip strict GCC >= 15 diagnostics that are now errors by + # default; downgrade them to warnings for now. + if( + CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR + CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + ) + target_compile_options(bitdht PRIVATE + -Wno-error=incompatible-pointer-types + -Wno-error=int-conversion + -Wno-error=implicit-function-declaration + ) + endif() +endif() + + +add_library(bitdht:bitdht ALIAS bitdht) + +add_subdirectory(src) + +# TODO: some things to polish the cmake integration +# - install the library itself to support dynamic linking +# - install headers +# - install a config file +# - create a build-tree config file +# - config version files for install and build trees install( FILES src/bitdht/bdboot.txt - DESTINATION ${RS_DATA_DIR} ) + DESTINATION ${RS_DATA_DIR} +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..4911b96 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,23 @@ +# ------------------------------------------------------------------------ *\ +# src/CMakeLists.txt +# This file is part of BitDHT +# +# Copyright (C) 2026 David Bears +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . +# ------------------------------------------------------------------------ */ + +add_subdirectory(bitdht) +add_subdirectory(udp) +add_subdirectory(util) diff --git a/src/bitdht/CMakeLists.txt b/src/bitdht/CMakeLists.txt new file mode 100644 index 0000000..5234cd9 --- /dev/null +++ b/src/bitdht/CMakeLists.txt @@ -0,0 +1,55 @@ +# ------------------------------------------------------------------------ *\ +# src/bitdht/CMakeLists.txt +# This file is part of BitDHT +# +# Copyright (C) 2026 David Bears +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . +# ------------------------------------------------------------------------ */ + +target_sources(${PROJECT_NAME} PRIVATE + bdaccount.cc + bdaccount.h + bdconnection.cc + bdconnection.h + bdfilter.cc + bdfilter.h + bdfriendlist.cc + bdfriendlist.h + bdhash.cc + bdhash.h + bdhistory.cc + bdhistory.h + bdiface.h + bdmanager.cc + bdmanager.h + bdmsgs.cc + bdmsgs.h + bdnode.cc + bdnode.h + bdobj.cc + bdobj.h + bdpeer.cc + bdpeer.h + bdquery.cc + bdquery.h + bdquerymgr.cc + bdquerymgr.h + bdstddht.cc + bdstddht.h + bdstore.cc + bdstore.h + bencode.c + bencode.h +) diff --git a/src/udp/CMakeLists.txt b/src/udp/CMakeLists.txt new file mode 100644 index 0000000..7f4c3f5 --- /dev/null +++ b/src/udp/CMakeLists.txt @@ -0,0 +1,29 @@ +# ------------------------------------------------------------------------ *\ +# src/udp/CMakeLists.txt +# This file is part of BitDHT +# +# Copyright (C) 2026 David Bears +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . +# ------------------------------------------------------------------------ */ + +target_sources(${PROJECT_NAME} PRIVATE + udpbitdht.cc + udpbitdht.h + udplayer.cc + udplayer.h + udpproxylayer.h + udpstack.cc + udpstack.h +) diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt new file mode 100644 index 0000000..0d1516f --- /dev/null +++ b/src/util/CMakeLists.txt @@ -0,0 +1,34 @@ +# ------------------------------------------------------------------------ *\ +# src/util/CMakeLists.txt +# This file is part of BitDHT +# +# Copyright (C) 2026 David Bears +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . +# ------------------------------------------------------------------------ */ + +target_sources(${PROJECT_NAME} PRIVATE + bdbloom.cc + bdbloom.h + bdfile.cc + bdfile.h + bdnet.cc + bdnet.h + bdrandom.cc + bdrandom.h + bdstring.cc + bdstring.h + bdthreads.cc + bdthreads.h +)