Skip to content

Commit ef76c3e

Browse files
authored
Merge branch 'conan-io:master' into opentelemetry-cpp-1.8.2
2 parents bdf8603 + a9af1b4 commit ef76c3e

File tree

6 files changed

+56
-56
lines changed

6 files changed

+56
-56
lines changed

recipes/onnx/all/conanfile.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
from conan import ConanFile
22
from conan.errors import ConanInvalidConfiguration
3-
from conan.tools.build import check_min_cppstd
3+
from conan.tools.apple import fix_apple_shared_install_name
4+
from conan.tools.build import check_min_cppstd, cross_building
45
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
5-
from conan.tools.env import VirtualBuildEnv
6-
from conan.tools.files import apply_conandata_patches, copy, get, rmdir, save
6+
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
7+
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, save
78
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
89
from conan.tools.scm import Version
910
import os
1011
import textwrap
1112

12-
required_conan_version = ">=1.50.2 <1.51.0 || >=1.51.2"
13+
required_conan_version = ">=1.53.0"
1314

1415

1516
class OnnxConan(ConanFile):
@@ -20,6 +21,7 @@ class OnnxConan(ConanFile):
2021
homepage = "https://github.com/onnx/onnx"
2122
url = "https://github.com/conan-io/conan-center-index"
2223

24+
package_type = "library"
2325
settings = "os", "arch", "compiler", "build_type"
2426
options = {
2527
"shared": [True, False],
@@ -33,44 +35,47 @@ class OnnxConan(ConanFile):
3335
@property
3436
def _protobuf_version(self):
3537
# onnx < 1.9.0 doesn't support protobuf >= 3.18
36-
return "3.21.4" if Version(self.version) >= "1.9.0" else "3.17.1"
38+
return "3.21.9" if Version(self.version) >= "1.9.0" else "3.17.1"
3739

3840
def export_sources(self):
39-
for p in self.conan_data.get("patches", {}).get(self.version, []):
40-
copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder)
41+
export_conandata_patches(self)
4142

4243
def config_options(self):
4344
if self.settings.os == "Windows":
4445
del self.options.fPIC
4546

4647
def configure(self):
4748
if self.options.shared:
48-
del self.options.fPIC
49+
self.options.rm_safe("fPIC")
50+
51+
def layout(self):
52+
cmake_layout(self, src_folder="src")
4953

5054
def requirements(self):
51-
self.requires(f"protobuf/{self._protobuf_version}")
55+
self.requires(f"protobuf/{self._protobuf_version}", run=not cross_building(self), transitive_headers=True, transitive_libs=True)
5256

5357
def validate(self):
54-
if self.info.settings.compiler.cppstd:
58+
if self.settings.compiler.get_safe("cppstd"):
5559
check_min_cppstd(self, 11)
56-
if is_msvc(self) and self.info.options.shared:
60+
if is_msvc(self) and self.options.shared:
5761
raise ConanInvalidConfiguration("onnx shared is broken with Visual Studio")
5862

5963
def build_requirements(self):
60-
if hasattr(self, "settings_build"):
64+
if hasattr(self, "settings_build") and cross_building(self):
6165
self.tool_requires(f"protobuf/{self._protobuf_version}")
6266

63-
def layout(self):
64-
cmake_layout(self, src_folder="src")
65-
6667
def source(self):
67-
get(self, **self.conan_data["sources"][self.version],
68-
destination=self.source_folder, strip_root=True)
68+
get(self, **self.conan_data["sources"][self.version], strip_root=True)
6969

7070
def generate(self):
71+
env = VirtualBuildEnv(self)
72+
env.generate()
73+
if not cross_building(self):
74+
env = VirtualRunEnv(self)
75+
env.generate(scope="build")
7176
tc = CMakeToolchain(self)
7277
tc.variables["ONNX_BUILD_BENCHMARKS"] = False
73-
tc.variables["ONNX_USE_PROTOBUF_SHARED_LIBS"] = self.options["protobuf"].shared
78+
tc.variables["ONNX_USE_PROTOBUF_SHARED_LIBS"] = self.dependencies.host["protobuf"].options.shared
7479
tc.variables["BUILD_ONNX_PYTHON"] = False
7580
tc.variables["ONNX_GEN_PB_TYPE_STUBS"] = False
7681
tc.variables["ONNX_WERROR"] = False
@@ -86,8 +91,6 @@ def generate(self):
8691
tc.generate()
8792
deps = CMakeDeps(self)
8893
deps.generate()
89-
env = VirtualBuildEnv(self)
90-
env.generate()
9194

9295
def build(self):
9396
apply_conandata_patches(self)
@@ -100,6 +103,7 @@ def package(self):
100103
cmake = CMake(self)
101104
cmake.install()
102105
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
106+
fix_apple_shared_install_name(self)
103107

104108
# TODO: to remove in conan v2 once legacy generators removed
105109
self._create_cmake_module_alias_targets(
@@ -138,7 +142,8 @@ def _onnx_components(self):
138142
"requires": ["protobuf::libprotobuf"]
139143
},
140144
"onnxifi": {
141-
"target": "onnxifi"
145+
"target": "onnxifi",
146+
"system_libs": [(self.settings.os in ["Linux", "FreeBSD"], ["dl"])],
142147
},
143148
"onnxifi_dummy": {
144149
"target": "onnxifi_dummy",
@@ -167,10 +172,12 @@ def _register_components(components):
167172
libs = comp_values.get("libs", [])
168173
defines = comp_values.get("defines", [])
169174
requires = comp_values.get("requires", [])
175+
system_libs = [l for cond, sys_libs in comp_values.get("system_libs", []) if cond for l in sys_libs]
170176
self.cpp_info.components[comp_name].set_property("cmake_target_name", target)
171177
self.cpp_info.components[comp_name].libs = libs
172178
self.cpp_info.components[comp_name].defines = defines
173179
self.cpp_info.components[comp_name].requires = requires
180+
self.cpp_info.components[comp_name].system_libs = system_libs
174181

175182
# TODO: to remove in conan v2 once cmake_find_package_* generators removed
176183
self.cpp_info.components[comp_name].names["cmake_find_package"] = target

recipes/onnx/all/test_package/conanfile.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
class TestPackageConan(ConanFile):
88
settings = "os", "arch", "compiler", "build_type"
99
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
10-
11-
def requirements(self):
12-
self.requires(self.tested_reference_str)
10+
test_type = "explicit"
1311

1412
def layout(self):
1513
cmake_layout(self)
1614

15+
def requirements(self):
16+
self.requires(self.tested_reference_str)
17+
1718
def build(self):
1819
cmake = CMake(self)
1920
cmake.configure()
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
cmake_minimum_required(VERSION 3.8)
2-
project(test_package LANGUAGES CXX)
1+
cmake_minimum_required(VERSION 3.1)
2+
project(test_package)
33

44
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
55
conan_basic_setup(TARGETS)
66

7-
find_package(ONNX REQUIRED CONFIG)
8-
9-
add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
10-
target_link_libraries(${PROJECT_NAME} PRIVATE onnx)
11-
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
7+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
8+
${CMAKE_CURRENT_BINARY_DIR}/test_package)

recipes/openddl-parser/all/conanfile.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from conan import ConanFile
22
from conan.tools.build import check_min_cppstd
33
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
4-
from conan.tools.files import apply_conandata_patches, copy, get, rmdir
4+
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
55
import os
66

7-
required_conan_version = ">=1.50.0"
7+
required_conan_version = ">=1.54.0"
88

99

1010
class OpenDDLParserConan(ConanFile):
@@ -15,6 +15,7 @@ class OpenDDLParserConan(ConanFile):
1515
description = "A simple and fast OpenDDL Parser"
1616
topics = ("openddl", "parser")
1717

18+
package_type = "library"
1819
settings = "os", "arch", "compiler", "build_type"
1920
options = {
2021
"shared": [True, False],
@@ -26,35 +27,31 @@ class OpenDDLParserConan(ConanFile):
2627
}
2728

2829
def export_sources(self):
29-
for p in self.conan_data.get("patches", {}).get(self.version, []):
30-
copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder)
30+
export_conandata_patches(self)
3131

3232
def config_options(self):
3333
if self.settings.os == "Windows":
3434
del self.options.fPIC
3535

3636
def configure(self):
3737
if self.options.shared:
38-
del self.options.fPIC
39-
40-
def validate(self):
41-
if self.info.settings.compiler.cppstd:
42-
check_min_cppstd(self, 11)
38+
self.options.rm_safe("fPIC")
4339

4440
def layout(self):
4541
cmake_layout(self, src_folder="src")
4642

43+
def validate(self):
44+
if self.settings.compiler.get_safe("cppstd"):
45+
check_min_cppstd(self, 11)
46+
4747
def source(self):
48-
get(self, **self.conan_data["sources"][self.version],
49-
destination=self.source_folder, strip_root=True)
48+
get(self, **self.conan_data["sources"][self.version], strip_root=True)
5049

5150
def generate(self):
5251
tc = CMakeToolchain(self)
5352
tc.variables["DDL_STATIC_LIBRARY"] = not self.options.shared
5453
tc.variables["DDL_BUILD_TESTS"] = False
5554
tc.variables["DDL_BUILD_PARSER_DEMO"] = False
56-
# Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840)
57-
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
5855
tc.generate()
5956

6057
def build(self):
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
from conan import ConanFile
2-
from conan.tools.build import cross_building
2+
from conan.tools.build import can_run
33
from conan.tools.cmake import CMake, cmake_layout
44
import os
55

66

77
class TestPackageConan(ConanFile):
88
settings = "os", "arch", "compiler", "build_type"
99
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
10-
11-
def requirements(self):
12-
self.requires(self.tested_reference_str)
10+
test_type = "explicit"
1311

1412
def layout(self):
1513
cmake_layout(self)
1614

15+
def requirements(self):
16+
self.requires(self.tested_reference_str)
17+
1718
def build(self):
1819
cmake = CMake(self)
1920
cmake.configure()
2021
cmake.build()
2122

2223
def test(self):
23-
if not cross_building(self):
24+
if can_run(self):
2425
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
2526
self.run(bin_path, env="conanrun")
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
cmake_minimum_required(VERSION 3.8)
2-
project(test_package LANGUAGES CXX)
1+
cmake_minimum_required(VERSION 3.1)
2+
project(test_package)
33

44
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
55
conan_basic_setup(TARGETS)
66

7-
find_package(openddlparser REQUIRED CONFIG)
8-
9-
add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
10-
target_link_libraries(${PROJECT_NAME} PRIVATE openddlparser::openddlparser)
11-
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
7+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
8+
${CMAKE_CURRENT_BINARY_DIR}/test_package)

0 commit comments

Comments
 (0)