From 78c19c85d2c0ed4eed9463bd176d80ccc3920bf4 Mon Sep 17 00:00:00 2001 From: toge Date: Sun, 10 Jul 2022 03:05:13 +0900 Subject: [PATCH 1/2] libxmlpp: add version 5.0.1 --- recipes/libxmlpp/2.x.x/conandata.yml | 3 + recipes/libxmlpp/2.x.x/conanfile.py | 99 +++++++++++-------- .../2.x.x/test_package/CMakeLists.txt | 12 ++- recipes/libxmlpp/config.yml | 2 + 4 files changed, 72 insertions(+), 44 deletions(-) diff --git a/recipes/libxmlpp/2.x.x/conandata.yml b/recipes/libxmlpp/2.x.x/conandata.yml index b0c79f2cf5d4d..a17dd60f250d8 100644 --- a/recipes/libxmlpp/2.x.x/conandata.yml +++ b/recipes/libxmlpp/2.x.x/conandata.yml @@ -1,4 +1,7 @@ sources: + "5.0.1": + url: "https://github.com/libxmlplusplus/libxmlplusplus/releases/download/5.0.1/libxml++-5.0.1.tar.xz" + sha256: "" "2.42.1": url: "https://github.com/libxmlplusplus/libxmlplusplus/releases/download/2.42.1/libxml++-2.42.1.tar.xz" sha256: "9b59059abe5545d28ceb388a55e341095f197bd219c73e6623aeb6d801e00be8" diff --git a/recipes/libxmlpp/2.x.x/conanfile.py b/recipes/libxmlpp/2.x.x/conanfile.py index 263833d5c393b..1297a686c1b40 100644 --- a/recipes/libxmlpp/2.x.x/conanfile.py +++ b/recipes/libxmlpp/2.x.x/conanfile.py @@ -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): @@ -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( @@ -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): @@ -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 = { @@ -98,18 +112,18 @@ 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( @@ -117,20 +131,25 @@ def package(self): 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}" diff --git a/recipes/libxmlpp/2.x.x/test_package/CMakeLists.txt b/recipes/libxmlpp/2.x.x/test_package/CMakeLists.txt index 8946f91b2467c..acd4c1ac2441b 100644 --- a/recipes/libxmlpp/2.x.x/test_package/CMakeLists.txt +++ b/recipes/libxmlpp/2.x.x/test_package/CMakeLists.txt @@ -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() diff --git a/recipes/libxmlpp/config.yml b/recipes/libxmlpp/config.yml index 37007196cba28..4976ee096e564 100644 --- a/recipes/libxmlpp/config.yml +++ b/recipes/libxmlpp/config.yml @@ -1,3 +1,5 @@ versions: + "5.0.1": + folder: "2.x.x" "2.42.1": folder: "2.x.x" From 850723b3d5aaeed54101190113c6cc42a774611d Mon Sep 17 00:00:00 2001 From: toge Date: Tue, 12 Jul 2022 02:38:32 +0900 Subject: [PATCH 2/2] support msvc static build --- recipes/libxmlpp/2.x.x/conandata.yml | 7 +++- ...1-0001-enable_static_builds_on_msvc.patch} | 0 ....1-0001-enable_static_builds_on_msvc.patch | 38 +++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) rename recipes/libxmlpp/2.x.x/patches/{enable_static_builds_on_msvc.patch => 2.42.1-0001-enable_static_builds_on_msvc.patch} (100%) create mode 100644 recipes/libxmlpp/2.x.x/patches/5.0.1-0001-enable_static_builds_on_msvc.patch diff --git a/recipes/libxmlpp/2.x.x/conandata.yml b/recipes/libxmlpp/2.x.x/conandata.yml index a17dd60f250d8..c28f5a99de926 100644 --- a/recipes/libxmlpp/2.x.x/conandata.yml +++ b/recipes/libxmlpp/2.x.x/conandata.yml @@ -1,12 +1,15 @@ sources: "5.0.1": url: "https://github.com/libxmlplusplus/libxmlplusplus/releases/download/5.0.1/libxml++-5.0.1.tar.xz" - sha256: "" + 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" diff --git a/recipes/libxmlpp/2.x.x/patches/enable_static_builds_on_msvc.patch b/recipes/libxmlpp/2.x.x/patches/2.42.1-0001-enable_static_builds_on_msvc.patch similarity index 100% rename from recipes/libxmlpp/2.x.x/patches/enable_static_builds_on_msvc.patch rename to recipes/libxmlpp/2.x.x/patches/2.42.1-0001-enable_static_builds_on_msvc.patch diff --git a/recipes/libxmlpp/2.x.x/patches/5.0.1-0001-enable_static_builds_on_msvc.patch b/recipes/libxmlpp/2.x.x/patches/5.0.1-0001-enable_static_builds_on_msvc.patch new file mode 100644 index 0000000000000..135415955e944 --- /dev/null +++ b/recipes/libxmlpp/2.x.x/patches/5.0.1-0001-enable_static_builds_on_msvc.patch @@ -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',