forked from alasdairmackintosh/google-concurrency-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
78 lines (65 loc) · 3.09 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
from conan.tools.build import check_min_cppstd, can_run, cross_building
import os
class gclRecipe(ConanFile):
name = "gcl"
version = "0.9.1"
# Optional metadata
license = "<Put the package license here>"
author = "<Put your name here> <And your email here>"
url = "https://github.com/existedinnettw/google-concurrency-library"
description = " Export several internal C++ Google concurrency libraries with modern building support"
topics = ("gcl", "pipeline", "c++14")
# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = "CMakeLists.txt", "*.in", "src/*", "include/*", "samples/*", "testing/*"
# exports_sources="./*"
requires = (["openssl/[~3]", "zlib/[~1]"]) # >=1.0 <2.0, #openssl ver 3 will show deprecate warn for sample dedup.
# def requirements(self):
# self.requires(["openssl/[~3]", "zlib/[~1]"]) #>=1.0 <2.0 #not work
def build_requirements(self):
self.test_requires("gtest/[~1.12]") # recipe forbid 13 for gcc5
self.tool_requires("cmake/[>=3.23 <=3.26]")
def validate(self):
check_min_cppstd(self, "14")
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def layout(self):
cmake_layout(self)
def generate(self):
tc = CMakeToolchain(self)
tc.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
if (not self.conf.get("tools.build:skip_test", default=False)) and can_run(self):
# test_folder = os.path.join("tests")
# if self.settings.os == "Windows":
# test_folder = os.path.join("tests", str(self.settings.build_type))
# self.run(os.path.join(test_folder, "test_hello"))
cmake.test()
def package(self):
cmake = CMake(self)
cmake.install()
def package_info(self):
'''
conan package is relevent to cmake package. conan only get information of
cmake target. And with have to make that target a conan package(libs) under following.
'''
self.cpp_info.libs = ["goocon"] # The libs to link against. still target_link_lib it by gcl::gcl
# self.cpp_info.system_libs.append("pthread")
# self.cpp_info.system_libs = [] # System libs to link against
#another name to find_package
#method1
self.cpp_info.set_property("cmake_target_name", "gcl::goocon")
#method2
# self.cpp_info.components["goocon"].set_property("cmake_target_name", "gcl::goocon")
# self.cpp_info.components["goocon"].libs=["goocon"]
# self.cpp_info.components["goocon"].system_libs.append("pthread") #this work
# self.cpp_info.components["goocon"].system_libs=self.cpp_info.system_libs #not work