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

Updates to get most code compiling in Windows, including cv-node.

parent dc35bd89
No related branches found
No related tags found
No related merge requests found
Pipeline #9602 failed
Showing with 59 additions and 65 deletions
......@@ -19,6 +19,8 @@ find_package( URIParser REQUIRED )
find_package( MsgPack REQUIRED )
find_package( LibSGM )
include_directories(${GLOG_INCLUDE_DIRS})
# Why is this problematic on some machines?
check_language(CUDA)
if (CUDA_TOOLKIT_ROOT_DIR)
......@@ -57,6 +59,9 @@ check_include_file("uuid/uuid.h" UUID_FOUND)
if (NOT UUID_FOUND)
message(ERROR "UUID library is required")
endif()
find_library(UUID_LIBRARIES NAME uuid libuuid)
else()
endif()
find_program(CPPCHECK_FOUND cppcheck)
......
###############################################################################
# Find glog
#
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})
else()
set(glog_DIR "")
endif()
# Find lib
set(GLOG_FOUND FALSE CACHE BOOL "" FORCE)
find_library(GLOG_LIBRARY
NAMES glog libglog
PATHS ${glog_DIR}
PATH_SUFFIXES lib/
)
# Find include
find_path(GLOG_INCLUDE_DIRS
NAMES glog/logging.h
PATHS ${glog_DIR}
PATH_SUFFIXES include
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(glog DEFAULT_MSG GLOG_LIBRARY GLOG_INCLUDE_DIRS)
mark_as_advanced(GLOG_FOUND)
if(GLOG_FOUND)
include_directories(${GLOG_INCLUDE_DIRS})
set(GLOG_FOUND TRUE CACHE BOOL "" FORCE)
set(GLOG_LIBRARIES ${GLOG_LIBRARY})
message(STATUS "Found glog")
endif()
......@@ -47,6 +47,6 @@ set_property(TARGET cv-node PROPERTY CUDA_SEPARABLE_COMPILATION ON)
endif()
#target_include_directories(cv-node PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(cv-node net Threads::Threads ${OpenCV_LIBS} ${LIBSGM_LIBRARIES} ${CUDA_LIBRARIES} ${GLOG_LIBRARIES})
target_link_libraries(cv-node Threads::Threads ${OpenCV_LIBS} ${LIBSGM_LIBRARIES} ${CUDA_LIBRARIES} glog::glog ${PROJECT_BINARY_DIR}/net/cpp/Release/net.lib)
......@@ -10,6 +10,8 @@
#include <ftl/disparity.hpp>
#include <nlohmann/json.hpp>
#include <ftl/config.h>
#if defined HAVE_CUDA
#include <opencv2/core/cuda.hpp>
#endif
......
......@@ -8,6 +8,7 @@
#include <string>
#include <map>
#include <vector>
#include <fstream>
#include <opencv2/opencv.hpp>
#include <ftl/local.hpp>
......@@ -42,9 +43,20 @@ static json config;
* Find and load a JSON configuration file
*/
static bool findConfiguration(const string &file) {
// TODO(nick) Check other locations
ifstream i((file != "") ? file : FTL_LOCAL_CONFIG_ROOT "/config.json");
if (!i.is_open()) return false;
ifstream i;
if (file != "") {
i.open(file);
}
if (!i.is_open()) {
i.open("./config.json");
}
if (!i.is_open()) {
i.open(FTL_LOCAL_CONFIG_ROOT "/config.json");
}
if (!i.is_open()) {
i.open(FTL_GLOBAL_CONFIG_ROOT "/config.json");
}
i >> config;
return true;
}
......
......@@ -20,10 +20,10 @@ set(NETSOURCE
check_function_exists(uriParseSingleUriA HAVE_URIPARSESINGLE)
add_library(net ${NETSOURCE})
target_link_libraries(net pthread)
target_link_libraries(net Threads::Threads glog::glog)
add_executable(net-cli src/main.cpp)
target_link_libraries(net-cli "${PROJECT_BINARY_DIR}/net/cpp/libnet.a" ${GLOG_LIBRARIES} ${URIPARSER_LIBRARIES} pthread readline uuid)
target_link_libraries(net-cli "${PROJECT_BINARY_DIR}/net/cpp/libnet.a" glog::glog ${URIPARSER_LIBRARIES} Threads::Threads ${READLINE_LIBRARIES} ${UUID_LIBRARIES})
add_dependencies(net-cli net)
ADD_SUBDIRECTORY(test)
......@@ -2,6 +2,11 @@
#define _FTL_NET_DISPATCHER_HPP_
#include <ftl/net/func_traits.hpp>
#ifdef _MSC_VER
#include <msgpack_optional.hpp>
#endif
#include <msgpack.hpp>
#include <memory>
#include <tuple>
......
#ifndef _FTL_NET_P2P_HPP_
#define _FTL_NET_P2P_HPP_
#include <ftl/net/protocol.hpp>
#include <ftl/net/socket.hpp>
#include <ftl/uuid.hpp>
#include <optional>
#include <string>
......@@ -8,8 +10,6 @@
#include <chrono>
#include <vector>
#include <memory>
#include <ftl/net/protocol.hpp>
#include <ftl/net/socket.hpp>
namespace ftl {
namespace net {
......
......@@ -20,7 +20,7 @@ namespace ftl {
public:
UUID() {
#ifdef WIN32
::UuidCreate(&uuid_);
::UuidCreate(&guid_);
#else
uuid_generate(uuid_);
#endif
......@@ -50,7 +50,7 @@ namespace ftl {
std::string to_string() const {
char b[37];
#ifdef WIN32
UuidToString(&uuid_, (RPC_CSTR*)b);
UuidToString(&guid_, (RPC_CSTR*)b);
#else
uuid_unparse(uuid_, b);
#endif
......@@ -62,7 +62,10 @@ namespace ftl {
private:
#ifdef WIN32
_GUID uuid_;
union {
_GUID guid_;
unsigned char uuid_[16];
};
#else
unsigned char uuid_[16];
#endif
......
......@@ -19,10 +19,9 @@
#endif
#ifdef WIN32
#include <winsock2.h>
#include <windows.h>
#include <winsock.h>
typedef int socklen_t;
#define MSG_WAITALL 0
#endif
using namespace ftl;
......
......@@ -5,7 +5,14 @@
#include <ftl/net/socket.hpp>
#include <memory>
#include <thread>
#ifndef WIN32
#include <readline/readline.h>
#endif
#ifdef WIN32
#pragma comment(lib, "Ws2_32.lib")
#endif
using std::string;
using std::shared_ptr;
......
......@@ -10,10 +10,6 @@
#include <iostream>
#include <chrono>
#ifdef WIN32
#pragma comment(lib, "Ws2_32.lib")
#endif
using namespace std;
using namespace std::chrono;
using ftl::net::Listener;
......
......@@ -19,9 +19,9 @@
#endif
#ifdef WIN32
#include <windows.h>
#include <winsock2.h>
#include <Ws2tcpip.h>
#include <windows.h>
#endif
#include <iostream>
......
......@@ -21,9 +21,9 @@
#endif
#ifdef WIN32
#include <windows.h>
#include <winsock2.h>
#include <Ws2tcpip.h>
#include <windows.h>
#endif
#include <string>
......
......@@ -2,8 +2,7 @@ add_executable(protocol_unit
./tests.cpp
./protocol_unit.cpp
)
target_include_directories(protocol_unit PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(protocol_unit ${GLOG_LIBRARIES})
target_link_libraries(protocol_unit glog::glog)
add_executable(socket_unit
./tests.cpp
......@@ -11,13 +10,13 @@ add_executable(socket_unit
./socket_unit.cpp
)
target_include_directories(socket_unit PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(socket_unit ${URIPARSER_LIBRARIES} ${GLOG_LIBRARIES})
target_link_libraries(socket_unit ${URIPARSER_LIBRARIES} glog::glog)
add_executable(uri_unit
./tests.cpp
./uri_unit.cpp
)
target_include_directories(uri_unit PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(uri_unit ${URIPARSER_LIBRARIES})
add_executable(p2p_base_unit
......@@ -31,8 +30,8 @@ add_executable(p2p_base_unit
../src/listener.cpp
../src/ws_internal.cpp
)
target_include_directories(p2p_base_unit PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(p2p_base_unit ${URIPARSER_LIBRARIES} gflags ${GLOG_LIBRARIES} uuid)
target_link_libraries(p2p_base_unit ${URIPARSER_LIBRARIES} gflags glog::glog ${UUID_LIBRARIES})
add_executable(net_integration
./tests.cpp
......@@ -44,8 +43,7 @@ add_executable(net_integration
../src/net.cpp
../src/ws_internal.cpp
)
target_include_directories(net_integration PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(net_integration ${URIPARSER_LIBRARIES} ${GLOG_LIBRARIES})
target_link_libraries(net_integration ${URIPARSER_LIBRARIES} glog::glog)
add_test(URIUnitTest uri_unit)
add_test(ProtocolUnitTest protocol_unit)
......
......@@ -24,9 +24,11 @@ using std::shared_ptr;
#endif
#ifdef WIN32
#include <windows.h>
#include <winsock2.h>
#include <Ws2tcpip.h>
#include <windows.h>
#pragma comment(lib, "Ws2_32.lib")
#endif
static int ssock = INVALID_SOCKET;
......
......@@ -7,6 +7,8 @@
#ifndef WIN32
#include <sys/select.h>
#else
typedef int ssize_t;
#endif
using ftl::net::Dispatcher;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment