Skip to content

Commit

Permalink
Merge pull request #119 from uilianries/feature/gflags
Browse files Browse the repository at this point in the history
Add gflags 2.2.2
  • Loading branch information
lasote committed Sep 27, 2019
2 parents 619e8eb + 731c223 commit a34458e
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 0 deletions.
8 changes: 8 additions & 0 deletions recipes/gflags/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 2.8.12)
project(cmake_wrapper)

message("Conan CMake Wrapper")
include("conanbuildinfo.cmake")
conan_basic_setup()

add_subdirectory("source_subfolder")
4 changes: 4 additions & 0 deletions recipes/gflags/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"2.2.2":
sha256: 34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf
url: https://github.com/gflags/gflags/archive/v2.2.2.tar.gz
69 changes: 69 additions & 0 deletions recipes/gflags/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from conans import ConanFile, CMake, tools
import os


class GflagsConan(ConanFile):
name = "gflags"
description = "The gflags package contains a C++ library that implements commandline flags processing"
topics = ("conan", "gflags", "cli", "flags", "commandline")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/gflags/gflags"
license = 'BSD-3-Clause'
exports = ["LICENSE.md"]
exports_sources = ["CMakeLists.txt"]
generators = "cmake"
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False], "nothreads": [True, False], "namespace": "ANY"}
default_options = {'shared': False, 'fPIC': True, 'nothreads': True, 'namespace': 'gflags'}

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def configure(self):
if self.settings.os == "Windows":
del self.options.fPIC

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename("%s-%s" % (self.name, self.version), self._source_subfolder)

def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared
cmake.definitions["BUILD_STATIC_LIBS"] = not self.options.shared
cmake.definitions["BUILD_gflags_LIB"] = not self.options.nothreads
cmake.definitions["BUILD_gflags_nothreads_LIB"] = self.options.nothreads
cmake.definitions["BUILD_PACKAGING"] = False
cmake.definitions["BUILD_TESTING"] = False
cmake.definitions["INSTALL_HEADERS"] = True
cmake.definitions["INSTALL_SHARED_LIBS"] = self.options.shared
cmake.definitions["INSTALL_STATIC_LIBS"] = not self.options.shared
cmake.definitions["REGISTER_BUILD_DIR"] = False
cmake.definitions["REGISTER_INSTALL_PREFIX"] = False
cmake.definitions["GFLAGS_NAMESPACE"] = self.options.namespace
cmake.configure(build_folder=self._build_subfolder)
return cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("COPYING.txt", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
if self.settings.os == "Windows":
self.cpp_info.libs.extend(['shlwapi'])
elif self.settings.os == "Linux":
self.cpp_info.libs.extend(["pthread", "m"])
10 changes: 10 additions & 0 deletions recipes/gflags/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8.12)
project(test_package)

set(CMAKE_VERBOSE_MAKEFILE TRUE)

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

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
16 changes: 16 additions & 0 deletions recipes/gflags/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from conans import ConanFile, CMake, tools
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):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
12 changes: 12 additions & 0 deletions recipes/gflags/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <iostream>
#include <gflags/gflags.h>

DEFINE_bool(big_menu, true, "Include 'advanced' options in the menu listing");
DEFINE_string(languages, "english,french,german",
"comma-separated list of languages to offer in the 'lang' menu");

int main(int argc, char **argv) {
GFLAGS_NAMESPACE::ShowUsageWithFlags(argv[0]);
GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
return 0;
}
4 changes: 4 additions & 0 deletions recipes/gflags/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
versions:
"2.2.2":
folder: all

0 comments on commit a34458e

Please sign in to comment.