mirror of
https://github.com/RetroShare/BitDHT.git
synced 2026-09-14 11:05:44 +05:00
improve cmake build
- avoid globbing sources - move platform-dependent compile options for bitdht from other projects to this one - create an alias target for use by superproject - avoid messing with RS_DATA_DIR globally
This commit is contained in:
parent
4355ea96b2
commit
51aebb6ee3
@ -1,28 +1,55 @@
|
||||
# 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" )
|
||||
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}
|
||||
)
|
||||
|
||||
23
src/CMakeLists.txt
Normal file
23
src/CMakeLists.txt
Normal file
@ -0,0 +1,23 @@
|
||||
# ------------------------------------------------------------------------ *\
|
||||
# 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/>.
|
||||
# ------------------------------------------------------------------------ */
|
||||
|
||||
add_subdirectory(bitdht)
|
||||
add_subdirectory(udp)
|
||||
add_subdirectory(util)
|
||||
55
src/bitdht/CMakeLists.txt
Normal file
55
src/bitdht/CMakeLists.txt
Normal file
@ -0,0 +1,55 @@
|
||||
# ------------------------------------------------------------------------ *\
|
||||
# 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} 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
|
||||
)
|
||||
29
src/udp/CMakeLists.txt
Normal file
29
src/udp/CMakeLists.txt
Normal file
@ -0,0 +1,29 @@
|
||||
# ------------------------------------------------------------------------ *\
|
||||
# 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
|
||||
udpbitdht.cc
|
||||
udpbitdht.h
|
||||
udplayer.cc
|
||||
udplayer.h
|
||||
udpproxylayer.h
|
||||
udpstack.cc
|
||||
udpstack.h
|
||||
)
|
||||
34
src/util/CMakeLists.txt
Normal file
34
src/util/CMakeLists.txt
Normal file
@ -0,0 +1,34 @@
|
||||
# ------------------------------------------------------------------------ *\
|
||||
# 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
|
||||
bdbloom.cc
|
||||
bdbloom.h
|
||||
bdfile.cc
|
||||
bdfile.h
|
||||
bdnet.cc
|
||||
bdnet.h
|
||||
bdrandom.cc
|
||||
bdrandom.h
|
||||
bdstring.cc
|
||||
bdstring.h
|
||||
bdthreads.cc
|
||||
bdthreads.h
|
||||
)
|
||||
Loading…
Reference in New Issue
Block a user