Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpprestsdk: add package_type + bump boost & openssl + remove package id boost minor mode #17096

Merged
merged 3 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
39 changes: 19 additions & 20 deletions recipes/cpprestsdk/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from conan import ConanFile
from conan.tools import files
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import (
apply_conandata_patches, collect_libs, copy, export_conandata_patches, get,
replace_in_file, rmdir
)
import os

required_conan_version = ">=1.53.0"
Expand All @@ -12,9 +15,9 @@ class CppRestSDKConan(ConanFile):
"C++ API design"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/Microsoft/cpprestsdk"
topics = ("cpprestsdk", "rest", "client", "http", "https")
topics = ("rest", "client", "http", "https")
license = "MIT"

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
Expand All @@ -36,7 +39,7 @@ class CppRestSDKConan(ConanFile):
}

def export_sources(self):
files.export_conandata_patches(self)
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
Expand All @@ -50,23 +53,19 @@ def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires("boost/1.80.0")
self.requires("openssl/1.1.1s")
self.requires("boost/1.81.0")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
self.requires("boost/1.81.0")
self.requires("boost/1.82.0")

self.requires("openssl/[>=1.1 <4]")
if self.options.with_compression:
self.requires("zlib/1.2.13")
if self.options.with_websockets:
self.requires("websocketpp/0.8.2")

def package_id(self):
self.info.requires["boost"].minor_mode()

def layout(self):
cmake_layout(self, src_folder="src")

def source(self):
files.get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
Expand All @@ -90,22 +89,22 @@ def generate(self):

def _patch_clang_libcxx(self):
if self.settings.compiler == 'clang' and str(self.settings.compiler.libcxx) in ['libstdc++', 'libstdc++11']:
files.replace_in_file(self, os.path.join(self.source_folder, 'Release', 'CMakeLists.txt'),
replace_in_file(self, os.path.join(self.source_folder, 'Release', 'CMakeLists.txt'),
'libc++', 'libstdc++')

def build(self):
files.apply_conandata_patches(self)
apply_conandata_patches(self)
self._patch_clang_libcxx()
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
files.copy(self, "license.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
copy(self, "license.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
cmake = CMake(self)
cmake.install()
files.rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
files.rmdir(self, os.path.join(self.package_folder, "lib", "cpprestsdk"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "cpprestsdk"))

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "cpprestsdk")
Expand All @@ -120,7 +119,7 @@ def package_info(self):
self.cpp_info.components["cpprestsdk_openssl_internal"].requires = ["openssl::openssl"]
# cpprest
self.cpp_info.components["cpprest"].set_property("cmake_target_name", "cpprestsdk::cpprest")
self.cpp_info.components["cpprest"].libs = files.collect_libs(self)
self.cpp_info.components["cpprest"].libs = collect_libs(self)
self.cpp_info.components["cpprest"].requires = ["cpprestsdk_boost_internal", "cpprestsdk_openssl_internal"]
if self.settings.os == "Linux":
self.cpp_info.components["cpprest"].system_libs.append("pthread")
Expand Down
8 changes: 4 additions & 4 deletions recipes/cpprestsdk/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

find_package(cpprestsdk REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} cpprestsdk::cpprest)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
target_link_libraries(${PROJECT_NAME} PRIVATE cpprestsdk::cpprest)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)