Skip to content

Commit 85aa9e6

Browse files
authored
(#11631) libxmlpp: add version 5.0.1
* libxmlpp: add version 5.0.1 * support msvc static build
1 parent 33e52a6 commit 85aa9e6

File tree

6 files changed

+114
-45
lines changed

6 files changed

+114
-45
lines changed

recipes/libxmlpp/2.x.x/conandata.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
sources:
2+
"5.0.1":
3+
url: "https://github.com/libxmlplusplus/libxmlplusplus/releases/download/5.0.1/libxml++-5.0.1.tar.xz"
4+
sha256: "15c38307a964fa6199f4da6683a599eb7e63cc89198545b36349b87cf9aa0098"
25
"2.42.1":
36
url: "https://github.com/libxmlplusplus/libxmlplusplus/releases/download/2.42.1/libxml++-2.42.1.tar.xz"
47
sha256: "9b59059abe5545d28ceb388a55e341095f197bd219c73e6623aeb6d801e00be8"
58

69
patches:
10+
"5.0.1":
11+
- patch_file: "patches/5.0.1-0001-enable_static_builds_on_msvc.patch"
12+
base_path: "source_subfolder"
713
"2.42.1":
8-
- patch_file: "patches/enable_static_builds_on_msvc.patch"
14+
- patch_file: "patches/2.42.1-0001-enable_static_builds_on_msvc.patch"
915
base_path: "source_subfolder"

recipes/libxmlpp/2.x.x/conanfile.py

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,29 @@
44
from conan.tools.microsoft import is_msvc
55
import shutil
66
import os
7+
import functools
78

9+
required_conan_version = ">=1.45.0"
810

911
class LibXMLPlusPlus(ConanFile):
1012
# FIXME: naming the library "libxml++" causes conan not to add it to the
1113
# environment path on windows
1214
name = "libxmlpp"
13-
homepage = "https://github.com/libxmlplusplus/libxmlplusplus"
15+
description = "libxml++ (a.k.a. libxmlplusplus) provides a C++ interface to XML files"
1416
license = "LGPL-2.1"
1517
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"
1719
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+
}
2229
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)
3130

3231
@property
3332
def _source_subfolder(self):
@@ -37,17 +36,35 @@ def _source_subfolder(self):
3736
def _build_subfolder(self):
3837
return "build_subfolder"
3938

39+
def export_sources(self):
40+
for patch in self.conan_data.get("patches", {}).get(self.version, []):
41+
self.copy(patch["patch_file"])
42+
4043
def config_options(self):
4144
if self.settings.os == "Windows":
4245
del self.options.fPIC
4346

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
4750

4851
def requirements(self):
4952
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")
5168

5269
def source(self):
5370
tools.get(
@@ -57,7 +74,7 @@ def source(self):
5774
)
5875

5976
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, []):
6178
tools.patch(**patch)
6279

6380
if is_msvc(self):
@@ -70,10 +87,7 @@ def _patch_sources(self):
7087
os.path.join(self._source_subfolder, "meson.build"),
7188
"cpp_std=c++", "cpp_std=vc++")
7289

73-
def configure(self):
74-
if self.options.shared:
75-
del self.options.fPIC
76-
90+
@functools.lru_cache(1)
7791
def _configure_meson(self):
7892
meson = Meson(self)
7993
defs = {
@@ -98,39 +112,44 @@ def build(self):
98112
meson.build()
99113

100114
def package(self):
115+
lib_version = "2.6" if tools.Version(self.version) <= "2.42.1" else "5.0"
116+
101117
self.copy("COPYING", dst="licenses", src=self._source_subfolder)
102118
meson = self._configure_meson()
103119
meson.install()
104120

105121
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"))
110124

111125
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}"))
113127

114128
if is_msvc(self):
115129
tools.remove_files_by_mask(
116130
os.path.join(self.package_folder, "bin"), "*.pdb")
117131
if not self.options.shared:
118132
rename(
119133
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"))
122136

123137
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+
124152
self.cpp_info.names["cmake_find_package"] = "libxml++"
125153
self.cpp_info.names["cmake_find_package_multi"] = "libxml++"
126154
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}"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
diff --git a/libxml++config.h.meson b/libxml++config.h.meson
2+
index 2f0264f..11e0c2c 100755
3+
--- a/libxml++config.h.meson
4+
+++ b/libxml++config.h.meson
5+
@@ -16,6 +16,9 @@
6+
/* Micro version number of libxml++. */
7+
#mesondefine LIBXMLXX_MICRO_VERSION
8+
9+
+/* Defined if libxml++ is built as a static library. */
10+
+#mesondefine LIBXMLXX_STATIC
11+
+
12+
// Enable DLL-specific stuff only when not building a static library
13+
#if !defined(__CYGWIN__) && (defined(__MINGW32__) || defined(_MSC_VER)) && !defined(LIBXMLXX_STATIC)
14+
# define LIBXMLPP_DLL 1
15+
diff --git a/meson.build b/meson.build
16+
index 6e86ca3..8557846 100644
17+
--- a/meson.build
18+
+++ b/meson.build
19+
@@ -274,15 +274,13 @@ if cpp_compiler.compiles(files('tools' / 'conf_tests' / 'have_exception_ptr.cc')
20+
pkg_conf_data.set('LIBXMLXX_HAVE_EXCEPTION_PTR', 1)
21+
endif
22+
23+
+if get_option('default_library') == 'static'
24+
+ pkg_conf_data.set('LIBXMLXX_STATIC', 1)
25+
+endif
26+
+
27+
# Static library?
28+
library_build_type = get_option('default_library')
29+
30+
-if cpp_compiler.get_argument_syntax() == 'msvc'
31+
- if library_build_type == 'static' or library_build_type == 'both'
32+
- error('Static builds are not supported by MSVC-style builds')
33+
- endif
34+
-endif
35+
-
36+
configure_file(
37+
input: 'libxml++.pc.in',
38+
output: xmlxx_pcname + '.pc',
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
cmake_minimum_required(VERSION 3.6)
1+
cmake_minimum_required(VERSION 3.8)
22
project(test_package)
33

44
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
5-
conan_basic_setup(TARGET)
5+
conan_basic_setup(TARGETS)
66

77
find_package(libxml++ REQUIRED CONFIG)
88

99
add_executable(${PROJECT_NAME} test_package.cpp)
10-
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
11-
target_link_libraries(${PROJECT_NAME} libxml++::libxml++-2.6)
10+
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
11+
if(TARGET libxml++::libxml++-2.6)
12+
target_link_libraries(${PROJECT_NAME} libxml++::libxml++-2.6)
13+
else()
14+
target_link_libraries(${PROJECT_NAME} libxml++::libxml++-5.0)
15+
endif()

recipes/libxmlpp/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
versions:
2+
"5.0.1":
3+
folder: "2.x.x"
24
"2.42.1":
35
folder: "2.x.x"

0 commit comments

Comments
 (0)