This commit is contained in:
David Bears 2026-08-22 17:22:11 +00:00 committed by GitHub
commit 82d63e3d52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 286 additions and 15 deletions

View File

@ -1,28 +1,93 @@
# RetroShare decentralized communication platform
#
# Copyright (C) 2021-2022 Gioacchino Mazzurco <gio@retroshare.cc>
# Copyright (C) 2026 David Bears <dbear4q@gmail.com>
#
# 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" )
include(GNUInstallDirs)
set(BD_INSTALL_DATADIR "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}")
set(BD_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}")
file(
GLOB BITDHT_SOURCES
src/bitdht/*.c src/bitdht/*.cc src/udp/*.cc src/util/*.cc )
add_library(${PROJECT_NAME})
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
add_library(${PROJECT_NAME} ${BITDHT_SOURCES})
set(BD_BOOT_FILE "${PROJECT_SOURCE_DIR}/src/bitdht/bdboot.txt")
target_include_directories(
${PROJECT_NAME}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src )
if(WIN32)
target_compile_definitions(${PROJECT_NAME} 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(${PROJECT_NAME} PRIVATE
-Wno-error=incompatible-pointer-types
-Wno-error=int-conversion
-Wno-error=implicit-function-declaration
)
endif()
endif()
add_subdirectory(src)
### installation
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}_export
COMPONENT ${PROJECT_NAME}
FILE_SET HEADERS DESTINATION "${BD_INSTALL_INCLUDEDIR}"
)
install(
FILES src/bitdht/bdboot.txt
DESTINATION ${RS_DATA_DIR} )
FILES "${BD_BOOT_FILE}"
DESTINATION "${BD_INSTALL_DATADIR}"
COMPONENT ${PROJECT_NAME}
)
# config package for install tree
set(CONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
install(EXPORT ${PROJECT_NAME}_export
DESTINATION "${CONFIG_DIR}"
FILE ${PROJECT_NAME}-targets.cmake
NAMESPACE ${PROJECT_NAME}::
COMPONENT ${PROJECT_NAME}
)
include(CMakePackageConfigHelpers)
set(BD_INSTALL_BOOT_FILE "${BD_INSTALL_DATADIR}/bdboot.txt")
configure_package_config_file(mk/cmake/${PROJECT_NAME}-config.cmake.in
cmake/${PROJECT_NAME}-config_installed.cmake
INSTALL_DESTINATION "${CONFIG_DIR}"
PATH_VARS BD_INSTALL_BOOT_FILE
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}-config_installed.cmake"
DESTINATION "${CONFIG_DIR}"
RENAME ${PROJECT_NAME}-config.cmake
COMPONENT ${PROJECT_NAME}
)
# config package for build tree
export(EXPORT ${PROJECT_NAME}_export
FILE cmake/${PROJECT_NAME}-targets.cmake
NAMESPACE ${PROJECT_NAME}::
)
include(CMakePackageConfigHelpers)
set(PACKAGE_BD_INSTALL_BOOT_FILE "${BD_BOOT_FILE}")
configure_package_config_file(mk/cmake/${PROJECT_NAME}-config.cmake.in
cmake/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION cmake
)
# config package for CMAKE_FIND_PACKAGE_REDIRECTS_DIR
configure_file(
mk/cmake/${PROJECT_NAME}-config_redirects.cmake.in
"${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/${PROJECT_NAME}-config.cmake"
@ONLY
)

View File

@ -0,0 +1,27 @@
# ------------------------------------------------------------------------ *\
# mk/cmake/bitdht-config.cmake.in
# This file is part of BitDHT
#
# Copyright (C) 2026 David Bears <dbear4q@gmail.com>
#
# 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 <https://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------ */
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/bitdht-targets.cmake")
set_and_check(BD_BOOT_FILE "@PACKAGE_BD_INSTALL_BOOT_FILE@")
check_required_components("${CMAKE_FIND_PACKAGE_NAME}")

View File

@ -0,0 +1,24 @@
# ------------------------------------------------------------------------ *\
# mk/cmake/bitdht-config_redirects.cmake.in
# This file is part of BitDHT
#
# Copyright (C) 2026 David Bears <dbear4q@gmail.com>
#
# 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 <https://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------ */
set(BD_BOOT_FILE "@BD_BOOT_FILE@")
include("${CMAKE_CURRENT_LIST_DIR}/bitdht-extra.cmake" OPTIONAL)
include("${CMAKE_CURRENT_LIST_DIR}/bitdhtExtra.cmake" OPTIONAL)

28
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,28 @@
# ------------------------------------------------------------------------ *\
# src/CMakeLists.txt
# This file is part of BitDHT
#
# Copyright (C) 2026 David Bears <dbear4q@gmail.com>
#
# 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 <https://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------ */
target_sources(${PROJECT_NAME}
PUBLIC FILE_SET HEADERS
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
)
add_subdirectory(bitdht)
add_subdirectory(udp)
add_subdirectory(util)

58
src/bitdht/CMakeLists.txt Normal file
View File

@ -0,0 +1,58 @@
# ------------------------------------------------------------------------ *\
# src/bitdht/CMakeLists.txt
# This file is part of BitDHT
#
# Copyright (C) 2026 David Bears <dbear4q@gmail.com>
#
# 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 <https://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------ */
target_sources(${PROJECT_NAME}
PUBLIC FILE_SET HEADERS FILES
bdaccount.h
bdconnection.h
bdfilter.h
bdfriendlist.h
bdhash.h
bdhistory.h
bdiface.h
bdmanager.h
bdmsgs.h
bdnode.h
bdobj.h
bdpeer.h
bdquery.h
bdquerymgr.h
bdstddht.h
bdstore.h
bencode.h
PRIVATE
bdaccount.cc
bdconnection.cc
bdfilter.cc
bdfriendlist.cc
bdhash.cc
bdhistory.cc
bdmanager.cc
bdmsgs.cc
bdnode.cc
bdobj.cc
bdpeer.cc
bdquery.cc
bdquerymgr.cc
bdstddht.cc
bdstore.cc
bencode.c
)

32
src/udp/CMakeLists.txt Normal file
View File

@ -0,0 +1,32 @@
# ------------------------------------------------------------------------ *\
# src/udp/CMakeLists.txt
# This file is part of BitDHT
#
# Copyright (C) 2026 David Bears <dbear4q@gmail.com>
#
# 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 <https://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------ */
target_sources(${PROJECT_NAME} PRIVATE
PUBLIC FILE_SET HEADERS FILES
udpbitdht.h
udplayer.h
udpproxylayer.h
udpstack.h
PRIVATE
udpbitdht.cc
udplayer.cc
udpstack.cc
)

37
src/util/CMakeLists.txt Normal file
View File

@ -0,0 +1,37 @@
# ------------------------------------------------------------------------ *\
# src/util/CMakeLists.txt
# This file is part of BitDHT
#
# Copyright (C) 2026 David Bears <dbear4q@gmail.com>
#
# 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 <https://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------ */
target_sources(${PROJECT_NAME} PRIVATE
PUBLIC FILE_SET HEADERS FILES
bdbloom.h
bdfile.h
bdnet.h
bdrandom.h
bdstring.h
bdthreads.h
PRIVATE
bdbloom.cc
bdfile.cc
bdnet.cc
bdrandom.cc
bdstring.cc
bdthreads.cc
)