diff --git a/.travis.yml b/.travis.yml index 168ed0b709..e2b111dce8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -117,6 +117,20 @@ matrix: - LIBCXX_BUILD=1 LIBCXX_SANITIZER=Thread - ENABLE_SANITIZER=1 - EXTRA_FLAGS="-stdlib=libc++ -g -O2 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" + - compiler: gcc + env: CONAN=True + language: python + python: "3.6" + before_script: + - pip install -U pip + before_install: + - pip --version + install: + - pip install conan + script: + - conan create . google/testing --build + after_success: + - exit 0 - os: osx osx_image: xcode8.3 compiler: clang diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000000..57ac1811ac --- /dev/null +++ b/conanfile.py @@ -0,0 +1,79 @@ +from conans import ConanFile, CMake, tools + + +class GoogleBenchmarkConan(ConanFile): + name = "benchmark" + version = "1.4.1" + 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 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): + tools.replace_in_file("CMakeLists.txt", "project (benchmark)", '''project (benchmark) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_basic_setup()''') + + 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 == "Solaris": + self.cpp.info.libs.append("kstat") diff --git a/releasing.md b/releasing.md index f0cd7010e3..4f7b53c0f2 100644 --- a/releasing.md +++ b/releasing.md @@ -4,6 +4,7 @@ * Ensure the project builds and tests run (sanity check only, obviously) * `parallel -j0 exec ::: test/*_test` can help ensure everything at least passes +* Update the version string in conanfile.py * Prepare release notes * `git log $(git describe --abbrev=0 --tags)..HEAD` gives you the list of commits between the last annotated tag and HEAD