-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from uilianries/feature/gflags
Add gflags 2.2.2
- Loading branch information
Showing
7 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
versions: | ||
"2.2.2": | ||
folder: all |