-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #888 from SpaceIm/add-cpp-httplib-0.5.4
add cpp-httplib/0.5.4
- Loading branch information
Showing
7 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 2.8.11) | ||
project(cmake_wrapper) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_subdirectory("source_subfolder") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"0.5.4": | ||
url: "https://github.com/yhirose/cpp-httplib/archive/v0.5.4.tar.gz" | ||
sha256: "40dcce66ec002e2631ef918e1b3bfc9ec1662d02007291ea4743e17ac9c7d43f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import os | ||
|
||
from conans import ConanFile, CMake, tools | ||
|
||
class CpphttplibConan(ConanFile): | ||
name = "cpp-httplib" | ||
description = "A C++11 single-file header-only cross platform HTTP/HTTPS library." | ||
license = "MIT" | ||
topics = ("conan", "cpp-httplib", "http", "https", "header-only") | ||
homepage = "https://github.com/yhirose/cpp-httplib" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
exports_sources = "CMakeLists.txt" | ||
generators = "cmake" | ||
settings = "os" | ||
options = {"with_openssl": [True, False], "with_zlib": [True, False]} | ||
default_options = {"with_openssl": False, "with_zlib": False} | ||
no_copy_source = True | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
def requirements(self): | ||
if self.options.with_openssl: | ||
self.requires.add("openssl/1.1.1d") | ||
if self.options.with_zlib: | ||
self.requires.add("zlib/1.2.11") | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version]) | ||
os.rename(self.name + "-" + self.version, self._source_subfolder) | ||
|
||
def package(self): | ||
self.copy("LICENSE", dst="licenses", src=self._source_subfolder) | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.install() | ||
tools.rmdir(os.path.join(self.package_folder, "share")) | ||
|
||
def package_id(self): | ||
self.info.header_only() | ||
|
||
def package_info(self): | ||
if self.options.with_openssl: | ||
self.cpp_info.defines.append("CPPHTTPLIB_OPENSSL_SUPPORT") | ||
if self.options.with_zlib: | ||
self.cpp_info.defines.append("CPPHTTPLIB_ZLIB_SUPPORT") | ||
if self.settings.os == "Linux": | ||
self.cpp_info.system_libs.append("pthread") | ||
self.cpp_info.includedirs = ["include", os.path.join("include", "httplib")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 2.8.11) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
|
||
from conans import ConanFile, CMake, tools | ||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <httplib.h> | ||
|
||
int main() { | ||
httplib::Server svr; | ||
|
||
svr.Get("/hi", [](const httplib::Request& req, httplib::Response& res) { | ||
res.set_content("Hello World!", "text/plain"); | ||
}); | ||
|
||
svr.Get(R"(/numbers/(\d+))", [&](const httplib::Request& req, httplib::Response& res) { | ||
auto numbers = req.matches[1]; | ||
res.set_content(numbers, "text/plain"); | ||
}); | ||
|
||
svr.Get("/stop", [&](const httplib::Request& req, httplib::Response& res) { | ||
svr.stop(); | ||
}); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"0.5.4": | ||
folder: all |