From b1fea88e77d2da1290d5cf3c12fcf0bc0d7935d8 Mon Sep 17 00:00:00 2001 From: Lawrence Millar-Madigan Date: Fri, 19 Apr 2019 12:04:25 +1000 Subject: [PATCH] Add conanfile and test consumer package --- conanfile.py | 19 +++++++++++++++++++ test_package/CMakeLists.txt | 10 ++++++++++ test_package/conanfile.py | 18 ++++++++++++++++++ test_package/example.cpp | 7 +++++++ 4 files changed, 54 insertions(+) create mode 100644 conanfile.py create mode 100644 test_package/CMakeLists.txt create mode 100644 test_package/conanfile.py create mode 100644 test_package/example.cpp diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..e401cc4 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile + + +class ScopeguardConan(ConanFile): + name = "scope_guard" + version = "0.2.3" + license = "The Unlicense" + author = "Ricardo Abreu ricardo.abreu@canonical.com" + url = "https://github.com/Lawrencemm/scope_guard" + description = ( + "A modern C++ scope guard that is easy to use but hard to misuse. " + "https://ricab.github.io/scope_guard/" + ) + topics = ("scope guard", "RAII", "resource management") + exports_sources = "scope_guard.hpp" + no_copy_source = True + + def package(self): + self.copy("*scope_guard.hpp", dst="include") diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt new file mode 100644 index 0000000..b812380 --- /dev/null +++ b/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.10) +project(PackageTest CXX) + +set(CMAKE_CXX_STANDARD 17) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(example example.cpp) +target_link_libraries(example ${CONAN_LIBS}) diff --git a/test_package/conanfile.py b/test_package/conanfile.py new file mode 100644 index 0000000..f272329 --- /dev/null +++ b/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class ScopeguardTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + os.chdir("bin") + self.run(".%sexample" % os.sep) diff --git a/test_package/example.cpp b/test_package/example.cpp new file mode 100644 index 0000000..2f83c5d --- /dev/null +++ b/test_package/example.cpp @@ -0,0 +1,7 @@ +#include + +#include + +int main() { + auto guard = sg::make_scope_guard([]() noexcept { return; }); +}