-
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.
- Loading branch information
Showing
11 changed files
with
335 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
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,7 @@ | ||
cmake_minimum_required(VERSION 2.8.11) | ||
project(cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
include(${CMAKE_SOURCE_DIR}/CMakeListsOriginal.txt) |
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 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
import os | ||
|
||
if os.getenv("APPVEYOR_REPO_TAG") != "true": | ||
print("Skip build step. It's not TAG") | ||
else: | ||
os.system("python conan/build.py") |
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 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
import os | ||
|
||
if os.getenv("APPVEYOR_REPO_TAG") != "true": | ||
print("Skip step. It's not TAG") | ||
else: | ||
os.system("pip install conan conan-package-tools") |
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,36 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
from cpt.packager import ConanMultiPackager | ||
import os | ||
|
||
def set_appveyor_environment(): | ||
if os.getenv("APPVEYOR") is not None: | ||
compiler_version = os.getenv("CMAKE_VS_VERSION").split(" ")[0].replace('"', '') | ||
os.environ["CONAN_VISUAL_VERSIONS"] = compiler_version | ||
os.environ["CONAN_STABLE_BRANCH_PATTERN"] = "master" | ||
ci_platform = os.getenv("Platform").replace('"', '') | ||
ci_platform = "x86" if ci_platform == "x86" else "x86_64" | ||
os.environ["CONAN_ARCHS"] = ci_platform | ||
os.environ["CONAN_BUILD_TYPES"] = os.getenv("Configuration").replace('"', '') | ||
|
||
if __name__ == "__main__": | ||
login_username = os.getenv("CONAN_LOGIN_USERNAME") | ||
username = os.getenv("CONAN_USERNAME") | ||
reference = os.getenv("CONAN_REFERENCE") | ||
channel = os.getenv("CONAN_CHANNEL") | ||
upload = os.getenv("CONAN_UPLOAD") | ||
stable_branch_pattern = os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+.*") | ||
test_folder = os.getenv("CPT_TEST_FOLDER", os.path.join("conan", "test_package")) | ||
upload_only_when_stable = os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True) | ||
set_appveyor_environment() | ||
|
||
builder = ConanMultiPackager(username=username, | ||
reference=reference, | ||
channel=channel, | ||
login_username=login_username, | ||
upload=upload, | ||
stable_branch_pattern=stable_branch_pattern, | ||
upload_only_when_stable=upload_only_when_stable, | ||
test_folder=test_folder) | ||
builder.add_common_builds(pure_c=False) | ||
builder.run() |
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 @@ | ||
project(test_package) | ||
cmake_minimum_required(VERSION 2.8.11) | ||
|
||
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,20 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 | ||
|
||
from conans import ConanFile, CMake | ||
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,18 @@ | ||
#include "benchmark/benchmark.h" | ||
|
||
void BM_StringCreation(benchmark::State& state) { | ||
while (state.KeepRunning()) | ||
std::string empty_string; | ||
} | ||
|
||
BENCHMARK(BM_StringCreation); | ||
|
||
void BM_StringCopy(benchmark::State& state) { | ||
std::string x = "hello"; | ||
while (state.KeepRunning()) | ||
std::string copy(x); | ||
} | ||
|
||
BENCHMARK(BM_StringCopy); | ||
|
||
BENCHMARK_MAIN(); |
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,14 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
if [[ "$(uname -s)" == 'Darwin' ]]; then | ||
if which pyenv > /dev/null; then | ||
eval "$(pyenv init -)" | ||
fi | ||
pyenv activate conan | ||
fi | ||
|
||
conan user | ||
python conan/build.py |
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,22 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
if [[ "$(uname -s)" == 'Darwin' ]]; then | ||
brew update || brew update | ||
brew outdated pyenv || brew upgrade pyenv | ||
brew install pyenv-virtualenv | ||
brew install cmake || true | ||
|
||
if which pyenv > /dev/null; then | ||
eval "$(pyenv init -)" | ||
fi | ||
|
||
pyenv install 2.7.10 | ||
pyenv virtualenv 2.7.10 conan | ||
pyenv rehash | ||
pyenv activate conan | ||
fi | ||
|
||
pip install -U conan_package_tools conan |
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,82 @@ | ||
from conans import ConanFile, CMake, tools | ||
import shutil | ||
import os | ||
|
||
|
||
class GoogleBenchmarkConan(ConanFile): | ||
name = "benchmark" | ||
description = "A microbenchmark support library." | ||
url = "https://github.com/google/benchmark" | ||
homepage = "https://github.com/google/benchmark" | ||
license = "Apache-2.0" | ||
settings = "arch", "build_type", "compiler", "os" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"enable_exceptions": [True, False], | ||
"enable_lto": [True, False], | ||
"enable_testing": [True, False], | ||
"enable_gtest_tests": [True, False] | ||
} | ||
default_options = "shared=False", "fPIC=True", "enable_exceptions=True", "enable_lto=False", "enable_testing=False", "enable_gtest_tests=False" | ||
exports_sources = ["*"] | ||
generators = "cmake" | ||
|
||
build_subfolder = "." | ||
|
||
def source(self): | ||
"""Wrap the original CMake file to call conan_basic_setup | ||
""" | ||
shutil.move("CMakeLists.txt", "CMakeListsOriginal.txt") | ||
shutil.move(os.path.join("conan", "CMakeLists.txt"), "CMakeLists.txt") | ||
|
||
def config_options(self): | ||
if self.settings.os == 'Windows': | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.settings.os == 'Windows' and self.options.shared: | ||
raise Exception("Windows shared builds are not supported right now, see issue #639") | ||
|
||
if self.options.enable_testing == False: | ||
self.options.enable_gtest_tests = False | ||
|
||
def _configure_cmake(self): | ||
cmake = CMake(self) | ||
cmake.definitions['BENCHMARK_ENABLE_TESTING'] = "ON" if self.options.enable_testing else "OFF" | ||
cmake.definitions['BENCHMARK_ENABLE_GTEST_TESTS'] = "ON" if self.options.enable_gtest_tests and self.options.enable_testing else "OFF" | ||
cmake.definitions["BENCHMARK_ENABLE_LTO"] = "ON" if self.options.enable_lto else "OFF" | ||
cmake.definitions["BENCHMARK_ENABLE_EXCEPTIONS"] = "ON" if self.options.enable_exceptions else "OFF" | ||
|
||
# See https://github.com/google/benchmark/pull/638 for Windows 32 build explanation | ||
if self.settings.os != "Windows": | ||
cmake.definitions["BENCHMARK_BUILD_32_BITS"] = "ON" if "64" not in str(self.settings.arch) else "OFF" | ||
cmake.definitions["BENCHMARK_USE_LIBCXX"] = "ON" if (str(self.settings.compiler.libcxx) == "libc++") else "OFF" | ||
else: | ||
cmake.definitions["BENCHMARK_USE_LIBCXX"] = "OFF" | ||
|
||
cmake.configure(build_folder=self.build_subfolder) | ||
return cmake | ||
|
||
def build_requirements(self): | ||
if self.options.enable_gtest_tests: | ||
self.build_requires("gtest/1.8.0@bincrafters/stable") | ||
|
||
def build(self): | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def package(self): | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
|
||
self.copy(pattern="LICENSE", dst="licenses") | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = tools.collect_libs(self) | ||
if self.settings.os == "Linux": | ||
self.cpp_info.libs.extend(["pthread", "rt"]) | ||
elif self.settings.os == "Windows": | ||
self.cpp_info.libs.append("shlwapi") | ||
elif self.settings.os == "SunOS": | ||
self.cpp.info.libs.append("kstat") |