From c3a7d1521a4852f863a3839554b12ba27eb3e594 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Thu, 25 Apr 2024 17:41:25 +0200 Subject: [PATCH] switched from own cmake to toxcore provided cmake --- .github/workflows/cd.yml | 8 +- .github/workflows/ci.yml | 4 +- external/toxcore/CMakeLists.txt | 250 +++++++------------------------- src/tox_client.cpp | 2 +- 4 files changed, 56 insertions(+), 208 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 1eb41764..436de0d8 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -68,7 +68,7 @@ jobs: submodules: recursive - name: Install Dependencies - run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static + run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows # setup vs env - uses: ilammy/msvc-dev-cmd@v1 @@ -79,7 +79,7 @@ jobs: #- uses: ilammy/setup-nasm@v1 - name: Configure CMake - run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF + run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} @@ -122,7 +122,7 @@ jobs: submodules: recursive - name: Install Dependencies - run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static + run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows # setup vs env - uses: ilammy/msvc-dev-cmd@v1 @@ -133,7 +133,7 @@ jobs: #- uses: ilammy/setup-nasm@v1 - name: Configure CMake - run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF + run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34a1608a..e13674ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: submodules: recursive - name: Install Dependencies - run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static + run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows # setup vs env - uses: ilammy/msvc-dev-cmd@v1 @@ -70,7 +70,7 @@ jobs: #- uses: ilammy/setup-nasm@v1 - name: Configure CMake - run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF + run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 diff --git a/external/toxcore/CMakeLists.txt b/external/toxcore/CMakeLists.txt index 4887bb2f..6cb26daa 100644 --- a/external/toxcore/CMakeLists.txt +++ b/external/toxcore/CMakeLists.txt @@ -1,214 +1,62 @@ -cmake_minimum_required(VERSION 3.9 FATAL_ERROR) +cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR) +set(EXPERIMENTAL_API ON CACHE BOOL "" FORCE) +set(UNITTEST OFF CACHE BOOL "" FORCE) +set(BOOTSTRAP_DAEMON OFF CACHE BOOL "" FORCE) + +add_subdirectory(./c-toxcore) + +# the ideal case +#add_library(toxcore ALIAS toxcore_static) + +# the sad case +add_library(toxcore INTERFACE) + +target_link_libraries(toxcore INTERFACE toxcore_static) + +# 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( + ./c-toxcore/toxcore/tox_events.h + ${CMAKE_CURRENT_BINARY_DIR}/include/tox/tox_events.h + @ONLY +) +configure_file( + ./c-toxcore/toxcore/tox_private.h + ${CMAKE_CURRENT_BINARY_DIR}/include/tox/tox_private.h + @ONLY +) +configure_file( + ./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 INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/include/) + +# HACK: support old libsodium find +# libs should handle this case themselfs list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -set(TOX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/c-toxcore/") - -# TODO: shared -add_library(toxcore STATIC - ${TOX_DIR}third_party/cmp/cmp.c - ${TOX_DIR}third_party/cmp/cmp.h - - ${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.h - ${TOX_DIR}toxcore/tox_pack.c - ${TOX_DIR}toxcore/tox_unpack.c - ${TOX_DIR}toxcore/tox_unpack.h - ${TOX_DIR}toxcore/util.c - ${TOX_DIR}toxcore/util.h - - ${TOX_DIR}toxencryptsave/defines.h - ${TOX_DIR}toxencryptsave/toxencryptsave.c - ${TOX_DIR}toxencryptsave/toxencryptsave.h -) - -# HACK: "install" api headers into self -# this is dirty, should be binary dir -# TODO: add the others -configure_file( - ${TOX_DIR}toxcore/tox.h - ${TOX_DIR}tox/tox.h - @ONLY -) -configure_file( - ${TOX_DIR}toxcore/tox_events.h - ${TOX_DIR}tox/tox_events.h - @ONLY -) -configure_file( - ${TOX_DIR}toxcore/tox_private.h - ${TOX_DIR}tox/tox_private.h - @ONLY -) - -target_include_directories(toxcore PRIVATE "${TOX_DIR}toxcore") -target_include_directories(toxcore PUBLIC "${TOX_DIR}") - -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) - -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) - diff --git a/src/tox_client.cpp b/src/tox_client.cpp index dec854bd..dd4e6b0f 100644 --- a/src/tox_client.cpp +++ b/src/tox_client.cpp @@ -3,7 +3,7 @@ // meh, change this #include #include -#include +#include #include