Skip to content

Commit 7e3a40b

Browse files
laci-aurapraetorian20
authored andcommitted
liblifthttp: add new recipe and publish version 4.4.2 (conan-io#27532)
* added lifthttp recipe * added support for shared build * removed deprecated stdc++fs dependency * added version 4.4.1 * added version 4.4.2 * Revert "added version 4.4.1" This reverts commit 48146fa. * removed version 4.4.0 * applied PR review suggestions * set uv cmake target name to libuv::uv * added windows shared build error * fixed is_msvc import * added layout method * changed name to liblifthttp
1 parent ee8cdc6 commit 7e3a40b

File tree

7 files changed

+140
-0
lines changed

7 files changed

+140
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
find_package(CURL REQUIRED)
2+
find_package(libuv REQUIRED)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sources:
2+
"4.4.2":
3+
url: "https://github.com/jbaldwin/liblifthttp/archive/refs/tags/v4.4.2.tar.gz"
4+
sha256: "093ad71d95853ea6006ccefba0e68de945493d8a320e23fd5dbf64eecb1aacc5"
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
from conan import ConanFile
2+
from conan.tools.build import check_min_cppstd
3+
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
4+
from conan.tools.files import copy, get
5+
from conan.tools.microsoft import is_msvc
6+
from conan.errors import ConanInvalidConfiguration
7+
8+
import os
9+
10+
required_conan_version = ">=2.0.9"
11+
12+
class LiftHttpConan(ConanFile):
13+
name = "liblifthttp"
14+
description = "Safe and easy to use C++17 HTTP client library."
15+
license = "Apache-2.0"
16+
url = "https://github.com/conan-io/conan-center-index"
17+
homepage = "https://github.com/jbaldwin/liblifthttp"
18+
topics = ("cpp", "async", "asynchronous", "http", "https", "web", "client")
19+
package_type = "library"
20+
settings = "os", "arch", "compiler", "build_type"
21+
options = {
22+
"shared": [True, False],
23+
"fPIC": [True, False],
24+
}
25+
default_options = {
26+
"shared": False,
27+
"fPIC": True,
28+
}
29+
30+
def export_sources(self):
31+
copy(self, "conan_deps.cmake", self.recipe_folder, os.path.join(self.export_sources_folder, "src"))
32+
33+
def config_options(self):
34+
if self.settings.os == "Windows":
35+
del self.options.fPIC
36+
37+
def configure(self):
38+
if self.options.shared:
39+
self.options.rm_safe("fPIC")
40+
41+
def layout(self):
42+
cmake_layout(self, src_folder="src")
43+
44+
def requirements(self):
45+
self.requires("libcurl/[>=7.88.0 <9]", transitive_headers=True)
46+
self.requires("libuv/[>=1.45.0 <2]", transitive_headers=True)
47+
48+
def source(self):
49+
get(self, **self.conan_data["sources"][self.version], strip_root=True)
50+
def validate(self):
51+
check_min_cppstd(self, 17)
52+
if is_msvc(self) and self.options.shared:
53+
# INFO: It lacks of exposing symbols in a .lib
54+
raise ConanInvalidConfiguration("The project does not support Windows shared build.")
55+
56+
def generate(self):
57+
tc = CMakeToolchain(self)
58+
tc.variables["CMAKE_PROJECT_lifthttp_INCLUDE"] = "conan_deps.cmake"
59+
tc.variables["LIFT_BUILD_EXAMPLES"] = False
60+
tc.variables["LIFT_BUILD_TESTS"] = False
61+
tc.variables["LIFT_USER_LINK_LIBRARIES"] = "CURL::libcurl;libuv::uv"
62+
if self.settings.os in ["Linux", "FreeBSD"]:
63+
tc.variables["LIFT_USER_LINK_LIBRARIES"] += ";pthread;dl"
64+
tc.generate()
65+
66+
deps = CMakeDeps(self)
67+
# INFO: Avoid guessing libuv target name as it changes according version/configuration
68+
deps.set_property("libuv", "cmake_target_name", "libuv::uv")
69+
deps.generate()
70+
71+
def build(self):
72+
cmake = CMake(self)
73+
cmake.configure()
74+
cmake.build()
75+
76+
def package(self):
77+
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
78+
copy(self, pattern="*.hpp", src=os.path.join(self.source_folder, "inc"), dst=os.path.join(self.package_folder, "include"))
79+
for pattern in ["*.a", "*.so*", "*.dylib", "*.lib"]:
80+
copy(self, pattern, src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
81+
copy(self, "*.dll", src=self.build_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False)
82+
83+
def package_info(self):
84+
self.cpp_info.set_property("cmake_file_name", "lifthttp")
85+
self.cpp_info.set_property("cmake_target_name", "lifthttp::lifthttp")
86+
self.cpp_info.libs = ["lifthttp"]
87+
if self.settings.os in ["Linux", "FreeBSD"]:
88+
self.cpp_info.system_libs.extend(["pthread", "dl"])
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
project(test_package CXX)
3+
4+
find_package(lifthttp REQUIRED)
5+
6+
add_executable(${PROJECT_NAME} test_package.cpp)
7+
target_link_libraries(${PROJECT_NAME} PRIVATE lifthttp::lifthttp)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from conan import ConanFile
2+
from conan.tools.build import can_run
3+
from conan.tools.cmake import cmake_layout, CMake
4+
import os
5+
6+
7+
class TestPackageConan(ConanFile):
8+
settings = "os", "arch", "compiler", "build_type"
9+
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
10+
test_type = "explicit"
11+
12+
def layout(self):
13+
cmake_layout(self)
14+
15+
def requirements(self):
16+
self.requires(self.tested_reference_str)
17+
18+
def build(self):
19+
cmake = CMake(self)
20+
cmake.configure()
21+
cmake.build()
22+
23+
def test(self):
24+
if can_run(self):
25+
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
26+
self.run(bin_path, env="conanrun")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <cstdlib>
2+
#include <cstdlib>
3+
#include <iostream>
4+
#include <lift/lift.hpp>
5+
6+
7+
int main() {
8+
std::cout << "lift status: " << lift::to_string(lift::lift_status::success) << std::endl;
9+
return EXIT_SUCCESS;
10+
}

recipes/liblifthttp/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
versions:
2+
"4.4.2":
3+
folder: all

0 commit comments

Comments
 (0)