From 731c223492fe8d615e7a63e4304c75645e596617 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 26 Sep 2019 17:36:46 -0300 Subject: [PATCH] Add gflags Signed-off-by: Uilian Ries --- recipes/gflags/all/CMakeLists.txt | 8 +++ recipes/gflags/all/conandata.yml | 4 ++ recipes/gflags/all/conanfile.py | 69 +++++++++++++++++++ .../gflags/all/test_package/CMakeLists.txt | 10 +++ recipes/gflags/all/test_package/conanfile.py | 16 +++++ .../gflags/all/test_package/test_package.cpp | 12 ++++ recipes/gflags/config.yml | 4 ++ 7 files changed, 123 insertions(+) create mode 100644 recipes/gflags/all/CMakeLists.txt create mode 100644 recipes/gflags/all/conandata.yml create mode 100644 recipes/gflags/all/conanfile.py create mode 100644 recipes/gflags/all/test_package/CMakeLists.txt create mode 100644 recipes/gflags/all/test_package/conanfile.py create mode 100644 recipes/gflags/all/test_package/test_package.cpp create mode 100644 recipes/gflags/config.yml diff --git a/recipes/gflags/all/CMakeLists.txt b/recipes/gflags/all/CMakeLists.txt new file mode 100644 index 0000000000000..5544c114ce2e6 --- /dev/null +++ b/recipes/gflags/all/CMakeLists.txt @@ -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") diff --git a/recipes/gflags/all/conandata.yml b/recipes/gflags/all/conandata.yml new file mode 100644 index 0000000000000..f438b0ba1c510 --- /dev/null +++ b/recipes/gflags/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.2.2": + sha256: 34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf + url: https://github.com/gflags/gflags/archive/v2.2.2.tar.gz diff --git a/recipes/gflags/all/conanfile.py b/recipes/gflags/all/conanfile.py new file mode 100644 index 0000000000000..d8f3e88cb0076 --- /dev/null +++ b/recipes/gflags/all/conanfile.py @@ -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"]) diff --git a/recipes/gflags/all/test_package/CMakeLists.txt b/recipes/gflags/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..56a1bba89a19d --- /dev/null +++ b/recipes/gflags/all/test_package/CMakeLists.txt @@ -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}) diff --git a/recipes/gflags/all/test_package/conanfile.py b/recipes/gflags/all/test_package/conanfile.py new file mode 100644 index 0000000000000..79062f5522c62 --- /dev/null +++ b/recipes/gflags/all/test_package/conanfile.py @@ -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) diff --git a/recipes/gflags/all/test_package/test_package.cpp b/recipes/gflags/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..52d36fe7643c5 --- /dev/null +++ b/recipes/gflags/all/test_package/test_package.cpp @@ -0,0 +1,12 @@ +#include +#include + +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; +} diff --git a/recipes/gflags/config.yml b/recipes/gflags/config.yml new file mode 100644 index 0000000000000..0eb4bc4ba8e82 --- /dev/null +++ b/recipes/gflags/config.yml @@ -0,0 +1,4 @@ +--- +versions: + "2.2.2": + folder: all