Skip to content

Commit

Permalink
copy and adopt toxcore cmake from tomato
Browse files Browse the repository at this point in the history
  • Loading branch information
Green-Sky committed Jan 12, 2025
1 parent 9bd8bf2 commit 8128d92
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 187 deletions.
2 changes: 1 addition & 1 deletion external/totato
235 changes: 50 additions & 185 deletions external/toxcore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,215 +1,80 @@
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
cmake_minimum_required(VERSION 3.13...3.16 FATAL_ERROR)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(EXPERIMENTAL_API ON CACHE BOOL "" FORCE)
set(UNITTEST OFF CACHE BOOL "" FORCE)
set(BOOTSTRAP_DAEMON OFF CACHE BOOL "" FORCE)
#if (TOMATO_TOX_AV)
# set(BUILD_TOXAV ON CACHE BOOL "" FORCE)
# set(MUST_BUILD_TOXAV ON CACHE BOOL "" FORCE)
#endif()

set(TOX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/c-toxcore/")
add_subdirectory(./c-toxcore)

# TODO: shared
add_library(toxcore STATIC
${TOX_DIR}third_party/cmp/cmp.c
${TOX_DIR}third_party/cmp/cmp.h
#message("II BUILD_TOXAV: ${BUILD_TOXAV}")

${TOX_DIR}toxcore/announce.c
${TOX_DIR}toxcore/announce.h
${TOX_DIR}toxcore/bin_pack.c
${TOX_DIR}toxcore/bin_pack.h
${TOX_DIR}toxcore/bin_unpack.c
${TOX_DIR}toxcore/bin_unpack.h
${TOX_DIR}toxcore/ccompat.c
${TOX_DIR}toxcore/ccompat.h
${TOX_DIR}toxcore/crypto_core.c
${TOX_DIR}toxcore/crypto_core.h
${TOX_DIR}toxcore/crypto_core_pack.c
${TOX_DIR}toxcore/crypto_core_pack.h
${TOX_DIR}toxcore/DHT.c
${TOX_DIR}toxcore/DHT.h
${TOX_DIR}toxcore/events/conference_connected.c
${TOX_DIR}toxcore/events/conference_invite.c
${TOX_DIR}toxcore/events/conference_message.c
${TOX_DIR}toxcore/events/conference_peer_list_changed.c
${TOX_DIR}toxcore/events/conference_peer_name.c
${TOX_DIR}toxcore/events/conference_title.c
${TOX_DIR}toxcore/events/dht_get_nodes_response.c
${TOX_DIR}toxcore/events/events_alloc.c
${TOX_DIR}toxcore/events/events_alloc.h
${TOX_DIR}toxcore/events/file_chunk_request.c
${TOX_DIR}toxcore/events/file_recv.c
${TOX_DIR}toxcore/events/file_recv_chunk.c
${TOX_DIR}toxcore/events/file_recv_control.c
${TOX_DIR}toxcore/events/friend_connection_status.c
${TOX_DIR}toxcore/events/friend_lossless_packet.c
${TOX_DIR}toxcore/events/friend_lossy_packet.c
${TOX_DIR}toxcore/events/friend_message.c
${TOX_DIR}toxcore/events/friend_name.c
${TOX_DIR}toxcore/events/friend_read_receipt.c
${TOX_DIR}toxcore/events/friend_request.c
${TOX_DIR}toxcore/events/friend_status.c
${TOX_DIR}toxcore/events/friend_status_message.c
${TOX_DIR}toxcore/events/friend_typing.c
${TOX_DIR}toxcore/events/self_connection_status.c
${TOX_DIR}toxcore/events/group_custom_packet.c
${TOX_DIR}toxcore/events/group_custom_private_packet.c
${TOX_DIR}toxcore/events/group_invite.c
${TOX_DIR}toxcore/events/group_join_fail.c
${TOX_DIR}toxcore/events/group_message.c
${TOX_DIR}toxcore/events/group_moderation.c
${TOX_DIR}toxcore/events/group_password.c
${TOX_DIR}toxcore/events/group_peer_exit.c
${TOX_DIR}toxcore/events/group_peer_join.c
${TOX_DIR}toxcore/events/group_peer_limit.c
${TOX_DIR}toxcore/events/group_peer_name.c
${TOX_DIR}toxcore/events/group_peer_status.c
${TOX_DIR}toxcore/events/group_privacy_state.c
${TOX_DIR}toxcore/events/group_private_message.c
${TOX_DIR}toxcore/events/group_self_join.c
${TOX_DIR}toxcore/events/group_topic.c
${TOX_DIR}toxcore/events/group_topic_lock.c
${TOX_DIR}toxcore/events/group_voice_state.c
${TOX_DIR}toxcore/forwarding.c
${TOX_DIR}toxcore/forwarding.h
${TOX_DIR}toxcore/friend_connection.c
${TOX_DIR}toxcore/friend_connection.h
${TOX_DIR}toxcore/friend_requests.c
${TOX_DIR}toxcore/friend_requests.h
${TOX_DIR}toxcore/group.c
${TOX_DIR}toxcore/group.h
${TOX_DIR}toxcore/group_announce.c
${TOX_DIR}toxcore/group_announce.h
${TOX_DIR}toxcore/group_moderation.c
${TOX_DIR}toxcore/group_moderation.h
${TOX_DIR}toxcore/group_chats.c
${TOX_DIR}toxcore/group_chats.h
${TOX_DIR}toxcore/group_common.h
${TOX_DIR}toxcore/group_connection.c
${TOX_DIR}toxcore/group_connection.h
${TOX_DIR}toxcore/group_onion_announce.c
${TOX_DIR}toxcore/group_onion_announce.h
${TOX_DIR}toxcore/group_pack.c
${TOX_DIR}toxcore/group_pack.h
${TOX_DIR}toxcore/LAN_discovery.c
${TOX_DIR}toxcore/LAN_discovery.h
${TOX_DIR}toxcore/list.c
${TOX_DIR}toxcore/list.h
${TOX_DIR}toxcore/logger.c
${TOX_DIR}toxcore/logger.h
${TOX_DIR}toxcore/Messenger.c
${TOX_DIR}toxcore/Messenger.h
${TOX_DIR}toxcore/mem.c
${TOX_DIR}toxcore/mem.h
${TOX_DIR}toxcore/mono_time.c
${TOX_DIR}toxcore/mono_time.h
${TOX_DIR}toxcore/net_crypto.c
${TOX_DIR}toxcore/net_crypto.h
${TOX_DIR}toxcore/network.c
${TOX_DIR}toxcore/network.h
${TOX_DIR}toxcore/onion_announce.c
${TOX_DIR}toxcore/onion_announce.h
${TOX_DIR}toxcore/onion.c
${TOX_DIR}toxcore/onion_client.c
${TOX_DIR}toxcore/onion_client.h
${TOX_DIR}toxcore/onion.h
${TOX_DIR}toxcore/ping_array.c
${TOX_DIR}toxcore/ping_array.h
${TOX_DIR}toxcore/ping.c
${TOX_DIR}toxcore/ping.h
${TOX_DIR}toxcore/shared_key_cache.c
${TOX_DIR}toxcore/shared_key_cache.h
${TOX_DIR}toxcore/state.c
${TOX_DIR}toxcore/state.h
${TOX_DIR}toxcore/TCP_client.c
${TOX_DIR}toxcore/TCP_client.h
${TOX_DIR}toxcore/TCP_common.c
${TOX_DIR}toxcore/TCP_common.h
${TOX_DIR}toxcore/TCP_connection.c
${TOX_DIR}toxcore/TCP_connection.h
${TOX_DIR}toxcore/TCP_server.c
${TOX_DIR}toxcore/TCP_server.h
${TOX_DIR}toxcore/timed_auth.c
${TOX_DIR}toxcore/timed_auth.h
${TOX_DIR}toxcore/tox_api.c
${TOX_DIR}toxcore/tox.c
${TOX_DIR}toxcore/tox_dispatch.c
${TOX_DIR}toxcore/tox_dispatch.h
${TOX_DIR}toxcore/tox_event.c
${TOX_DIR}toxcore/tox_event.h
${TOX_DIR}toxcore/tox_events.c
${TOX_DIR}toxcore/tox_events.h
${TOX_DIR}toxcore/tox.h
${TOX_DIR}toxcore/tox_private.c
${TOX_DIR}toxcore/tox_private.h
${TOX_DIR}toxcore/tox_pack.c
${TOX_DIR}toxcore/tox_pack.h
${TOX_DIR}toxcore/tox_unpack.c
${TOX_DIR}toxcore/tox_unpack.h
${TOX_DIR}toxcore/util.c
${TOX_DIR}toxcore/util.h
# the sad case
add_library(toxcore INTERFACE)

${TOX_DIR}toxencryptsave/defines.h
${TOX_DIR}toxencryptsave/toxencryptsave.c
${TOX_DIR}toxencryptsave/toxencryptsave.h
)
if (TARGET toxcore_static)
target_link_libraries(toxcore INTERFACE toxcore_static)

# HACK: "install" api headers into self
# this is dirty, should be binary dir
# TODO: add the others
# the ideal case
#add_library(toxcore ALIAS toxcore_static)
else()
target_link_libraries(toxcore INTERFACE toxcore_shared)

# the ideal case
#add_library(toxcore ALIAS toxcore_shared)
endif()

# HACK: "install" api headers into binary dir
configure_file(
./c-toxcore/toxcore/tox.h
${CMAKE_CURRENT_BINARY_DIR}/include/tox/tox.h
@ONLY
)
configure_file(
${TOX_DIR}toxcore/tox.h
${TOX_DIR}tox/tox.h
./c-toxcore/toxcore/tox_events.h
${CMAKE_CURRENT_BINARY_DIR}/include/tox/tox_events.h
@ONLY
)
configure_file(
${TOX_DIR}toxcore/tox_events.h
${TOX_DIR}tox/tox_events.h
./c-toxcore/toxcore/tox_private.h
${CMAKE_CURRENT_BINARY_DIR}/include/tox/tox_private.h
@ONLY
)
configure_file(
${TOX_DIR}toxcore/tox_private.h
${TOX_DIR}tox/tox_private.h
./c-toxcore/toxencryptsave/toxencryptsave.h
${CMAKE_CURRENT_BINARY_DIR}/include/tox/toxencryptsave.h
@ONLY
)
#configure_file(
# ./c-toxcore/toxav/toxav.h
# ${CMAKE_CURRENT_BINARY_DIR}/include/tox/toxav.h
# @ONLY
#)

target_include_directories(toxcore PRIVATE "${TOX_DIR}toxcore")
target_include_directories(toxcore PUBLIC "${TOX_DIR}")
target_include_directories(toxcore INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/include/)

target_compile_definitions(toxcore PUBLIC USE_IPV6=1)
#target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_DEBUG)
target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_INFO)
# HACK: support old libsodium find
# libs should handle this case themselfs
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

find_package(unofficial-sodium CONFIG QUIET)
find_package(sodium QUIET)
if(unofficial-sodium_FOUND) # vcpkg
if(TARGET unofficial-sodium::sodium)
target_link_libraries(toxcore unofficial-sodium::sodium)
target_link_libraries(toxcore INTERFACE unofficial-sodium::sodium)
endif()
if(TARGET unofficial-sodium::sodium_config_public)
target_link_libraries(toxcore unofficial-sodium::sodium_config_public)
target_link_libraries(toxcore INTERFACE unofficial-sodium::sodium_config_public)
endif()
elseif(sodium_FOUND)
target_link_libraries(toxcore sodium)
target_link_libraries(toxcore INTERFACE sodium)
else()
message(SEND_ERROR "missing libsodium")
endif()

if(WIN32)
target_link_libraries(toxcore ws2_32 iphlpapi)
endif()

find_package(pthreads QUIET)
if(TARGET PThreads4W::PThreads4W)
target_link_libraries(toxcore PThreads4W::PThreads4W)
else()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(toxcore Threads::Threads)
endif()

add_executable(DHT_Bootstrap EXCLUDE_FROM_ALL
${TOX_DIR}other/DHT_bootstrap.c
${TOX_DIR}other/bootstrap_node_packets.h
${TOX_DIR}other/bootstrap_node_packets.c
${TOX_DIR}testing/misc_tools.h
${TOX_DIR}testing/misc_tools.c
)

target_link_libraries(DHT_Bootstrap toxcore)
#if(BUILD_TOXAV)
# set_target_properties(toxcore PROPERTIES TOX_HAS_TOXAV ON)
#endif()

2 changes: 1 addition & 1 deletion external/toxcore/c-toxcore
Submodule c-toxcore updated 95 files
+24 −56 .circleci/config.yml
+9 −3 .cirrus.yml
+12 −0 .github/workflows/checks.yml
+20 −23 .github/workflows/ci.yml
+37 −16 CMakeLists.txt
+15 −0 CMakePresets.json
+1 −0 auto_tests/BUILD.bazel
+10 −3 auto_tests/CMakeLists.txt
+16 −16 auto_tests/TCP_test.c
+1 −1 auto_tests/announce_test.c
+34 −18 auto_tests/crypto_test.c
+2 −22 auto_tests/encryptsave_test.c
+1 −1 auto_tests/forwarding_test.c
+56 −18 auto_tests/friend_request_test.c
+7 −4 auto_tests/network_test.c
+13 −13 auto_tests/onion_test.c
+16 −6 azure-pipelines.yml
+21 −2 cmake/Dependencies.cmake
+0 −87 conanfile.py
+5 −0 other/BUILD.bazel
+9 −6 other/DHT_bootstrap.c
+2 −2 other/analysis/gen-file.sh
+8 −0 other/bootstrap_daemon/BUILD.bazel
+4 −1 other/bootstrap_daemon/src/config.c
+5 −4 other/bootstrap_daemon/src/tox-bootstrapd.c
+4 −4 other/docker/circleci/Dockerfile
+2 −2 other/docker/circleci/entrypoint.sh
+9 −1 other/docker/circleci/run
+1 −0 other/docker/esp32/BUILD.bazel
+10 −5 other/docker/modules/check
+1 −0 other/docker/modules/modules.Dockerfile
+1 −0 super_donators/BUILD.bazel
+0 −1 testing/BUILD.bazel
+6 −10 testing/CMakeLists.txt
+0 −4 testing/Makefile.inc
+4 −1 testing/Messenger_test.c
+3 −0 testing/fuzzing/BUILD.bazel
+10 −0 testing/fuzzing/fuzz_support.cc
+0 −59 testing/misc_tools.c
+1 −1 third_party/cmp
+69 −5 toxcore/BUILD.bazel
+115 −69 toxcore/DHT.c
+4 −3 toxcore/DHT.h
+7 −3 toxcore/DHT_fuzz_test.cc
+9 −8 toxcore/DHT_test.cc
+2 −0 toxcore/Makefile.inc
+1 −1 toxcore/Messenger.c
+2 −0 toxcore/Messenger.h
+6 −6 toxcore/TCP_client.c
+2 −2 toxcore/TCP_common.c
+2 −2 toxcore/TCP_server.c
+2 −2 toxcore/announce.c
+33 −27 toxcore/crypto_core.c
+9 −4 toxcore/crypto_core.h
+33 −1 toxcore/crypto_core_test.cc
+8 −2 toxcore/forwarding_fuzz_test.cc
+4 −0 toxcore/friend_connection.c
+2 −1 toxcore/friend_requests.h
+62 −9 toxcore/group.c
+5 −3 toxcore/group_announce_fuzz_test.cc
+2 −1 toxcore/group_announce_test.cc
+15 −14 toxcore/group_chats.c
+3 −2 toxcore/group_chats.h
+1 −1 toxcore/group_common.h
+1 −1 toxcore/group_connection.c
+1 −1 toxcore/group_moderation_test.cc
+3 −2 toxcore/group_onion_announce.c
+2 −1 toxcore/group_onion_announce.h
+19 −47 toxcore/logger.c
+3 −1 toxcore/logger.h
+17 −17 toxcore/net_crypto.c
+164 −67 toxcore/network.c
+25 −14 toxcore/network.h
+11 −4 toxcore/network_test_util.cc
+6 −2 toxcore/network_test_util.hh
+16 −16 toxcore/onion.c
+2 −2 toxcore/onion.h
+88 −45 toxcore/onion_announce.c
+4 −4 toxcore/onion_announce.h
+91 −48 toxcore/onion_client.c
+2 −0 toxcore/onion_client.h
+6 −4 toxcore/ping.c
+182 −0 toxcore/sort.c
+116 −0 toxcore/sort.h
+140 −0 toxcore/sort_bench.cc
+79 −0 toxcore/sort_test.cc
+32 −0 toxcore/sort_test_util.cc
+54 −0 toxcore/sort_test_util.hh
+5 −2 toxcore/tox.c
+23 −1 toxcore/tox.h
+9 −0 toxcore/tox_api.c
+1 −1 toxcore/tox_private.c
+2 −1 toxcore/util.c
+4 −29 toxcore/util_test.cc
+2 −2 toxencryptsave/toxencryptsave.c

0 comments on commit 8128d92

Please sign in to comment.