2015-01-09 09:07:59 -05:00
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
include_directories(${CMAKE_SOURCE_DIR}/src/)
|
2016-08-24 15:45:03 -04:00
|
|
|
include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/lib/libevent/include)
|
|
|
|
include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/lib/polarssl/include)
|
2015-01-09 09:07:59 -05:00
|
|
|
|
|
|
|
add_definitions(-DTEST_GLOBALS=1)
|
2015-01-17 17:33:59 -05:00
|
|
|
|
|
|
|
# Create a single Network library that contains all the networking code:
|
2015-01-18 05:57:16 -05:00
|
|
|
set (Network_SRCS
|
2015-01-12 09:45:30 -05:00
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/CriticalSection.cpp
|
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/Event.cpp
|
2015-01-18 05:57:16 -05:00
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/HostnameLookup.cpp
|
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/IPLookup.cpp
|
2017-06-15 05:03:49 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/IsThread.cpp
|
2016-03-13 13:12:33 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/NetworkInterfaceEnum.cpp
|
2017-06-15 05:03:49 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/NetworkLookup.cpp
|
2015-01-17 17:33:59 -05:00
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/NetworkSingleton.cpp
|
2015-01-18 05:57:16 -05:00
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/ServerHandleImpl.cpp
|
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/TCPLinkImpl.cpp
|
2016-08-22 13:53:34 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/src/PolarSSL++/CtrDrbgContext.cpp
|
|
|
|
${CMAKE_SOURCE_DIR}/src/PolarSSL++/CryptoKey.cpp
|
|
|
|
${CMAKE_SOURCE_DIR}/src/PolarSSL++/EntropyContext.cpp
|
|
|
|
${CMAKE_SOURCE_DIR}/src/PolarSSL++/SslContext.cpp
|
|
|
|
${CMAKE_SOURCE_DIR}/src/PolarSSL++/X509Cert.cpp
|
2015-01-12 09:45:30 -05:00
|
|
|
${CMAKE_SOURCE_DIR}/src/StringUtils.cpp
|
|
|
|
)
|
|
|
|
|
2015-01-18 05:57:16 -05:00
|
|
|
set (Network_HDRS
|
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/CriticalSection.h
|
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/Event.h
|
2017-06-15 05:03:49 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/GetAddressInfoError.h
|
2015-01-18 05:57:16 -05:00
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/HostnameLookup.h
|
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/IPLookup.h
|
2017-06-15 05:03:49 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/IsThread.h
|
2015-01-18 05:57:16 -05:00
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/Network.h
|
2017-06-15 05:03:49 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/NetworkLookup.h
|
2015-01-18 05:57:16 -05:00
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/NetworkSingleton.h
|
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/ServerHandleImpl.h
|
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/TCPLinkImpl.h
|
2017-06-15 05:03:49 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/src/OSSupport/Queue.h
|
2016-08-22 13:53:34 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/src/PolarSSL++/CtrDrbgContext.h
|
|
|
|
${CMAKE_SOURCE_DIR}/src/PolarSSL++/CryptoKey.h
|
|
|
|
${CMAKE_SOURCE_DIR}/src/PolarSSL++/EntropyContext.h
|
|
|
|
${CMAKE_SOURCE_DIR}/src/PolarSSL++/SslContext.h
|
|
|
|
${CMAKE_SOURCE_DIR}/src/PolarSSL++/X509Cert.h
|
2015-01-18 05:57:16 -05:00
|
|
|
${CMAKE_SOURCE_DIR}/src/StringUtils.h
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(Network
|
|
|
|
${Network_SRCS}
|
|
|
|
${Network_HDRS}
|
|
|
|
)
|
|
|
|
|
2016-08-22 13:53:34 -04:00
|
|
|
target_link_libraries(Network event_core event_extra mbedtls)
|
2015-01-11 05:21:18 -05:00
|
|
|
if (MSVC)
|
|
|
|
target_link_libraries(Network ws2_32.lib)
|
|
|
|
endif()
|
2015-01-09 09:07:59 -05:00
|
|
|
|
2016-08-24 15:45:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-17 17:33:59 -05:00
|
|
|
|
|
|
|
# Define individual tests:
|
|
|
|
|
|
|
|
# Google: download the google.com frontpage using http client socket:
|
2015-01-09 09:07:59 -05:00
|
|
|
add_executable(Google-exe Google.cpp)
|
|
|
|
target_link_libraries(Google-exe Network)
|
|
|
|
add_test(NAME Google-test COMMAND Google-exe)
|
2015-01-11 05:21:18 -05:00
|
|
|
|
2015-01-17 17:33:59 -05:00
|
|
|
# EchoServer: Listen on port 9876, echo everything back:
|
2015-01-11 05:21:18 -05:00
|
|
|
add_executable(EchoServer EchoServer.cpp)
|
|
|
|
target_link_libraries(EchoServer Network)
|
|
|
|
|
2015-01-17 17:33:59 -05:00
|
|
|
# NameLookup: Lookup hostname-to-IP and IP-to-hostname:
|
2015-01-11 05:21:18 -05:00
|
|
|
add_executable(NameLookup NameLookup.cpp)
|
|
|
|
target_link_libraries(NameLookup Network)
|
2016-03-13 13:12:33 -04:00
|
|
|
|
|
|
|
# EnumInterfaces: List all network interfaces:
|
|
|
|
add_executable(EnumInterfaces-exe EnumInterfaces.cpp)
|
|
|
|
target_link_libraries(EnumInterfaces-exe Network)
|
|
|
|
add_test(NAME EnumInterfaces-test COMMAND EnumInterfaces-exe)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Put all the tests into a solution folder (MSVC):
|
|
|
|
set_target_properties(
|
|
|
|
EchoServer
|
|
|
|
Google-exe
|
|
|
|
NameLookup
|
|
|
|
EnumInterfaces-exe
|
2016-03-13 13:22:35 -04:00
|
|
|
PROPERTIES FOLDER Tests/Network
|
|
|
|
)
|
|
|
|
set_target_properties(
|
|
|
|
Network
|
|
|
|
PROPERTIES FOLDER Lib
|
2016-03-13 13:12:33 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|