Skip to content

Commit

Permalink
Add support for MSVC 2015 (#365)
Browse files Browse the repository at this point in the history
Co-authored-by: An Tao <antao2002@gmail.com>
  • Loading branch information
wanggao1990 and an-tao authored Feb 26, 2020
1 parent 53f61e9 commit d5cd882
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ if(NOT WIN32)
message(FATAL_ERROR "uuid lib error")
endif()
endif(NOT WIN32)
if(NOT MSVC)
if(NOT MSVC OR NOT BUILD_ORM)
find_package(ZLIB REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE ${ZLIB_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE ${ZLIB_LIBRARIES})
endif(NOT MSVC)
endif(NOT MSVC OR NOT BUILD_ORM)

set(DROGON_SOURCES
lib/src/AOPAdvice.cc
Expand Down
7 changes: 3 additions & 4 deletions cmake/templates/DrogonConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# DROGON_INCLUDE_DIRS - include directories for Drogon
# DROGON_LIBRARIES - libraries to link against
# DROGON_EXECUTABLE - the drogon_ctl executable
# DROGON_FOUND
# Drogon_FOUND
# This module defines the following IMPORTED target:
# Drogon::Drogon

@PACKAGE_INIT@

if(NOT TRANTOR_FOUND)
if(NOT Trantor_FOUND)
# find trantor
find_package(Trantor REQUIRED)
find_package(Trantor CONFIG REQUIRED)
endif()

# Our library dependencies (contains definitions for IMPORTED targets)
Expand All @@ -24,4 +24,3 @@ endif()
get_target_property(DROGON_INCLUDE_DIRS Drogon::Drogon INTERFACE_INCLUDE_DIRECTORIES)
set(DROGON_LIBRARIES Drogon::Drogon)
set(DROGON_EXECUTABLE drogon_ctl)
set(DROGON_FOUND TRUE)
6 changes: 3 additions & 3 deletions lib/inc/drogon/HttpRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ HttpRequestPtr toRequest(T &&)
}

template <>
HttpRequestPtr toRequest(const Json::Value &pJson);
HttpRequestPtr toRequest<const Json::Value &>(const Json::Value &pJson);
template <>
HttpRequestPtr toRequest(Json::Value &&pJson);
template <>
inline HttpRequestPtr toRequest(Json::Value &pJson)
inline HttpRequestPtr toRequest<Json::Value &>(Json::Value &pJson)
{
return toRequest((const Json::Value &)pJson);
}
Expand Down Expand Up @@ -372,7 +372,7 @@ class HttpRequest
};

template <>
inline HttpRequestPtr toRequest(const Json::Value &pJson)
inline HttpRequestPtr toRequest<const Json::Value &>(const Json::Value &pJson)
{
return HttpRequest::newHttpJsonRequest(pJson);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/inc/drogon/HttpResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ HttpResponsePtr toResponse(T &&)
exit(1);
}
template <>
HttpResponsePtr toResponse(const Json::Value &pJson);
HttpResponsePtr toResponse<const Json::Value &>(const Json::Value &pJson);
template <>
HttpResponsePtr toResponse(Json::Value &&pJson);
template <>
inline HttpResponsePtr toResponse(Json::Value &pJson)
inline HttpResponsePtr toResponse<Json::Value &>(Json::Value &pJson)
{
return toResponse((const Json::Value &)pJson);
}
Expand Down Expand Up @@ -367,7 +367,7 @@ class HttpResponse
virtual void setBody(const char *body, size_t len) = 0;
};
template <>
inline HttpResponsePtr toResponse(const Json::Value &pJson)
inline HttpResponsePtr toResponse<const Json::Value &>(const Json::Value &pJson)
{
return HttpResponse::newHttpJsonResponse(pJson);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/inc/drogon/MultiPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class HttpFile
/// Return the file content.
char *fileData() noexcept
{
#if __cplusplus >= 201703L | defined _WIN32
#if __cplusplus >= 201703L || (defined _MSC_VER && _MSC_VER > 1900)
return fileContent_.data();
#else
return (char *)(fileContent_.data());
Expand Down
4 changes: 2 additions & 2 deletions lib/inc/drogon/utils/any.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
*/

#pragma once
#if __cplusplus >= 201703L | defined _WIN32
#if __cplusplus >= 201703L || (defined _MSC_VER && _MSC_VER > 1900)
#include <any>
#else
#include <boost/any.hpp>
#endif

namespace drogon
{
#if __cplusplus >= 201703L | defined _WIN32
#if __cplusplus >= 201703L || (defined _MSC_VER && _MSC_VER > 1900)
using std::any;
using std::any_cast;
#else
Expand Down
4 changes: 2 additions & 2 deletions lib/inc/drogon/utils/string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/

#pragma once
#if __cplusplus >= 201703L | defined _WIN32
#if __cplusplus >= 201703L || (defined _MSC_VER && _MSC_VER > 1900)
#include <string_view>
#else
#include <boost/utility/string_view.hpp>
Expand All @@ -24,7 +24,7 @@

namespace drogon
{
#if __cplusplus >= 201703L | defined _WIN32
#if __cplusplus >= 201703L || (defined _MSC_VER && _MSC_VER > 1900)
using std::string_view;
#else
using boost::string_view;
Expand Down
9 changes: 6 additions & 3 deletions lib/src/HttpAppFrameworkImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,14 @@ HttpAppFrameworkImpl::HttpAppFrameworkImpl()
uploadPath_(rootPath_ + "uploads")
{
}

static std::function<void()> f = [] {
LOG_TRACE << "Initialize the main event loop in the main thread";
};

/// Make sure that the main event loop is initialized in the main thread.
drogon::InitBeforeMainFunction drogon::HttpAppFrameworkImpl::initFirst_([]() {
HttpAppFrameworkImpl::instance().getLoop()->runInLoop([]() {
LOG_TRACE << "Initialize the main event loop in the main thread";
});
HttpAppFrameworkImpl::instance().getLoop()->runInLoop(f);
});

namespace drogon
Expand Down
2 changes: 1 addition & 1 deletion orm_lib/inc/drogon/orm/ResultIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class ConstReverseResultIterator : private ConstResultIterator
using iterator_type::iterator_category;
using iterator_type::pointer;
using iterator_type::reference;
using iterator_type::value_type;
// using iterator_type::value_type;

ConstReverseResultIterator(const ConstReverseResultIterator &rhs)
: ConstResultIterator(rhs)
Expand Down
2 changes: 1 addition & 1 deletion orm_lib/inc/drogon/orm/RowIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class ConstReverseRowIterator : private ConstRowIterator
using iterator_type::iterator_category;
using iterator_type::pointer;
using iterator_type::reference;
using iterator_type::value_type;
// using iterator_type::value_type;

ConstReverseRowIterator(const ConstReverseRowIterator &rhs)
: ConstRowIterator(rhs)
Expand Down
2 changes: 1 addition & 1 deletion trantor

0 comments on commit d5cd882

Please sign in to comment.