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

reflect-cpp: add option for using with msgpack #24262

Merged
merged 2 commits into from
Jun 13, 2024
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
4 changes: 4 additions & 0 deletions recipes/reflect-cpp/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ class ReflectCppConan(ConanFile):
"with_xml" : [True, False],
"with_flatbuffers" : [True, False],
"with_yaml": [True, False],
"with_msgpack": [True, False],
}
default_options = {
"with_json" : False,
"with_xml" : False,
"with_flatbuffers" : False,
"with_yaml" : False,
"with_msgpack": False,
}

@property
Expand Down Expand Up @@ -56,6 +58,8 @@ def requirements(self):
self.requires("flatbuffers/23.5.26", transitive_headers=True)
if self.options.with_yaml:
self.requires("yaml-cpp/0.8.0", transitive_headers=True)
if self.options.with_msgpack:
self.requires("msgpack-c/6.0.0", transitive_headers=True)

def package_id(self):
self.info.clear()
Expand Down
10 changes: 5 additions & 5 deletions recipes/reflect-cpp/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
cmake_minimum_required(VERSION 3.12)
project(test_package LANGUAGES CXX)

if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(reflect-cpp REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE reflect-cpp::reflect-cpp)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)

if(CONAN_TEST_WITH_MSGPACK)
target_compile_definitions(${PROJECT_NAME} PRIVATE CONAN_TEST_WITH_MSGPACK)
endif()
10 changes: 8 additions & 2 deletions recipes/reflect-cpp/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
import os


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

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def generate(self):
tc = CMakeToolchain(self)
if self.dependencies[self.tested_reference_str].options.with_msgpack:
tc.cache_variables["CONAN_TEST_WITH_MSGPACK"] = True
tc.generate()

def build(self):
cmake = CMake(self)
Expand Down
14 changes: 14 additions & 0 deletions recipes/reflect-cpp/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#include <string>
#include <iostream>
#include <rfl.hpp>

#if defined(CONAN_TEST_WITH_MSGPACK)
#include <rfl/msgpack.hpp>
#endif

struct TestStruct {
int x;
std::string name;
Expand All @@ -11,5 +16,14 @@ int main(void) {
(void) f.name();
(void) f.type();
}

#if defined(CONAN_TEST_WITH_MSGPACK)
const auto test = TestStruct{.x = 15, .name = "test_package"};
std::cout << "msgpack test: ";
rfl::msgpack::write(test, std::cout) << std::endl;
#endif

std::cout << "reflect-cpp test successful\n";

return 0;
}
9 changes: 0 additions & 9 deletions recipes/reflect-cpp/all/test_v1_package/CMakeLists.txt

This file was deleted.

18 changes: 0 additions & 18 deletions recipes/reflect-cpp/all/test_v1_package/conanfile.py

This file was deleted.

Loading