Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libxmlpp: add version 5.0.1 #11631

Merged
merged 2 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion recipes/libxmlpp/2.x.x/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
sources:
"5.0.1":
url: "https://github.com/libxmlplusplus/libxmlplusplus/releases/download/5.0.1/libxml++-5.0.1.tar.xz"
sha256: "15c38307a964fa6199f4da6683a599eb7e63cc89198545b36349b87cf9aa0098"
"2.42.1":
url: "https://github.com/libxmlplusplus/libxmlplusplus/releases/download/2.42.1/libxml++-2.42.1.tar.xz"
sha256: "9b59059abe5545d28ceb388a55e341095f197bd219c73e6623aeb6d801e00be8"

patches:
"5.0.1":
- patch_file: "patches/5.0.1-0001-enable_static_builds_on_msvc.patch"
base_path: "source_subfolder"
"2.42.1":
- patch_file: "patches/enable_static_builds_on_msvc.patch"
- patch_file: "patches/2.42.1-0001-enable_static_builds_on_msvc.patch"
base_path: "source_subfolder"
99 changes: 59 additions & 40 deletions recipes/libxmlpp/2.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,29 @@
from conan.tools.microsoft import is_msvc
import shutil
import os
import functools

required_conan_version = ">=1.45.0"

class LibXMLPlusPlus(ConanFile):
# FIXME: naming the library "libxml++" causes conan not to add it to the
# environment path on windows
name = "libxmlpp"
homepage = "https://github.com/libxmlplusplus/libxmlplusplus"
description = "libxml++ (a.k.a. libxmlplusplus) provides a C++ interface to XML files"
license = "LGPL-2.1"
url = "https://github.com/conan-io/conan-center-index"
description = "libxml++ (a.k.a. libxmlplusplus) provides a C++ interface to XML files"
homepage = "https://github.com/libxmlplusplus/libxmlplusplus"
topics = ["xml", "parser", "wrapper"]
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
generators = "pkg_config"
exports_sources = "patches/**"

def validate(self):
if hasattr(self, "settings_build") and tools.cross_building(self):
raise ConanInvalidConfiguration("Cross-building not implemented")

if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 11)

@property
def _source_subfolder(self):
Expand All @@ -37,17 +36,35 @@ def _source_subfolder(self):
def _build_subfolder(self):
return "build_subfolder"

def export_sources(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
self.copy(patch["patch_file"])

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

def build_requirements(self):
self.build_requires("meson/0.59.1")
self.build_requires("pkgconf/1.7.4")
def configure(self):
if self.options.shared:
del self.options.fPIC

def requirements(self):
self.requires("libxml2/2.9.14")
self.requires("glibmm/2.66.4")
if tools.Version(self.version) <= "2.42.1":
self.requires("glibmm/2.66.4")
else:
self.requires("glibmm/2.72.1")

def validate(self):
if hasattr(self, "settings_build") and tools.cross_building(self):
raise ConanInvalidConfiguration("Cross-building not implemented")

if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 11)

def build_requirements(self):
self.build_requires("meson/0.63.0")
self.build_requires("pkgconf/1.7.4")

def source(self):
tools.get(
Expand All @@ -57,7 +74,7 @@ def source(self):
)

def _patch_sources(self):
for patch in self.conan_data["patches"][self.version]:
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)

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

def configure(self):
if self.options.shared:
del self.options.fPIC

@functools.lru_cache(1)
def _configure_meson(self):
meson = Meson(self)
defs = {
Expand All @@ -98,39 +112,44 @@ def build(self):
meson.build()

def package(self):
lib_version = "2.6" if tools.Version(self.version) <= "2.42.1" else "5.0"

self.copy("COPYING", dst="licenses", src=self._source_subfolder)
meson = self._configure_meson()
meson.install()

shutil.move(
os.path.join(self.package_folder, "lib", "libxml++-2.6",
"include", "libxml++config.h"),
os.path.join(self.package_folder, "include", "libxml++-2.6",
"libxml++config.h"))
os.path.join(self.package_folder, "lib", f"libxml++-{lib_version}", "include", "libxml++config.h"),
os.path.join(self.package_folder, "include", f"libxml++-{lib_version}", "libxml++config.h"))

tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "lib", "libxml++-2.6"))
tools.rmdir(os.path.join(self.package_folder, "lib", f"libxml++-{lib_version}"))

if is_msvc(self):
tools.remove_files_by_mask(
os.path.join(self.package_folder, "bin"), "*.pdb")
if not self.options.shared:
rename(
self,
os.path.join(self.package_folder, "lib", "libxml++-2.6.a"),
os.path.join(self.package_folder, "lib", "xml++-2.6.lib"))
os.path.join(self.package_folder, "lib", f"libxml++-{lib_version}.a"),
os.path.join(self.package_folder, "lib", f"xml++-{lib_version}.lib"))

def package_info(self):
lib_version = "2.6" if tools.Version(self.version) <= "2.42.1" else "5.0"

self.cpp_info.set_property("cmake_module_file_name", "libxml++")
self.cpp_info.set_property("cmake_module_target_name", "libxml++::libxml++")
self.cpp_info.set_property("pkg_config_name", "libxml++")
self.cpp_info.components[f"libxml++-{lib_version}"].set_property("pkg_config_name", f"libxml++-{lib_version}")
self.cpp_info.components[f"libxml++-{lib_version}"].libs = [f"xml++-{lib_version}"]
self.cpp_info.components[f"libxml++-{lib_version}"].includedirs = [
os.path.join("include", f"libxml++-{lib_version}")
]
self.cpp_info.components[f"libxml++-{lib_version}"].requires = [
"glibmm::glibmm", "libxml2::libxml2"
]

self.cpp_info.names["cmake_find_package"] = "libxml++"
self.cpp_info.names["cmake_find_package_multi"] = "libxml++"
self.cpp_info.names["pkg_config"] = "libxml++"

self.cpp_info.components["libxml++-2.6"].names[
"pkg_config"] = "libxml++-2.6"
self.cpp_info.components["libxml++-2.6"].libs = ["xml++-2.6"]
self.cpp_info.components["libxml++-2.6"].includedirs = [
os.path.join("include", "libxml++-2.6")
]
self.cpp_info.components["libxml++-2.6"].requires = [
"glibmm::glibmm-2.4", "libxml2::libxml2"
]
self.cpp_info.components[f"libxml++-{lib_version}"].names["pkg_config"] = f"libxml++-{lib_version}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff --git a/libxml++config.h.meson b/libxml++config.h.meson
index 2f0264f..11e0c2c 100755
--- a/libxml++config.h.meson
+++ b/libxml++config.h.meson
@@ -16,6 +16,9 @@
/* Micro version number of libxml++. */
#mesondefine LIBXMLXX_MICRO_VERSION

+/* Defined if libxml++ is built as a static library. */
+#mesondefine LIBXMLXX_STATIC
+
// Enable DLL-specific stuff only when not building a static library
#if !defined(__CYGWIN__) && (defined(__MINGW32__) || defined(_MSC_VER)) && !defined(LIBXMLXX_STATIC)
# define LIBXMLPP_DLL 1
diff --git a/meson.build b/meson.build
index 6e86ca3..8557846 100644
--- a/meson.build
+++ b/meson.build
@@ -274,15 +274,13 @@ if cpp_compiler.compiles(files('tools' / 'conf_tests' / 'have_exception_ptr.cc')
pkg_conf_data.set('LIBXMLXX_HAVE_EXCEPTION_PTR', 1)
endif

+if get_option('default_library') == 'static'
+ pkg_conf_data.set('LIBXMLXX_STATIC', 1)
+endif
+
# Static library?
library_build_type = get_option('default_library')

-if cpp_compiler.get_argument_syntax() == 'msvc'
- if library_build_type == 'static' or library_build_type == 'both'
- error('Static builds are not supported by MSVC-style builds')
- endif
-endif
-
configure_file(
input: 'libxml++.pc.in',
output: xmlxx_pcname + '.pc',
12 changes: 8 additions & 4 deletions recipes/libxmlpp/2.x.x/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
cmake_minimum_required(VERSION 3.6)
cmake_minimum_required(VERSION 3.8)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGET)
conan_basic_setup(TARGETS)

find_package(libxml++ REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
target_link_libraries(${PROJECT_NAME} libxml++::libxml++-2.6)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
if(TARGET libxml++::libxml++-2.6)
target_link_libraries(${PROJECT_NAME} libxml++::libxml++-2.6)
else()
target_link_libraries(${PROJECT_NAME} libxml++::libxml++-5.0)
endif()
2 changes: 2 additions & 0 deletions recipes/libxmlpp/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"5.0.1":
folder: "2.x.x"
"2.42.1":
folder: "2.x.x"