Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Modernize cmake scripts and support MSVC 2017#834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
anonimal wants to merge6 commits intocpp-netlib:0.13-release
base:0.13-release
Choose a base branch
Loading
fromanonimal:0.13-release
Open
Show file tree
Hide file tree
Changes from4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 117 additions & 89 deletionsCMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,8 +4,8 @@
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

cmake_minimum_required(VERSION2.8)
project(CPP-NETLIB)
cmake_minimum_required(VERSION3.5 FATAL_ERROR)
project(CPP-NETLIB CXX)

option( CPP-NETLIB_BUILD_SHARED_LIBS "Build cpp-netlib as shared libraries." OFF )
option( CPP-NETLIB_BUILD_TESTS "Build the cpp-netlib project tests." ON)
Expand DownExpand Up@@ -42,22 +42,25 @@ endif()
# Use Boost's static libraries
if (CPP-NETLIB_STATIC_BOOST)
set(Boost_USE_STATIC_LIBS ON)
else()
# We need this for all tests to use the dynamic version.
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS BOOST_ALL_DYN_LINK)
endif()

#We need this forall tests to use the dynamic version.
add_definitions(-DBOOST_TEST_DYN_LINK)
#The interface target forpublic usage requirements
add_library(cppnetlib INTERFACE)

# Always use multi-threaded Boost libraries.
set(Boost_USE_MULTI_THREADED ON)
set(Boost_USE_MULTITHREADED ON)

find_package(Boost 1.58.0 REQUIRED COMPONENTS system thread)
find_package(Boost 1.58.0 REQUIRED COMPONENTS system thread regex)

if (CPP-NETLIB_ENABLE_HTTPS)
if (APPLE)
# If we're on OS X check for Homebrew's copy of OpenSSL instead of Apple's
if (NOT OpenSSL_DIR)
find_program(HOMEBREW brew)
if (HOMEBREW STREQUAL "HOMEBREW-NOTFOUND")
if (NOTHOMEBREW)
message(WARNING "Homebrew not found: not using Homebrew's OpenSSL")
if (NOT OPENSSL_ROOT_DIR)
message(WARNING "Use -DOPENSSL_ROOT_DIR for non-Apple OpenSSL")
Expand All@@ -69,109 +72,134 @@ if (CPP-NETLIB_ENABLE_HTTPS)
endif()
endif()
endif()

if (CPP-NETLIB_STATIC_OPENSSL)
set(OPENSSL_USE_STATIC_LIBS TRUE)
endif()

find_package(OpenSSL REQUIRED)
target_compile_definitions(cppnetlib INTERFACE BOOST_NETWORK_ENABLE_HTTPS)
if (CPP-NETLIB_STATIC_OPENSSL)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
target_link_libraries(cppnetlib INTERFACE ${CMAKE_DL_LIBS})
endif()
find_package(OpenSSL)
endif()

find_package( Threads )

set(CMAKE_VERBOSE_MAKEFILE true)

set(CPPNETLIB_VERSION_MAJOR 0) # MUST bump this whenever we make ABI-incompatible changes
set(CPPNETLIB_VERSION_MINOR 13)
set(CPPNETLIB_VERSION_PATCH 0)
set(CPPNETLIB_VERSION_STRING ${CPPNETLIB_VERSION_MAJOR}.${CPPNETLIB_VERSION_MINOR}.${CPPNETLIB_VERSION_PATCH})

if (CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DBOOST_NETWORK_DEBUG)
endif()
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:BOOST_NETWORK_DEBUG>)

if (OPENSSL_FOUND)
add_definitions(-DBOOST_NETWORK_ENABLE_HTTPS)
include_directories(${OPENSSL_INCLUDE_DIR})
# Use C++11
if (CMAKE_VERSION VERSION_LESS 3.8)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
else()
target_compile_features(cppnetlib INTERFACE cxx_std_11)
endif()

if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
# Use C++11 when using GNU compilers.
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
# We want to link in C++11 mode in Clang too, but also set a high enough
# template depth for the template metaprogramming.
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -ftemplate-depth=256 -std=c++11")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-Wall)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# A high enough template depth for the template metaprogramming.
add_compile_options(-Wall -ftemplate-depth=256)
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
# Use libc++ only in OS X.
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++")
add_compile_options(-stdlib=libc++)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++")
endif()
endif()


if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
set(gtest_force_shared_crt true)
if (WIN32)
target_compile_definitions(cppnetlib INTERFACE _WIN32_WINNT=0x0501)

if (MSVC)
target_compile_options(cppnetlib INTERFACE /bigobj)
target_compile_definitions(cppnetlib INTERFACE _SCL_SECURE_NO_WARNINGS)
endif()

if (MINGW)
target_link_libraries(cppnetlib INTERFACE ws2_32 wsock32)
endif()
endif()

if (Boost_FOUND)
if (MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif(MSVC)
if (WIN32)
add_definitions(-D_WIN32_WINNT=0x0501)
endif(WIN32)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})

enable_testing()
add_subdirectory(libs/network/src)
if (CPP-NETLIB_BUILD_TESTS)
add_subdirectory(deps/googletest)
add_subdirectory(libs/network/test)
endif (CPP-NETLIB_BUILD_TESTS)
if (CPP-NETLIB_BUILD_EXAMPLES)
add_subdirectory(libs/network/example)
endif (CPP-NETLIB_BUILD_EXAMPLES)
endif(Boost_FOUND)

enable_testing()

set(CPP-NETLIB_LIBRARIES ${Boost_LIBRARIES} CACHE INTERNAL "Dependent libraries for header-only use")

install(DIRECTORY boost DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

###
## Export Targets
# (so cpp-netlib can be easily used by other CMake projects)
# [see http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file]

# Add all targets to the build-tree export set
export(TARGETS cppnetlib-client-connections cppnetlib-server-parsers cppnetlib-uri
FILE "${PROJECT_BINARY_DIR}/cppnetlibTargets.cmake")
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE cppnetlib)
# Create the cppnetlibConfig.cmake and cppnetlibConfigVersion files
file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}"
"${CMAKE_INSTALL_FULL_INCLUDEDIR}")
# ... for the build tree
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" ${Boost_INCLUDE_DIRS})
configure_file(cppnetlibConfig.cmake.in
"${PROJECT_BINARY_DIR}/cppnetlibConfig.cmake" @ONLY)
# ... for the install tree
set(CONF_INCLUDE_DIRS "\${CPPNETLIB_CMAKE_DIR}/${REL_INCLUDE_DIR}")
set(CONF_INCLUDE_DIRS ${CONF_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
target_include_directories(cppnetlib INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

find_package(Threads REQUIRED)
target_link_libraries(cppnetlib INTERFACE Boost::thread Threads::Threads)

install(TARGETS cppnetlib EXPORT cppnetlibTargets)

add_subdirectory(libs/network/src)

add_library(cppnetlib::cppnetlib ALIAS cppnetlib)
add_library(cppnetlib::uri ALIAS uri)
add_library(cppnetlib::server-parsers ALIAS server-parsers)
add_library(cppnetlib::client-connections ALIAS client-connections)

if (CPP-NETLIB_BUILD_TESTS)
enable_testing()

if (MSVC)
set(gtest_force_shared_crt ON CACHE BOOL "Use shared (DLL) run-time lib even when Google Test is built as static lib.")
endif()

add_subdirectory(deps/googletest)

if (MSVC)
target_compile_definitions(gtest PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
target_compile_definitions(gtest_main PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
target_compile_definitions(gmock PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
target_compile_definitions(gmock_main PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
endif()

add_subdirectory(libs/network/test)
endif()

if (CPP-NETLIB_BUILD_EXAMPLES)
add_library(cxxopts INTERFACE)
target_include_directories(cxxopts INTERFACE deps/cxxopts/src)

add_subdirectory(libs/network/example)
endif ()

install(DIRECTORY boost DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT dev)

###
## Export Targets
# (so cpp-netlib can be easily used by other CMake projects)
# [see http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file]

# Add all targets to the build-tree export set
export(EXPORT cppnetlibTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/cppnetlibTargets.cmake"
NAMESPACE cppnetlib::)
configure_file(cppnetlibConfig.cmake.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cppnetlibConfig.cmake" @ONLY)
# ... for both
configure_file(cppnetlibConfigVersion.cmake.in
"${PROJECT_BINARY_DIR}/cppnetlibConfigVersion.cmake" @ONLY)
# Install the cppnetlibConfig.cmake and cppnetlibConfigVersion.cmake
"${CMAKE_CURRENT_BINARY_DIR}/cppnetlibConfig.cmake" @ONLY)

# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE cppnetlib)

include(CMakePackageConfigHelpers)
write_basic_package_version_file(cppnetlibConfigVersion.cmake VERSION ${CPPNETLIB_VERSION_STRING} COMPATIBILITY AnyNewerVersion)

# Install the cppnetlibConfig.cmake and cppnetlibConfigVersion.cmake
install(FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cppnetlibConfig.cmake"
"${PROJECT_BINARY_DIR}/cppnetlibConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/cppnetlibConfig.cmake"
"${PROJECT_BINARY_DIR}/cppnetlibConfigVersion.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}"
COMPONENT dev)
# Install the export set for use with the install-tree
install(EXPORT cppnetlibTargets
DESTINATION "${INSTALL_CMAKE_DIR}"
COMPONENT dev)
COMPONENT dev)

# Install the export set for use with the install-tree
install(EXPORT cppnetlibTargets
FILE cppnetlibTargets.cmake
NAMESPACE cppnetlib::
DESTINATION "${INSTALL_CMAKE_DIR}")
19 changes: 9 additions & 10 deletionsboost/network/protocol/http/server/impl/parsers.ipp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,22 +49,21 @@ namespace http {
BOOST_NETWORK_INLINE void parse_version(
std::string const& partial_parsed,
std::tuple<std::uint8_t, std::uint8_t>& version_pair) {
using namespace boost::spirit::qi;
parse(partial_parsed.begin(), partial_parsed.end(),
(lit("HTTP/") >> ushort_ >> '.' >> ushort_), version_pair);
boost::spirit::qi::parse(partial_parsed.begin(), partial_parsed.end(),
(boost::spirit::qi::lit("HTTP/") >> boost::spirit::qi::ushort_ >> '.' >> boost::spirit::qi::ushort_), version_pair);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please re-base, as I've just merged a change that addresses this particular issue.

}

BOOST_NETWORK_INLINE void parse_headers(
std::string const& input, std::vector<request_header_narrow>& container) {
u8_to_u32_iterator<std::string::const_iterator> begin = input.begin(),
end = input.end();
using namespace boost::spirit::qi;
typedefas<boost::spirit::traits::u32_string> as_u32_string;
parse(begin, end,
*(+((alnum | punct) - ':') >> lit(": ") >>
as_u32_string()[+((unicode::alnum | space | punct) - '\r' - '\n')] >>
lit("\r\n")) >>
lit("\r\n"),

using as_u32_string = boost::spirit::qi::as<boost::spirit::traits::u32_string>;
boost::spirit::qi::parse(begin, end,
*(+((boost::spirit::qi::alnum |boost::spirit::qi::punct) - ':') >>boost::spirit::qi::lit(": ") >>
as_u32_string()[+((boost::spirit::qi::unicode::alnum |boost::spirit::qi::space |boost::spirit::qi::punct) - '\r' - '\n')] >>
boost::spirit::qi::lit("\r\n")) >>
boost::spirit::qi::lit("\r\n"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you separate out this change, (or rebase) to its own pull request?

container);
}

Expand Down
1 change: 1 addition & 0 deletionsboost/network/protocol/stream_handler.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,7 @@
#include <boost/asio/detail/throw_error.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/stream_socket_service.hpp>
#include <boost/asio/io_service.hpp>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is this strictly necessary? If so, can you make this a self-contained PR?

#include <cstddef>

#ifdef BOOST_NETWORK_ENABLE_HTTPS
Expand Down
58 changes: 36 additions & 22 deletionscppnetlibConfig.cmake.in
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
# - Config file for the cppnetlib package
# It defines the following variables
# CPPNETLIB_INCLUDE_DIRS - include directories for cppnetlib
# CPPNETLIB_LIBRARIES - libraries to link against
# CPPNETLIB_EXECUTABLE - the bar executable

# Compute paths
get_filename_component(CPPNETLIB_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(CPPNETLIB_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")

# Our library dependencies (contains definitions for IMPORTED targets)
if( NOT TARGET cppnetlib-client-connections
AND NOT TARGET cppnetlib-server-parsers
AND NOT TARGET cppnetlib-uri
AND NOT CPPNETLIB_BINARY_DIR)
include("${CPPNETLIB_CMAKE_DIR}/cppnetlibTargets.cmake")
# - Config file for the cppnetlib package
# It defines the following variables targets
# cppnetlib::cppnetlib - include directories and usage requirements for cppnetlib
# Libraries and usage requirements^
# cppnetlib::uri
# cppnetlib::server-parsers
# cppnetlib::client-connections
# Variables
# CPPNETLIB_INCLUDE_DIRS - include directories for cppnetlib (empty, usage requirements propageted through libraries)
# CPPNETLIB_LIBRARIES - libraries to link against

set(CPP-NETLIB_STATIC_BOOST @CPP-NETLIB_STATIC_BOOST@)
set(CPP-NETLIB_ENABLE_HTTPS @CPP-NETLIB_ENABLE_HTTPS@)
set(CPP-NETLIB_STATIC_OPENSSL @CPP-NETLIB_STATIC_OPENSSL@)

# Use Boost's static libraries
if (CPP-NETLIB_STATIC_BOOST)
set(Boost_USE_STATIC_LIBS ON)
endif()

# Always use multi-threaded Boost libraries.
set(Boost_USE_MULTITHREADED ON)

if (CPP-NETLIB_ENABLE_HTTPS)
if (CPP-NETLIB_STATIC_OPENSSL)
set(OPENSSL_USE_STATIC_LIBS TRUE)
endif()

find_package(OpenSSL REQUIRED)
endif()

# These are IMPORTED targets created by cppnetlibTargets.cmake
set(CPPNETLIB_LIBRARIES
cppnetlib-client-connections
cppnetlib-server-parsers
cppnetlib-uri)
#set(CPPNETLIB_EXECUTABLE ...) # maybe the examples?
find_package(Boost 1.58.0 REQUIRED COMPONENTS system thread regex)
find_package(Threads)

include("${CMAKE_CURRENT_LIST_DIR}/cppnetlibTargets.cmake")

set(CPPNETLIB_INCLUDE_DIRS)
set(CPPNETLIB_LIBRARIES cppnetlib::client-connections cppnetlib::server-parsers cppnetlib::uri)
11 changes: 0 additions & 11 deletionscppnetlibConfigVersion.cmake.in
View file
Open in desktop

This file was deleted.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp