Skip to content

Commit

Permalink
(#8593) pistache: fix gcc11 + modernize
Browse files Browse the repository at this point in the history
* fix gcc11

* modernize

* bump openssl

* fix patch
  • Loading branch information
SpaceIm authored Jan 7, 2022
1 parent 5e1d52b commit 3ec7e70
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 22 deletions.
2 changes: 2 additions & 0 deletions recipes/pistache/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ patches:
"cci.20201127":
- patch_file: "patches/0001-remove-fpic.patch"
base_path: "source_subfolder"
- patch_file: "patches/0002-include-stddef.patch"
base_path: "source_subfolder"
50 changes: 31 additions & 19 deletions recipes/pistache/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import os
import glob
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os


required_conan_version = ">=1.29.1"
required_conan_version = ">=1.33.0"


class PistacheConan(ConanFile):
Expand All @@ -14,10 +12,19 @@ class PistacheConan(ConanFile):
url = "https://github.com/conan-io/conan-center-index"
topics = ("http", "rest", "framework", "networking")
description = "Pistache is a modern and elegant HTTP and REST framework for C++"
settings = "os", "compiler", "arch", "build_type"
options = {"shared": [True, False], "fPIC": [True, False], "with_ssl": [True, False]}
default_options = {"shared": False, "fPIC": True, "with_ssl": False}
exports_sources = ["CMakeLists.txt", "patches/*"]

settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_ssl": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_ssl": False,
}

generators = "cmake", "cmake_find_package"
_cmake = None

Expand All @@ -29,7 +36,21 @@ def _source_subfolder(self):
def _build_subfolder(self):
return "build_subfolder"

def export_sources(self):
self.copy("CMakeLists.txt")
for patch in self.conan_data.get("patches", {}).get(self.version, []):
self.copy(patch["patch_file"])

def configure(self):
if self.options.shared:
del self.options.fPIC

def requirements(self):
self.requires("rapidjson/1.1.0")
if self.options.with_ssl:
self.requires("openssl/1.1.1m")

def validate(self):
compilers = {
"gcc": "7",
"clang": "6",
Expand All @@ -40,9 +61,6 @@ def configure(self):
if self.settings.compiler == "clang":
raise ConanInvalidConfiguration("Clang support is broken. See pistacheio/pistache#835.")

if self.options.shared:
del self.options.fPIC

if self.settings.compiler.cppstd:
tools.check_min_cppstd(self, 17)
minimum_compiler = compilers.get(str(self.settings.compiler))
Expand All @@ -52,15 +70,9 @@ def configure(self):
else:
self.output.warn("Pistache requires c++17, but this compiler is unknown to this recipe. Assuming your compiler supports c++17.")

def requirements(self):
self.requires("rapidjson/1.1.0")
if self.options.with_ssl:
self.requires("openssl/1.1.1i")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = glob.glob("pistache-*")[0]
os.rename(extracted_dir, self._source_subfolder)
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def _configure_cmake(self):
if self._cmake:
Expand Down
12 changes: 12 additions & 0 deletions recipes/pistache/all/patches/0002-include-stddef.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fixed upstream https://github.com/pistacheio/pistache/pull/965

--- a/include/pistache/typeid.h
+++ b/include/pistache/typeid.h
@@ -11,6 +11,7 @@

#pragma once

+#include <cstddef>
#include <functional>

namespace Pistache {
2 changes: 1 addition & 1 deletion recipes/pistache/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
conan_basic_setup(TARGETS)

find_package(Pistache REQUIRED CONFIG)

Expand Down
4 changes: 2 additions & 2 deletions recipes/pistache/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

def build(self):
Expand All @@ -12,6 +12,6 @@ def build(self):
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)

0 comments on commit 3ec7e70

Please sign in to comment.