Skip to content

Commit

Permalink
Conan support (#19)
Browse files Browse the repository at this point in the history
* added conan recipe and test_package

* Reduced test package and updated conanfile
  • Loading branch information
danimtb authored and adishavit committed Jan 28, 2018
1 parent a0d80a8 commit 1df56d3
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
16 changes: 16 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from conans import ConanFile
import os


class ArghConan(ConanFile):
name = "argh"
version = "1.2.0"
url = "https://github.com/adishavit/argh"
description = "Argh! A minimalist argument handler."
license = "BSD 3-Clause"
exports = ["LICENSE"]
exports_sources = "*.h"

def package(self):
self.copy(pattern="LICENSE", dst="license")
self.copy(pattern="argh.h", dst="include")
8 changes: 8 additions & 0 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
project(test_package)
cmake_minimum_required(VERSION 2.8.11)

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

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
19 changes: 19 additions & 0 deletions test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from conans import ConanFile, CMake, tools, RunEnvironment
import os


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

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

def test(self):
with tools.environment_append(RunEnvironment(self).vars):
self.run("%s -v" % os.path.join("bin", "test_package"))
14 changes: 14 additions & 0 deletions test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <iostream>

#include <argh.h>

int main(int argc, char* argv[])
{
argh::parser cmdl;
cmdl.parse(argc, argv, argh::parser::PREFER_PARAM_FOR_UNREG_OPTION);

if (cmdl["-v"])
std::cout << "Verbose, I am." << std::endl;

return EXIT_SUCCESS;
}

0 comments on commit 1df56d3

Please sign in to comment.