Skip to content

Commit

Permalink
(#16040) out_ptr: modernize more for conan v2
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceIm authored Mar 10, 2023
1 parent 76501cd commit c89eefd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
17 changes: 12 additions & 5 deletions recipes/out_ptr/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,27 @@ class OutPtrConan(ConanFile):
homepage = "https://github.com/soasis/out_ptr"
description = "a C++11 implementation of std::out_ptr (p1132), as a standalone library"
topics = ("utility", "backport")
package_type = "header-library"
settings = "os", "arch", "build_type", "compiler"
no_copy_source = True

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

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

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

def source(self):
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 build(self):
pass

def package(self):
copy(self, "*.hpp", src=os.path.join(self.source_folder, "include"),
dst=os.path.join(self.package_folder, "include"))
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))

def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []
11 changes: 6 additions & 5 deletions recipes/out_ptr/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
from conan import ConanFile
from conan.tools.build import cross_building
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os


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

def requirements(self):
self.requires(self.tested_reference_str)
test_type = "explicit"

def layout(self):
cmake_layout(self)

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

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

def test(self):
if not cross_building(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
11 changes: 4 additions & 7 deletions recipes/out_ptr/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)
cmake_minimum_required(VERSION 3.1)
project(test_package)

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

find_package(out_ptr CONFIG REQUIRED)

add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE out_ptr::out_ptr)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
${CMAKE_CURRENT_BINARY_DIR}/test_package)
1 change: 0 additions & 1 deletion recipes/out_ptr/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: skip-file
from conans import ConanFile, CMake, tools
import os

Expand Down

0 comments on commit c89eefd

Please sign in to comment.