Add cmake module to target a library as 'system', and fix a few warnings

pull/559/head
Michael 5 years ago
parent 50def75345
commit 4143472a17
No known key found for this signature in database
GPG Key ID: 2D51757B47E2434C

@ -21,6 +21,8 @@ option(WITH_SHARED "build shared library")
option(WITH_COVERAGE "generate coverage data")
option(WARNINGS_AS_ERRORS "treat all warnings as errors. turn off for development, on for release" OFF)
include(cmake/target_link_libraries_system.cmake)
# Basic definitions
get_filename_component(CORE_INCLUDE include ABSOLUTE)
get_filename_component(ABYSS_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/${ABYSS}/include" ABSOLUTE)
@ -86,7 +88,7 @@ endif(WIN32 AND NOT STATIC_LINK_RUNTIME)
add_subdirectory(vendor/cxxopts)
add_subdirectory(vendor/nlohmann)
include_directories(vendor/cxxopts/include)
include_directories(SYSTEM vendor/cxxopts/include)
# still need the headers unconditionally
set(ABSEIL_DIR vendor/abseil-cpp)
@ -372,7 +374,7 @@ set(ABYSS_SRC
add_library(${ABYSS_LIB} STATIC ${ABYSS_SRC})
add_subdirectory(${ABSEIL_DIR})
include_directories(${ABSEIL_DIR})
include_directories(SYSTEM ${ABSEIL_DIR})
add_subdirectory(crypto)
add_subdirectory(libutp)
@ -396,7 +398,7 @@ target_include_directories(${ABYSS_EXE} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${AB
# for freebsd
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
target_include_directories(${ABYSS_LIB} PUBLIC /usr/local/include)
target_include_directories(${ABYSS_LIB} SYSTEM PUBLIC /usr/local/include)
endif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
add_log_tag(${ABYSS_EXE})
add_log_tag(${ABYSS_LIB})
@ -419,7 +421,7 @@ else()
add_executable(${EXE} ${EXE_SRC})
elseif(NOT MSVC_VERSION)
add_executable(${EXE} ${EXE_SRC} llarp/win32/version.rc)
else()
else()
add_executable(${EXE} ${EXE_SRC})
endif(NOT WIN32)

@ -0,0 +1,9 @@
# This adds a dependency as a "system" dep - e.g -isystem
function(target_link_libraries_system target)
set(libs ${ARGN})
foreach(lib ${libs})
get_target_property(lib_include_dirs ${lib} INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${target} SYSTEM PUBLIC ${lib_include_dirs})
target_link_libraries(${target} ${lib})
endforeach(lib)
endfunction()

@ -34,4 +34,4 @@ extern "C"
#ifdef __cplusplus
}
#endif
#endif
#endif

@ -1,5 +1,5 @@
#ifndef __ABYSS_CLIENT_HPP__
#define __ABYSS_CLIENT_HPP__
#ifndef ABYSS_CLIENT_HPP
#define ABYSS_CLIENT_HPP
#include <ev/ev.h>
#include <util/json.hpp>

@ -1,5 +1,5 @@
#ifndef __ABYSS_HTTP_HPP__
#define __ABYSS_HTTP_HPP__
#ifndef ABYSS_HTTP_HPP
#define ABYSS_HTTP_HPP
#include <util/json.hpp>
#include <util/string_view.hpp>

@ -1,5 +1,5 @@
#ifndef __ABYSS_SERVER_HPP__
#define __ABYSS_SERVER_HPP__
#ifndef ABYSS_SERVER_HPP
#define ABYSS_SERVER_HPP
#include <ev/ev.h>
#include <util/json.hpp>

@ -50,8 +50,7 @@ struct DemoCall : public abyss::http::IRPCClientHandler
}
void
PopulateReqHeaders(ABSL_ATTRIBUTE_UNUSED
abyss::http::Headers_t& hdr) override
PopulateReqHeaders(ABSL_ATTRIBUTE_UNUSED abyss::http::Headers_t& hdr) override
{
}
@ -85,7 +84,7 @@ struct DemoClient : public abyss::http::JSONRPC
QueueRPC("test", nlohmann::json::object(),
std::bind(&DemoClient::NewConn, this, std::placeholders::_1));
Flush();
};
}
};
struct DemoServer : public abyss::httpd::BaseReqHandler

@ -46,12 +46,11 @@ set(LIB_UTIL_SRC
add_library(${UTIL_LIB} STATIC ${LIB_UTIL_SRC})
target_include_directories(${UTIL_LIB} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(${UTIL_LIB} PUBLIC absl::synchronization absl::hash)
target_link_libraries(${UTIL_LIB} PUBLIC nlohmann_json::nlohmann_json)
target_link_libraries_system(${UTIL_LIB} absl::synchronization absl::hash nlohmann_json::nlohmann_json)
# cut back on fluff
if (NOT WIN32)
target_link_libraries(${UTIL_LIB} PUBLIC absl::optional absl::variant absl::strings cppbackport)
target_link_libraries_system(${UTIL_LIB} absl::optional absl::variant absl::strings cppbackport)
endif(NOT WIN32)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
@ -259,6 +258,12 @@ if(WITH_SHARED)
add_log_tag(${SHARED_LIB})
endif()
if (WARNINGS_AS_ERRORS)
set(WARN_FLAGS -Wall -Wextra -Wextra-semi -Werror)
target_compile_options(${UTIL_LIB} PUBLIC ${WARN_FLAGS})
target_compile_options(${PLATFORM_LIB} PUBLIC ${WARN_FLAGS})
target_compile_options(${STATIC_LIB} PUBLIC ${WARN_FLAGS})
endif()
add_log_tag(${UTIL_LIB})
add_log_tag(${PLATFORM_LIB})
add_log_tag(${STATIC_LIB})

@ -78,7 +78,9 @@ namespace llarp
struct SecretKey final : public AlignedBuffer< SECKEYSIZE >
{
SecretKey() : AlignedBuffer< SECKEYSIZE >(){};
SecretKey() : AlignedBuffer< SECKEYSIZE >()
{
}
explicit SecretKey(const SecretKey &k) : AlignedBuffer< SECKEYSIZE >(k)
{
@ -127,7 +129,9 @@ namespace llarp
/// IdentitySecret is a secret key from a service node secret seed
struct IdentitySecret final : public AlignedBuffer< 32 >
{
IdentitySecret() : AlignedBuffer< 32 >(){};
IdentitySecret() : AlignedBuffer< 32 >()
{
}
friend std::ostream &
operator<<(std::ostream &out, const IdentitySecret &)

@ -19,7 +19,9 @@ namespace llarp
using BucketStorage_t = std::map< Key_t, Val_t, XorMetric >;
using Random_t = std::function< uint64_t() >;
Bucket(const Key_t& us, Random_t r) : nodes(XorMetric(us)), random(r){};
Bucket(const Key_t& us, Random_t r) : nodes(XorMetric(us)), random(r)
{
}
util::StatusObject
ExtractStatus() const

@ -11,13 +11,15 @@ namespace llarp
{
const Key_t& us;
XorMetric(const Key_t& ourKey) : us(ourKey){};
XorMetric(const Key_t& ourKey) : us(ourKey)
{
}
bool
operator()(const Key_t& left, const Key_t& right) const
{
return (us ^ left) < (us ^ right);
};
}
};
} // namespace dht
} // namespace llarp

@ -101,7 +101,9 @@ namespace llarp
{
ListDecoder(const Key_t &from,
std::vector< std::unique_ptr< IMessage > > &list)
: From(from), l(list){};
: From(from), l(list)
{
}
bool relayed = false;
const Key_t &From;

@ -16,7 +16,9 @@ namespace llarp
struct IMessage : public IBEncodeMessage
{
virtual ~IMessage(){};
virtual ~IMessage()
{
}
/// construct
IMessage(const Key_t& from) : From(from)

@ -29,7 +29,9 @@ namespace llarp
{
}
virtual ~TX(){};
virtual ~TX()
{
}
void
OnFound(const Key_t& askedPeer, const V& value);

@ -28,7 +28,9 @@ namespace llarp
{
huint32_t ipaddr;
virtual ~type_1a(){};
virtual ~type_1a()
{
}
type_1a();
bool
@ -42,7 +44,9 @@ namespace llarp
{
std::string ns;
virtual ~type_2ns(){};
virtual ~type_2ns()
{
}
type_2ns();
bool
@ -62,7 +66,9 @@ namespace llarp
uint32_t expire;
uint32_t minimum;
virtual ~type_6soa(){};
virtual ~type_6soa()
{
}
type_6soa();
bool
@ -76,7 +82,9 @@ namespace llarp
{
std::string cname;
virtual ~type_5cname(){};
virtual ~type_5cname()
{
}
type_5cname();
bool
@ -90,7 +98,9 @@ namespace llarp
{
std::string revname;
virtual ~type_12ptr(){};
virtual ~type_12ptr()
{
}
type_12ptr();
bool
@ -105,7 +115,9 @@ namespace llarp
std::string mx;
uint16_t priority;
virtual ~type_15mx(){};
virtual ~type_15mx()
{
}
type_15mx();
bool
@ -119,7 +131,9 @@ namespace llarp
{
std::string txt;
virtual ~type_16txt(){};
virtual ~type_16txt()
{
}
type_16txt();
bool

@ -5,6 +5,8 @@ namespace llarp
{
namespace dns
{
Serialize::~Serialize(){};
bool
EncodeRData(llarp_buffer_t* buf, const std::vector< byte_t >& v)
{

@ -12,7 +12,7 @@ namespace llarp
/// base type for serializable dns entities
struct Serialize
{
virtual ~Serialize() = default;
virtual ~Serialize() = 0;
/// encode entity to buffer
virtual bool

@ -15,7 +15,7 @@ namespace llarp
/// handler of dns query hooking
struct IQueryHandler
{
virtual ~IQueryHandler(){};
virtual ~IQueryHandler(){}
/// return true if we should hook this message
virtual bool

@ -383,14 +383,14 @@ namespace llarp
__attribute__((unused)) size_t sz)
{
return -1;
};
}
/// return false if we want to deregister and remove ourselves
virtual bool
tick()
{
return true;
};
}
/// used for tun interface and tcp conn
virtual ssize_t
@ -423,7 +423,9 @@ namespace llarp
}
virtual void
before_flush_write(){};
before_flush_write()
{
}
/// called in event loop when fd is ready for writing
/// requeues anything not written
@ -505,7 +507,7 @@ namespace llarp
virtual ~posix_ev_io()
{
close(fd);
};
}
};
#endif
@ -755,7 +757,9 @@ struct llarp_ev_loop
virtual bool
add_ev(llarp::ev_io* ev, bool write) = 0;
virtual ~llarp_ev_loop(){};
virtual ~llarp_ev_loop()
{
}
std::list< std::unique_ptr< llarp::ev_io > > handlers;

@ -22,7 +22,9 @@ namespace llarp
{
llarp_udp_io* udp;
udp_listener(int fd, llarp_udp_io* u) : ev_io(fd), udp(u){};
udp_listener(int fd, llarp_udp_io* u) : ev_io(fd), udp(u)
{
}
~udp_listener()
{
@ -45,7 +47,9 @@ namespace llarp
tun(llarp_tun_io* tio, llarp_ev_loop_ptr l)
: ev_io(-1, new LossyWriteQueue_t("kqueue_tun_write", l, l))
, t(tio)
, tunif(tuntap_init()){};
, tunif(tuntap_init())
{
}
int
sendto(__attribute__((unused)) const sockaddr* to,

@ -145,9 +145,11 @@ namespace llarp
ExitSession(const llarp::RouterID& snodeRouter,
std::function< bool(const llarp_buffer_t&) > writepkt,
AbstractRouter* r, size_t numpaths, size_t hoplen)
: BaseSession(snodeRouter, writepkt, r, numpaths, hoplen){};
: BaseSession(snodeRouter, writepkt, r, numpaths, hoplen)
{
}
~ExitSession(){};
~ExitSession() = default;
std::string
Name() const override;
@ -169,7 +171,7 @@ namespace llarp
AbstractRouter* r, size_t numpaths, size_t hoplen,
bool useRouterSNodeKey = false);
~SNodeSession(){};
~SNodeSession() = default;
std::string
Name() const override;

@ -11,7 +11,9 @@ namespace llarp
{
NullEndpoint(const std::string &name, AbstractRouter *r,
llarp::service::Context *parent)
: llarp::service::Endpoint(name, r, parent){};
: llarp::service::Endpoint(name, r, parent)
{
}
bool
HandleWriteIPPacket(const llarp_buffer_t &,

@ -15,7 +15,9 @@ namespace llarp
struct ILinkLayer;
struct ILinkSession
{
virtual ~ILinkSession(){};
virtual ~ILinkSession()
{
}
/// hook for utp for when we have established a connection
virtual void

@ -13,7 +13,9 @@ namespace llarp
uint64_t pathCreated;
PathConfirmMessage();
PathConfirmMessage(uint64_t lifetime);
~PathConfirmMessage(){};
~PathConfirmMessage()
{
}
bool
BEncode(llarp_buffer_t* buf) const override;
@ -29,7 +31,7 @@ namespace llarp
{
pathLifetime = 0;
pathCreated = 0;
};
}
};
} // namespace routing
} // namespace llarp

@ -24,7 +24,7 @@ namespace llarp
{
T = 0;
L = 0;
};
}
bool
HandleMessage(IMessageHandler* h, AbstractRouter* r) const override;

@ -131,7 +131,7 @@ namespace llarp
in_addr_t addr = this->addr4()->s_addr;
uint32_t byte = ntohl(addr);
return byte;
};
}
bool
isTenPrivate(uint32_t byte);

@ -113,7 +113,9 @@ namespace llarp
struct IHopHandler
{
virtual ~IHopHandler(){};
virtual ~IHopHandler()
{
}
virtual bool
Expired(llarp_time_t now) const = 0;

@ -21,9 +21,11 @@ namespace llarp
llarp_time_t lastUpdated = 0;
llarp_time_t lastDecay = 0;
RouterProfile() : IBEncodeMessage(){};
RouterProfile() : IBEncodeMessage()
{
}
~RouterProfile(){};
~RouterProfile() = default;
bool
BEncode(llarp_buffer_t* buf) const override;

@ -21,7 +21,9 @@ namespace llarp
{
}
virtual ~IMessage(){};
virtual ~IMessage()
{
}
virtual bool
HandleMessage(IMessageHandler* h, AbstractRouter* r) const = 0;

@ -98,7 +98,7 @@ namespace llarp
version = other.version;
UpdateAddr();
return *this;
};
}
bool
operator<(const ServiceInfo& other) const

@ -23,7 +23,9 @@ namespace llarp
struct IServiceLookup
{
IServiceLookup() = delete;
virtual ~IServiceLookup(){};
virtual ~IServiceLookup()
{
}
/// handle lookup result
virtual bool

@ -47,7 +47,7 @@ namespace llarp
{
(void)rebuild;
return true;
};
}
virtual void
UpdateIntroSet(bool randomizePath = false) = 0;

@ -227,7 +227,9 @@ namespace llarp
/// bencode serializable message
struct IBEncodeMessage
{
virtual ~IBEncodeMessage(){};
virtual ~IBEncodeMessage()
{
}
IBEncodeMessage(uint64_t v = LLARP_PROTO_VERSION)
{

@ -27,7 +27,7 @@ llarp_buffer_t::writef(const char* fmt, ...)
va_end(args);
if(written <= 0)
return false;
if(sz < written)
if(sz < static_cast< size_t >(written))
return false;
cur += written;
return true;

@ -7,7 +7,7 @@
namespace llarp
{
/// fluhsable file based log stream
/// flushable file based log stream
struct FileLogStream : public ILogStream
{
FileLogStream(llarp_threadpool* disk, FILE* f, llarp_time_t flushInterval);
@ -25,7 +25,9 @@ namespace llarp
Tick(llarp_time_t now) override;
void
PostLog(std::stringstream&) const override{};
PostLog(std::stringstream&) const override
{
}
private:
struct FlushEvent
@ -58,4 +60,4 @@ namespace llarp
};
} // namespace llarp
#endif
#endif

@ -14,7 +14,7 @@ namespace llarp
{
struct IParser
{
virtual ~IParser(){};
virtual ~IParser(){}
/// result from feeding data to parser
enum Result

@ -17,7 +17,9 @@ namespace llarp
void
PostLog(std::stringstream& ss) const override;
void Tick(llarp_time_t) override{};
void Tick(llarp_time_t) override
{
}
};
} // namespace llarp
#endif

@ -11,7 +11,9 @@ namespace llarp
/// logger stream interface
struct ILogStream
{
virtual ~ILogStream(){};
virtual ~ILogStream()
{
}
virtual void
PreLog(std::stringstream& out, LogLevel lvl, const char* fname,

@ -24,7 +24,9 @@ namespace llarp
virtual void
PostLog(std::stringstream& ss) const override;
void Tick(llarp_time_t) override{};
void Tick(llarp_time_t) override
{
}
private:
std::ostream& m_Out;

Loading…
Cancel
Save