2018-12-31 20:04:05 +01:00
|
|
|
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
|
|
|
|
|
|
|
#SOURCE SETS
|
|
|
|
set(TD_TEST_SOURCE
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/db.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/http.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/mtproto.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/message_entities.cpp
|
2019-03-05 21:21:10 +01:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/poll.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/secret.cpp
|
2018-03-26 16:07:04 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/secure_storage.cpp
|
2019-01-18 17:39:19 +01:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/set_with_position.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/string_cleaning.cpp
|
2018-12-28 01:54:54 +01:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/tdclient.cpp
|
2020-06-11 15:43:26 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/tqueue.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/data.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/data.h
|
|
|
|
|
|
|
|
${TDUTILS_TEST_SOURCE}
|
|
|
|
${TDACTOR_TEST_SOURCE}
|
|
|
|
)
|
|
|
|
set(TD_TEST_SOURCE ${TD_TEST_SOURCE} PARENT_SCOPE)
|
|
|
|
|
|
|
|
set(TESTS_MAIN
|
|
|
|
main.cpp
|
|
|
|
)
|
|
|
|
|
2020-10-12 10:49:23 +02:00
|
|
|
#add_library(all_tests STATIC ${TD_TEST_SOURCE})
|
|
|
|
#target_include_directories(all_tests PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
|
|
|
#target_link_libraries(all_tests PRIVATE tdcore tdclient)
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
if (NOT CMAKE_CROSSCOMPILING OR EMSCRIPTEN)
|
|
|
|
#Tests
|
2021-02-25 12:57:50 +01:00
|
|
|
if (OPENSSL_FOUND)
|
|
|
|
add_executable(test-crypto EXCLUDE_FROM_ALL ${CMAKE_CURRENT_SOURCE_DIR}/crypto.cpp)
|
|
|
|
target_include_directories(test-crypto SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR})
|
|
|
|
target_link_libraries(test-crypto PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES} tdutils tdcore)
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
if (MINGW)
|
|
|
|
target_link_libraries(test-crypto PRIVATE ws2_32 mswsock crypt32)
|
|
|
|
else()
|
|
|
|
target_link_libraries(test-crypto PRIVATE ws2_32 Mswsock Crypt32)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-10-12 10:49:23 +02:00
|
|
|
add_executable(test-tdutils EXCLUDE_FROM_ALL ${TESTS_MAIN} ${TDUTILS_TEST_SOURCE})
|
2020-11-26 15:49:51 +01:00
|
|
|
add_executable(test-online EXCLUDE_FROM_ALL online.cpp)
|
2018-12-31 20:04:05 +01:00
|
|
|
add_executable(run_all_tests ${TESTS_MAIN} ${TD_TEST_SOURCE})
|
2021-04-30 00:48:01 +02:00
|
|
|
if (CLANG AND NOT CYGWIN AND NOT EMSCRIPTEN AND NOT (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") AND NOT (CMAKE_SIZEOF_VOID_P EQUAL 4))
|
2020-10-09 16:35:53 +02:00
|
|
|
target_compile_options(test-tdutils PUBLIC -fsanitize=undefined -fno-sanitize=vptr)
|
2018-12-31 20:04:05 +01:00
|
|
|
target_compile_options(run_all_tests PUBLIC -fsanitize=undefined -fno-sanitize=vptr)
|
2020-11-26 15:49:51 +01:00
|
|
|
target_compile_options(test-online PUBLIC -fsanitize=undefined -fno-sanitize=vptr)
|
2018-12-31 20:04:05 +01:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fno-sanitize=vptr")
|
|
|
|
endif()
|
|
|
|
target_include_directories(run_all_tests PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
2020-10-09 16:35:53 +02:00
|
|
|
target_include_directories(test-tdutils PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
|
|
|
target_link_libraries(test-tdutils PRIVATE tdutils)
|
2020-02-23 23:29:51 +01:00
|
|
|
target_link_libraries(run_all_tests PRIVATE tdcore tdclient)
|
2020-11-26 15:49:51 +01:00
|
|
|
target_link_libraries(test-online PRIVATE tdcore tdclient tdutils tdactor)
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
if (CLANG)
|
|
|
|
# add_executable(fuzz_url fuzz_url.cpp)
|
2020-02-23 23:29:51 +01:00
|
|
|
# target_link_libraries(fuzz_url PRIVATE tdcore)
|
2018-12-31 20:04:05 +01:00
|
|
|
# target_compile_options(fuzz_url PRIVATE "-fsanitize-coverage=trace-pc-guard")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_test(run_all_tests run_all_tests)
|
|
|
|
endif()
|