4
4
from conan .tools .microsoft import is_msvc
5
5
import shutil
6
6
import os
7
+ import functools
7
8
9
+ required_conan_version = ">=1.45.0"
8
10
9
11
class LibXMLPlusPlus (ConanFile ):
10
12
# FIXME: naming the library "libxml++" causes conan not to add it to the
11
13
# environment path on windows
12
14
name = "libxmlpp"
13
- homepage = "https://github.com/ libxmlplusplus/libxmlplusplus "
15
+ description = "libxml++ (a.k.a. libxmlplusplus) provides a C++ interface to XML files "
14
16
license = "LGPL-2.1"
15
17
url = "https://github.com/conan-io/conan-center-index"
16
- description = "libxml++ (a.k.a. libxmlplusplus) provides a C++ interface to XML files "
18
+ homepage = "https://github.com/ libxmlplusplus/libxmlplusplus "
17
19
topics = ["xml" , "parser" , "wrapper" ]
18
- settings = "os" , "compiler" , "build_type" , "arch"
19
- options = {"shared" : [True , False ], "fPIC" : [True , False ]}
20
- default_options = {"shared" : False , "fPIC" : True }
21
-
20
+ settings = "os" , "arch" , "compiler" , "build_type"
21
+ options = {
22
+ "shared" : [True , False ],
23
+ "fPIC" : [True , False ],
24
+ }
25
+ default_options = {
26
+ "shared" : False ,
27
+ "fPIC" : True ,
28
+ }
22
29
generators = "pkg_config"
23
- exports_sources = "patches/**"
24
-
25
- def validate (self ):
26
- if hasattr (self , "settings_build" ) and tools .cross_building (self ):
27
- raise ConanInvalidConfiguration ("Cross-building not implemented" )
28
-
29
- if self .settings .compiler .get_safe ("cppstd" ):
30
- tools .check_min_cppstd (self , 11 )
31
30
32
31
@property
33
32
def _source_subfolder (self ):
@@ -37,17 +36,35 @@ def _source_subfolder(self):
37
36
def _build_subfolder (self ):
38
37
return "build_subfolder"
39
38
39
+ def export_sources (self ):
40
+ for patch in self .conan_data .get ("patches" , {}).get (self .version , []):
41
+ self .copy (patch ["patch_file" ])
42
+
40
43
def config_options (self ):
41
44
if self .settings .os == "Windows" :
42
45
del self .options .fPIC
43
46
44
- def build_requirements (self ):
45
- self .build_requires ( "meson/0.59.1" )
46
- self .build_requires ( "pkgconf/1.7.4" )
47
+ def configure (self ):
48
+ if self .options . shared :
49
+ del self .options . fPIC
47
50
48
51
def requirements (self ):
49
52
self .requires ("libxml2/2.9.14" )
50
- self .requires ("glibmm/2.66.4" )
53
+ if tools .Version (self .version ) <= "2.42.1" :
54
+ self .requires ("glibmm/2.66.4" )
55
+ else :
56
+ self .requires ("glibmm/2.72.1" )
57
+
58
+ def validate (self ):
59
+ if hasattr (self , "settings_build" ) and tools .cross_building (self ):
60
+ raise ConanInvalidConfiguration ("Cross-building not implemented" )
61
+
62
+ if self .settings .compiler .get_safe ("cppstd" ):
63
+ tools .check_min_cppstd (self , 11 )
64
+
65
+ def build_requirements (self ):
66
+ self .build_requires ("meson/0.63.0" )
67
+ self .build_requires ("pkgconf/1.7.4" )
51
68
52
69
def source (self ):
53
70
tools .get (
@@ -57,7 +74,7 @@ def source(self):
57
74
)
58
75
59
76
def _patch_sources (self ):
60
- for patch in self .conan_data [ "patches" ][ self .version ] :
77
+ for patch in self .conan_data . get ( "patches" , {}). get ( self .version , []) :
61
78
tools .patch (** patch )
62
79
63
80
if is_msvc (self ):
@@ -70,10 +87,7 @@ def _patch_sources(self):
70
87
os .path .join (self ._source_subfolder , "meson.build" ),
71
88
"cpp_std=c++" , "cpp_std=vc++" )
72
89
73
- def configure (self ):
74
- if self .options .shared :
75
- del self .options .fPIC
76
-
90
+ @functools .lru_cache (1 )
77
91
def _configure_meson (self ):
78
92
meson = Meson (self )
79
93
defs = {
@@ -98,39 +112,44 @@ def build(self):
98
112
meson .build ()
99
113
100
114
def package (self ):
115
+ lib_version = "2.6" if tools .Version (self .version ) <= "2.42.1" else "5.0"
116
+
101
117
self .copy ("COPYING" , dst = "licenses" , src = self ._source_subfolder )
102
118
meson = self ._configure_meson ()
103
119
meson .install ()
104
120
105
121
shutil .move (
106
- os .path .join (self .package_folder , "lib" , "libxml++-2.6" ,
107
- "include" , "libxml++config.h" ),
108
- os .path .join (self .package_folder , "include" , "libxml++-2.6" ,
109
- "libxml++config.h" ))
122
+ os .path .join (self .package_folder , "lib" , f"libxml++-{ lib_version } " , "include" , "libxml++config.h" ),
123
+ os .path .join (self .package_folder , "include" , f"libxml++-{ lib_version } " , "libxml++config.h" ))
110
124
111
125
tools .rmdir (os .path .join (self .package_folder , "lib" , "pkgconfig" ))
112
- tools .rmdir (os .path .join (self .package_folder , "lib" , "libxml++-2.6 " ))
126
+ tools .rmdir (os .path .join (self .package_folder , "lib" , f "libxml++-{ lib_version } " ))
113
127
114
128
if is_msvc (self ):
115
129
tools .remove_files_by_mask (
116
130
os .path .join (self .package_folder , "bin" ), "*.pdb" )
117
131
if not self .options .shared :
118
132
rename (
119
133
self ,
120
- os .path .join (self .package_folder , "lib" , "libxml++-2.6 .a" ),
121
- os .path .join (self .package_folder , "lib" , "xml++-2.6 .lib" ))
134
+ os .path .join (self .package_folder , "lib" , f "libxml++-{ lib_version } .a" ),
135
+ os .path .join (self .package_folder , "lib" , f "xml++-{ lib_version } .lib" ))
122
136
123
137
def package_info (self ):
138
+ lib_version = "2.6" if tools .Version (self .version ) <= "2.42.1" else "5.0"
139
+
140
+ self .cpp_info .set_property ("cmake_module_file_name" , "libxml++" )
141
+ self .cpp_info .set_property ("cmake_module_target_name" , "libxml++::libxml++" )
142
+ self .cpp_info .set_property ("pkg_config_name" , "libxml++" )
143
+ self .cpp_info .components [f"libxml++-{ lib_version } " ].set_property ("pkg_config_name" , f"libxml++-{ lib_version } " )
144
+ self .cpp_info .components [f"libxml++-{ lib_version } " ].libs = [f"xml++-{ lib_version } " ]
145
+ self .cpp_info .components [f"libxml++-{ lib_version } " ].includedirs = [
146
+ os .path .join ("include" , f"libxml++-{ lib_version } " )
147
+ ]
148
+ self .cpp_info .components [f"libxml++-{ lib_version } " ].requires = [
149
+ "glibmm::glibmm" , "libxml2::libxml2"
150
+ ]
151
+
124
152
self .cpp_info .names ["cmake_find_package" ] = "libxml++"
125
153
self .cpp_info .names ["cmake_find_package_multi" ] = "libxml++"
126
154
self .cpp_info .names ["pkg_config" ] = "libxml++"
127
-
128
- self .cpp_info .components ["libxml++-2.6" ].names [
129
- "pkg_config" ] = "libxml++-2.6"
130
- self .cpp_info .components ["libxml++-2.6" ].libs = ["xml++-2.6" ]
131
- self .cpp_info .components ["libxml++-2.6" ].includedirs = [
132
- os .path .join ("include" , "libxml++-2.6" )
133
- ]
134
- self .cpp_info .components ["libxml++-2.6" ].requires = [
135
- "glibmm::glibmm-2.4" , "libxml2::libxml2"
136
- ]
155
+ self .cpp_info .components [f"libxml++-{ lib_version } " ].names ["pkg_config" ] = f"libxml++-{ lib_version } "
0 commit comments