diff --git a/CMakeLists.txt b/CMakeLists.txt index 74ae1598f81c6b6fc6708c1ba0474e34acf8a199..969acb22dd27331df6075f0247985e6cd3dbdb3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ enable_testing() set(THREADS_PREFER_PTHREAD_FLAG ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") +#include(Findglog) find_package( glog REQUIRED ) find_package( OpenCV REQUIRED ) find_package( Threads REQUIRED ) diff --git a/cmake/Findglog.cmake b/cmake/Findglog.cmake index b7ea41f92cbc8e4dcbf800d4162155673431031e..9079190dcb3d7aecd54ff029542af64b2f4bf5e1 100644 --- a/cmake/Findglog.cmake +++ b/cmake/Findglog.cmake @@ -5,6 +5,13 @@ if(WIN32) find_path(glog_DIR NAMES include/glog/logging.h PATHS "C:/Program Files/glog" "C:/Program Files/google-glog" "C:/Program Files (x86)/google-glog") set(glog_DIR ${glog_DIR}) + +find_package(glog QUIET PATHS "${glog_DIR}/lib/cmake" NO_DEFAULT_PATH) + +if (GLOG_FOUND) +return() +endif() + else() set(glog_DIR "") endif() diff --git a/net/cpp/CMakeLists.txt b/net/cpp/CMakeLists.txt index 7f7f63884865a3ec0acb946d4370112321238fa3..d6c361ca7d33db814cd79f8a7c67575afc00b101 100644 --- a/net/cpp/CMakeLists.txt +++ b/net/cpp/CMakeLists.txt @@ -17,7 +17,7 @@ target_include_directories(ftlnet PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> PRIVATE src) -target_link_libraries(ftlnet Threads::Threads glog::glog) +target_link_libraries(ftlnet Threads::Threads glog::glog ${UUID_LIBRARIES} ${URIPARSER_LIBRARIES}) install(TARGETS ftlnet EXPORT ftlnet-config ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/net/cpp/include/ftl/net/peer.hpp b/net/cpp/include/ftl/net/peer.hpp index 0de0b4ea2bce5d9fc5eab5706347314ce0accd9b..16cad5138518d010df7b64a8d5b27ad6b091e27d 100644 --- a/net/cpp/include/ftl/net/peer.hpp +++ b/net/cpp/include/ftl/net/peer.hpp @@ -1,13 +1,6 @@ #ifndef _FTL_NET_PEER_HPP_ #define _FTL_NET_PEER_HPP_ -#define GLOG_NO_ABBREVIATED_SEVERITIES -#include <glog/logging.h> -#include <ftl/net/protocol.hpp> -#include <ftl/net/dispatcher.hpp> -#include <ftl/uri.hpp> -#include <ftl/uuid.hpp> - #ifndef WIN32 #define INVALID_SOCKET -1 #include <netinet/in.h> @@ -15,6 +8,13 @@ #include <winsock2.h> #endif +#define GLOG_NO_ABBREVIATED_SEVERITIES +#include <glog/logging.h> +#include <ftl/net/protocol.hpp> +#include <ftl/net/dispatcher.hpp> +#include <ftl/uri.hpp> +#include <ftl/uuid.hpp> + #include <iostream> #include <sstream> #include <tuple> diff --git a/net/cpp/src/peer.cpp b/net/cpp/src/peer.cpp index b01ac81d934823813e446829da447282c48bb38e..868aa168d270d5f80420e396fad8fccca56f4ea5 100644 --- a/net/cpp/src/peer.cpp +++ b/net/cpp/src/peer.cpp @@ -2,6 +2,11 @@ #include <glog/logging.h> #include <fcntl.h> +#ifdef WIN32 +#include <winsock2.h> +#include <Ws2tcpip.h> +#include <windows.h> +#endif #include <ftl/uri.hpp> #include <ftl/net/peer.hpp> @@ -20,12 +25,6 @@ #define SOCKET_ERROR -1 #endif -#ifdef WIN32 -#include <winsock2.h> -#include <Ws2tcpip.h> -#include <windows.h> -#endif - #include <iostream> #include <memory> #include <algorithm> @@ -502,9 +501,11 @@ int Peer::_send() { #ifdef WIN32 // TODO(nick) Use WSASend instead as equivalent to writev + auto send_vec = send_buf_.vector(); + auto send_size = send_buf_.vector_size(); int c = 0; - for (auto v : send_vec_) { - c += ftl::net::internal::send(sock_, (char*)v.iov_base, v.iov_len, 0); + for (int i = 0; i < send_size; i++) { + c += ftl::net::internal::send(sock_, (char*)send_vec[i].iov_base, send_vec[i].iov_len, 0); } #else int c = ftl::net::internal::writev(sock_, send_buf_.vector(), send_buf_.vector_size()); diff --git a/net/cpp/src/universe.cpp b/net/cpp/src/universe.cpp index 2e4659a7e0dd153ca0a38228b861a5cee2a192a1..ea8f3159fe836ddeeec0811252b98f6dd9f0bac1 100644 --- a/net/cpp/src/universe.cpp +++ b/net/cpp/src/universe.cpp @@ -1,5 +1,10 @@ #include <ftl/net/universe.hpp> +#ifdef WIN32 +#include <Ws2tcpip.h> +#pragma comment(lib, "Rpcrt4.lib") +#endif + using std::string; using std::vector; using std::thread; diff --git a/net/cpp/test/peer_unit.cpp b/net/cpp/test/peer_unit.cpp index 0f7e19855c16896139bd8cd239b5a379b7d123e7..edc9f1507a46b7a863b0da3f657765aad9202e1d 100644 --- a/net/cpp/test/peer_unit.cpp +++ b/net/cpp/test/peer_unit.cpp @@ -8,6 +8,10 @@ #include <ftl/net/protocol.hpp> #include <ftl/config.h> +#ifdef WIN32 +#pragma comment(lib, "Rpcrt4.lib") +#endif + /* Allow socket functions to be mocked */ #define TEST_MOCKS #include "../src/net_internal.hpp"