Skip to content

Commit b1fea88

Browse files
committed
Add conanfile and test consumer package
1 parent 14c5cda commit b1fea88

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

conanfile.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from conans import ConanFile
2+
3+
4+
class ScopeguardConan(ConanFile):
5+
name = "scope_guard"
6+
version = "0.2.3"
7+
license = "The Unlicense"
8+
author = "Ricardo Abreu [email protected]"
9+
url = "https://github.com/Lawrencemm/scope_guard"
10+
description = (
11+
"A modern C++ scope guard that is easy to use but hard to misuse. "
12+
"https://ricab.github.io/scope_guard/"
13+
)
14+
topics = ("scope guard", "RAII", "resource management")
15+
exports_sources = "scope_guard.hpp"
16+
no_copy_source = True
17+
18+
def package(self):
19+
self.copy("*scope_guard.hpp", dst="include")

test_package/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(PackageTest CXX)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
6+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
7+
conan_basic_setup()
8+
9+
add_executable(example example.cpp)
10+
target_link_libraries(example ${CONAN_LIBS})

test_package/conanfile.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
3+
from conans import ConanFile, CMake, tools
4+
5+
6+
class ScopeguardTestConan(ConanFile):
7+
settings = "os", "compiler", "build_type", "arch"
8+
generators = "cmake"
9+
10+
def build(self):
11+
cmake = CMake(self)
12+
cmake.configure()
13+
cmake.build()
14+
15+
def test(self):
16+
if not tools.cross_building(self.settings):
17+
os.chdir("bin")
18+
self.run(".%sexample" % os.sep)

test_package/example.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <iostream>
2+
3+
#include <scope_guard.hpp>
4+
5+
int main() {
6+
auto guard = sg::make_scope_guard([]() noexcept { return; });
7+
}

0 commit comments

Comments
 (0)