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

rapidjson: Conan 2.0 migration #12935

Merged
merged 7 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 13 additions & 11 deletions recipes/rapidjson/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
from conans import ConanFile, tools
from conan import ConanFile
from conan.tools.files import get, copy
import os

required_conan_version = ">=1.33.0"
required_conan_version = ">=1.46.0"
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved


class RapidjsonConan(ConanFile):
name = "rapidjson"
description = "A fast JSON parser/generator for C++ with both SAX/DOM style API"
topics = ("conan", "rapidjson", "json", "parser", "generator")
topics = ("rapidjson", "json", "parser", "generator")
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://rapidjson.org"
license = "MIT"
no_copy_source = True
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved

@property
def _source_subfolder(self):
return "source_subfolder"

def source(self):
tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)
get(self, **self.conan_data["sources"][self.version], strip_root=True,
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
destination=self.source_folder)

def package(self):
self.copy(pattern="license.txt", dst="licenses", src=self._source_subfolder)
self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include"))
copy(self, pattern="license.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
copy(self, pattern="*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include"))

def package_id(self):
self.info.header_only()
self.info.clear()

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "RapidJSON")
self.cpp_info.set_property("cmake_target_name", "RapidJSON::RapidJSON")
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved

# TODO: to remove in conan v2 once cmake_find_package* generators removed
self.cpp_info.names["cmake_find_package"] = "RapidJSON"
self.cpp_info.names["cmake_find_package_multi"] = "RapidJSON"
19 changes: 14 additions & 5 deletions recipes/rapidjson/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
from conans import ConanFile, CMake, tools
import os
from conan import ConanFile
from conan.tools.cmake import CMake
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved

required_conan_version = ">=1.50.0"

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

prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

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)
if can_run(self):
self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun")
10 changes: 10 additions & 0 deletions recipes/rapidjson/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved

find_package(RapidJSON CONFIG REQUIRED)

add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE RapidJSON::RapidJSON)
17 changes: 17 additions & 0 deletions recipes/rapidjson/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
import os


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

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)