Skip to content

Instantly share code, notes, and snippets.

@mmatrosov
Created November 2, 2017 16:35
Show Gist options
  • Save mmatrosov/b636cb0c5ca1c355afd00bb0f9f7f1d4 to your computer and use it in GitHub Desktop.
Save mmatrosov/b636cb0c5ca1c355afd00bb0f9f7f1d4 to your computer and use it in GitHub Desktop.

Revisions

  1. mmatrosov created this gist Nov 2, 2017.
    41 changes: 41 additions & 0 deletions conanfile.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    from conans import ConanFile, CMake, tools


    class GooglebenchmarkConan(ConanFile):
    name = "google-benchmark"
    version = "1.2.0"
    license = "<Put the package license here>"
    url = "<Package recipe repository url here, for issues about the package>"
    description = "<Description of Googlebenchmark here>"
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False]}
    default_options = "shared=False"
    generators = "cmake"

    def source(self):
    self.run("git clone https://github.com/google/benchmark.git")
    # This small hack might be useful to guarantee proper /MT /MD linkage in MSVC
    # if the packaged project doesn't have variables to set it properly
    tools.replace_in_file("benchmark/CMakeLists.txt", "project (benchmark)", '''project (benchmark)
    include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
    conan_basic_setup()''')

    def build(self):
    cmake = CMake(self)
    cmake.configure(source_dir="%s/benchmark" % self.source_folder)
    cmake.build()

    # Explicit way:
    # self.run('cmake %s/benchmark %s' % (self.source_folder, cmake.command_line))
    # self.run("cmake --build . %s" % cmake.build_config)

    def package(self):
    self.copy("*.h", dst="include", src="benchmark/include")
    self.copy("*benchmark.lib", dst="lib", keep_path=False)
    self.copy("*.dll", dst="bin", keep_path=False)
    self.copy("*.so", dst="lib", keep_path=False)
    self.copy("*.dylib", dst="lib", keep_path=False)
    self.copy("*.a", dst="lib", keep_path=False)

    def package_info(self):
    self.cpp_info.libs = ["benchmark"]