Skip to content
Snippets Groups Projects
Commit 8ca2528e authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Fixes for VS compilation and cmake in windows

parent 80dd8500
No related branches found
No related tags found
No related merge requests found
Pipeline #9694 passed
...@@ -13,6 +13,7 @@ enable_testing() ...@@ -13,6 +13,7 @@ enable_testing()
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
#include(Findglog)
find_package( glog REQUIRED ) find_package( glog REQUIRED )
find_package( OpenCV REQUIRED ) find_package( OpenCV REQUIRED )
find_package( Threads REQUIRED ) find_package( Threads REQUIRED )
......
...@@ -5,6 +5,13 @@ ...@@ -5,6 +5,13 @@
if(WIN32) 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") 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}) set(glog_DIR ${glog_DIR})
find_package(glog QUIET PATHS "${glog_DIR}/lib/cmake" NO_DEFAULT_PATH)
if (GLOG_FOUND)
return()
endif()
else() else()
set(glog_DIR "") set(glog_DIR "")
endif() endif()
......
#ifndef _FTL_NET_PEER_HPP_ #ifndef _FTL_NET_PEER_HPP_
#define _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 #ifndef WIN32
#define INVALID_SOCKET -1 #define INVALID_SOCKET -1
#include <netinet/in.h> #include <netinet/in.h>
...@@ -15,6 +8,13 @@ ...@@ -15,6 +8,13 @@
#include <winsock2.h> #include <winsock2.h>
#endif #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 <iostream>
#include <sstream> #include <sstream>
#include <tuple> #include <tuple>
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
#include <glog/logging.h> #include <glog/logging.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef WIN32
#include <winsock2.h>
#include <Ws2tcpip.h>
#include <windows.h>
#endif
#include <ftl/uri.hpp> #include <ftl/uri.hpp>
#include <ftl/net/peer.hpp> #include <ftl/net/peer.hpp>
...@@ -20,12 +25,6 @@ ...@@ -20,12 +25,6 @@
#define SOCKET_ERROR -1 #define SOCKET_ERROR -1
#endif #endif
#ifdef WIN32
#include <winsock2.h>
#include <Ws2tcpip.h>
#include <windows.h>
#endif
#include <iostream> #include <iostream>
#include <memory> #include <memory>
#include <algorithm> #include <algorithm>
...@@ -502,9 +501,11 @@ int Peer::_send() { ...@@ -502,9 +501,11 @@ int Peer::_send() {
#ifdef WIN32 #ifdef WIN32
// TODO(nick) Use WSASend instead as equivalent to writev // 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; int c = 0;
for (auto v : send_vec_) { for (int i = 0; i < send_size; i++) {
c += ftl::net::internal::send(sock_, (char*)v.iov_base, v.iov_len, 0); c += ftl::net::internal::send(sock_, (char*)send_vec[i].iov_base, send_vec[i].iov_len, 0);
} }
#else #else
int c = ftl::net::internal::writev(sock_, send_buf_.vector(), send_buf_.vector_size()); int c = ftl::net::internal::writev(sock_, send_buf_.vector(), send_buf_.vector_size());
......
#include <ftl/net/universe.hpp> #include <ftl/net/universe.hpp>
#ifdef WIN32
#include <Ws2tcpip.h>
#pragma comment(lib, "Rpcrt4.lib")
#endif
using std::string; using std::string;
using std::vector; using std::vector;
using std::thread; using std::thread;
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
#include <ftl/net/protocol.hpp> #include <ftl/net/protocol.hpp>
#include <ftl/config.h> #include <ftl/config.h>
#ifdef WIN32
#pragma comment(lib, "Rpcrt4.lib")
#endif
/* Allow socket functions to be mocked */ /* Allow socket functions to be mocked */
#define TEST_MOCKS #define TEST_MOCKS
#include "../src/net_internal.hpp" #include "../src/net_internal.hpp"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment