Squashed 'external/toxcore/c-toxcore/' changes from e29e185c03..f1df709b87
f1df709b87 feat: add ngc events 1b6c907235 refactor: Make event dispatch ordered by receive time. b7f9367f6f test: Upgrade cppcheck, fix some warnings. 766e62bc89 chore: Use `pkg_search_module` directly in cmake. 00ff078f91 cleanup: Use target_link_libraries directly in cmake. c58928cc89 chore: Add `IMPORTED_TARGET` to pkg-config packages. 895a6af122 cleanup: Remove NaCl support. 41dfb1c1c0 fix: unpack enum function names in event impl generator 447666d1a1 chore: Disable targets for cross-compilation. 572924e924 chore: Build a docker image with coverage info in it. 415cb78f5e cleanup: Some portability/warning fixes for Windows builds. 425216d9ec fix: Correct a use-after-free and fix some memory leaks. 4b1cfa3e08 refactor: Change all enum-like `#define` sequences into enums. d3c2704fa9 chore: Fix make_single_file to support core-only. 0ce46b644e refactor: Change the `TCP_PACKET_*` defines into an enum. 22cd38ad50 adopt event impl generation tool to #2392 f31ea1088a add the event impl generation tool 4e603bb613 refactor: Use `enum-from-int` rule from tokstyle. 19d8f180d6 chore: Update github actions `uses`. 6a895be0c7 test: Make esp32 build actually try to instantiate tox. 65d09c9bfb cleanup: Remove test net support. REVERT: e29e185c03 feat: add ngc events git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: f1df709b8792da4c0e946d826b11df77d565064d
This commit is contained in:
@@ -14,8 +14,8 @@
|
||||
#
|
||||
################################################################################
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_policy(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
cmake_policy(VERSION 3.16)
|
||||
project(toxcore)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake)
|
||||
@@ -76,6 +76,7 @@ if(APPLE)
|
||||
endif()
|
||||
|
||||
enable_testing()
|
||||
find_package(GTest)
|
||||
|
||||
set(CMAKE_MACOSX_RPATH ON)
|
||||
|
||||
@@ -111,16 +112,11 @@ if(NOT USE_IPV6)
|
||||
add_definitions(-DUSE_IPV6=0)
|
||||
endif()
|
||||
|
||||
option(USE_TEST_NETWORK "Use a separate test network with different packet IDs" OFF)
|
||||
if(USE_TEST_NETWORK)
|
||||
add_definitions(-DUSE_TEST_NETWORK=1)
|
||||
endif()
|
||||
|
||||
option(BUILD_MISC_TESTS "Build additional tests and utilities" OFF)
|
||||
option(BUILD_FUN_UTILS "Build additional just for fun utilities" OFF)
|
||||
|
||||
option(AUTOTEST "Enable autotests (mainly for CI)" OFF)
|
||||
if (AUTOTEST)
|
||||
if(AUTOTEST)
|
||||
option(NON_HERMETIC_TESTS "Whether to build and run tests that depend on an internet connection" OFF)
|
||||
option(PROXY_TEST "Enable proxy test (needs HTTP/SOCKS5 proxy on port 8080/8081)" OFF)
|
||||
endif()
|
||||
@@ -320,6 +316,8 @@ set(toxcore_SOURCES
|
||||
toxcore/tox.c
|
||||
toxcore/tox_dispatch.c
|
||||
toxcore/tox_dispatch.h
|
||||
toxcore/tox_event.c
|
||||
toxcore/tox_event.h
|
||||
toxcore/tox_events.c
|
||||
toxcore/tox_events.h
|
||||
toxcore/tox.h
|
||||
@@ -329,7 +327,10 @@ set(toxcore_SOURCES
|
||||
toxcore/tox_unpack.h
|
||||
toxcore/util.c
|
||||
toxcore/util.h)
|
||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${LIBSODIUM_LIBRARIES})
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${LIBSODIUM_LIBRARIES})
|
||||
set(toxcore_LINK_DIRECTORIES ${toxcore_LINK_DIRECTORIES} ${LIBSODIUM_LIBRARY_DIRS})
|
||||
set(toxcore_INCLUDE_DIRECTORIES ${toxcore_INCLUDE_DIRECTORIES} ${LIBSODIUM_INCLUDE_DIRS})
|
||||
set(toxcore_COMPILE_OPTIONS ${toxcore_COMPILE_OPTIONS} ${LIBSODIUM_CFLAGS_OTHER})
|
||||
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} libsodium)
|
||||
set(toxcore_API_HEADERS
|
||||
${toxcore_SOURCE_DIR}/toxcore/tox.h^tox
|
||||
@@ -365,7 +366,10 @@ if(BUILD_TOXAV)
|
||||
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
|
||||
${toxcore_SOURCE_DIR}/toxav/toxav.h^toxav)
|
||||
|
||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
|
||||
set(toxcore_LINK_DIRECTORIES ${toxcore_LINK_DIRECTORIES} ${OPUS_LIBRARY_DIRS} ${VPX_LIBRARY_DIRS})
|
||||
set(toxcore_INCLUDE_DIRECTORIES ${toxcore_INCLUDE_DIRECTORIES} ${OPUS_INCLUDE_DIRS} ${VPX_INCLUDE_DIRS})
|
||||
set(toxcore_COMPILE_OPTIONS ${toxcore_COMPILE_OPTIONS} ${OPUS_CFLAGS_OTHER} ${VPX_CFLAGS_OTHER})
|
||||
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} opus vpx)
|
||||
endif()
|
||||
|
||||
@@ -392,28 +396,28 @@ set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
|
||||
# any potential libvpx linking.
|
||||
message("CMAKE_THREAD_LIBS_INIT: ${CMAKE_THREAD_LIBS_INIT}")
|
||||
if(CMAKE_THREAD_LIBS_INIT)
|
||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${CMAKE_THREAD_LIBS_INIT})
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
|
||||
if(NSL_LIBRARIES)
|
||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${NSL_LIBRARIES})
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${NSL_LIBRARIES})
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lnsl)
|
||||
endif()
|
||||
|
||||
if(RT_LIBRARIES)
|
||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${RT_LIBRARIES})
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${RT_LIBRARIES})
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lrt)
|
||||
endif()
|
||||
|
||||
if(SOCKET_LIBRARIES)
|
||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${SOCKET_LIBRARIES})
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${SOCKET_LIBRARIES})
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lsocket)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ws2_32 iphlpapi)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ws2_32 iphlpapi)
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lws2_32 -liphlpapi)
|
||||
endif()
|
||||
|
||||
@@ -427,7 +431,18 @@ endif()
|
||||
add_module(toxcore ${toxcore_SOURCES})
|
||||
|
||||
# Link it to all dependencies.
|
||||
target_link_modules(toxcore ${toxcore_LINK_MODULES})
|
||||
if(TARGET toxcore_static)
|
||||
target_link_libraries(toxcore_static PRIVATE ${toxcore_LINK_LIBRARIES})
|
||||
target_link_directories(toxcore_static PUBLIC ${toxcore_LINK_DIRECTORIES})
|
||||
target_include_directories(toxcore_static SYSTEM PRIVATE ${toxcore_INCLUDE_DIRECTORIES})
|
||||
target_compile_options(toxcore_static PRIVATE ${toxcore_COMPILE_OPTIONS})
|
||||
endif()
|
||||
if(TARGET toxcore_shared)
|
||||
target_link_libraries(toxcore_shared PRIVATE ${toxcore_LINK_LIBRARIES})
|
||||
target_link_directories(toxcore_shared PUBLIC ${toxcore_LINK_DIRECTORIES})
|
||||
target_include_directories(toxcore_shared SYSTEM PRIVATE ${toxcore_INCLUDE_DIRECTORIES})
|
||||
target_compile_options(toxcore_shared PRIVATE ${toxcore_COMPILE_OPTIONS})
|
||||
endif()
|
||||
|
||||
# Make version script (on systems that support it) to limit symbol visibility.
|
||||
make_version_script(toxcore ${toxcore_API_HEADERS})
|
||||
@@ -442,23 +457,36 @@ install_module(toxcore DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tox)
|
||||
#
|
||||
################################################################################
|
||||
|
||||
include(CompileGTest)
|
||||
function(unit_test subdir target)
|
||||
add_executable(unit_${target}_test ${subdir}/${target}_test.cc)
|
||||
if(TARGET toxcore_static)
|
||||
target_link_libraries(unit_${target}_test PRIVATE toxcore_static)
|
||||
else()
|
||||
target_link_libraries(unit_${target}_test PRIVATE toxcore_shared)
|
||||
endif()
|
||||
target_link_libraries(unit_${target}_test PRIVATE GTest::GTest GTest::Main)
|
||||
set_target_properties(unit_${target}_test PROPERTIES COMPILE_FLAGS "${TEST_CXX_FLAGS}")
|
||||
add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target}_test)
|
||||
set_property(TEST ${target} PROPERTY ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw")
|
||||
endfunction()
|
||||
|
||||
# The actual unit tests follow.
|
||||
#
|
||||
unit_test(toxav ring_buffer)
|
||||
unit_test(toxav rtp)
|
||||
unit_test(toxcore DHT)
|
||||
unit_test(toxcore bin_pack)
|
||||
unit_test(toxcore crypto_core)
|
||||
unit_test(toxcore group_announce)
|
||||
unit_test(toxcore group_moderation)
|
||||
unit_test(toxcore list)
|
||||
unit_test(toxcore mem)
|
||||
unit_test(toxcore mono_time)
|
||||
unit_test(toxcore ping_array)
|
||||
unit_test(toxcore tox)
|
||||
unit_test(toxcore util)
|
||||
if(GTEST_FOUND)
|
||||
unit_test(toxav ring_buffer)
|
||||
unit_test(toxav rtp)
|
||||
unit_test(toxcore DHT)
|
||||
unit_test(toxcore bin_pack)
|
||||
unit_test(toxcore crypto_core)
|
||||
unit_test(toxcore group_announce)
|
||||
unit_test(toxcore group_moderation)
|
||||
unit_test(toxcore list)
|
||||
unit_test(toxcore mem)
|
||||
unit_test(toxcore mono_time)
|
||||
unit_test(toxcore ping_array)
|
||||
unit_test(toxcore tox)
|
||||
unit_test(toxcore util)
|
||||
endif()
|
||||
|
||||
add_subdirectory(testing)
|
||||
|
||||
@@ -482,7 +510,12 @@ if(DHT_BOOTSTRAP)
|
||||
add_executable(DHT_bootstrap
|
||||
other/DHT_bootstrap.c
|
||||
other/bootstrap_node_packets.c)
|
||||
target_link_modules(DHT_bootstrap toxcore misc_tools)
|
||||
if(TARGET toxcore_static)
|
||||
target_link_libraries(DHT_bootstrap PRIVATE toxcore_static)
|
||||
else()
|
||||
target_link_libraries(DHT_bootstrap PRIVATE toxcore_shared)
|
||||
endif()
|
||||
target_link_libraries(DHT_bootstrap PRIVATE misc_tools)
|
||||
install(TARGETS DHT_bootstrap RUNTIME DESTINATION bin)
|
||||
endif()
|
||||
|
||||
|
Reference in New Issue
Block a user