From 58abe5d619787218e5407c716acfb5a1446adad7 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 10 Nov 2022 23:32:41 +0100 Subject: [PATCH 1/4] add xlnt/1.5.0 --- recipes/xlnt/all/conandata.yml | 15 +++ recipes/xlnt/all/conanfile.py | 102 ++++++++++++++++++ .../0001-fix-cmake-and-unvendor-deps.patch | 91 ++++++++++++++++ .../xlnt/all/patches/0002-libstudxml.patch | 65 +++++++++++ .../all/patches/0003-include-limits.patch | 20 ++++ recipes/xlnt/all/test_package/CMakeLists.txt | 8 ++ recipes/xlnt/all/test_package/conanfile.py | 25 +++++ .../xlnt/all/test_package/test_package.cpp | 14 +++ .../xlnt/all/test_v1_package/CMakeLists.txt | 8 ++ recipes/xlnt/all/test_v1_package/conanfile.py | 17 +++ recipes/xlnt/config.yml | 3 + 11 files changed, 368 insertions(+) create mode 100644 recipes/xlnt/all/conandata.yml create mode 100644 recipes/xlnt/all/conanfile.py create mode 100644 recipes/xlnt/all/patches/0001-fix-cmake-and-unvendor-deps.patch create mode 100644 recipes/xlnt/all/patches/0002-libstudxml.patch create mode 100644 recipes/xlnt/all/patches/0003-include-limits.patch create mode 100644 recipes/xlnt/all/test_package/CMakeLists.txt create mode 100644 recipes/xlnt/all/test_package/conanfile.py create mode 100644 recipes/xlnt/all/test_package/test_package.cpp create mode 100644 recipes/xlnt/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/xlnt/all/test_v1_package/conanfile.py create mode 100644 recipes/xlnt/config.yml diff --git a/recipes/xlnt/all/conandata.yml b/recipes/xlnt/all/conandata.yml new file mode 100644 index 0000000000000..1be65b044d84b --- /dev/null +++ b/recipes/xlnt/all/conandata.yml @@ -0,0 +1,15 @@ +sources: + "1.5.0": + url: "https://github.com/tfussell/xlnt/archive/refs/tags/v1.5.0.tar.gz" + sha256: "8dec266d59ab6e4829da5dacea764a02887eeff5a5501c9a51ce796e735b90de" +patches: + "1.5.0": + - patch_file: "patches/0001-fix-cmake-and-unvendor-deps.patch" + patch_description: "Fix CMakeLists and unvendor miniz & utfcpp" + patch_type: "conan" + - patch_file: "patches/0002-libstudxml.patch" + patch_description: "Fix CMakeLists of libstudxml and unvendor expat" + patch_type: "conan" + - patch_file: "patches/0003-include-limits.patch" + patch_description: "Add missing includes" + patch_type: "conan" diff --git a/recipes/xlnt/all/conanfile.py b/recipes/xlnt/all/conanfile.py new file mode 100644 index 0000000000000..1b669356808c4 --- /dev/null +++ b/recipes/xlnt/all/conanfile.py @@ -0,0 +1,102 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir +import os + +required_conan_version = ">=1.53.0" + + +class XlntConan(ConanFile): + name = "xlnt" + description = "Cross-platform user-friendly xlsx library for C++11+" + license = "MIT" + topics = ("excel", "xlsx", "spreadsheet", "reader", "writer") + homepage = "https://github.com/tfussell/xlnt" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("miniz/3.0.1") + self.requires("utfcpp/3.2.2") + # TODO: unvendor libstudxml (needs libstudxml >= 1.1.0 in conan-center) + self.requires("expat/2.4.9") # dependency of libstudxml actually + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["STATIC"] = not self.options.shared + tc.variables["TESTS"] = False + tc.variables["SAMPLES"] = False + tc.variables["BENCHMARKS"] = False + tc.variables["PYTHON"] = False + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + # For some reason this useless file can break compilation + rm(self, "version", os.path.join(self.source_folder, "third-party", "libstudxml")) + # Remove unvendored third party libs + for third_party in (os.path.join("libstudxml", "libstudxml", "details", "expat"), "miniz", "utfcpp"): + rmdir(self, os.path.join(self.source_folder, "third-party", third_party)) + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Xlnt") + self.cpp_info.set_property("cmake_target_name", "xlnt::xlnt") + self.cpp_info.set_property("pkg_config_name", "xlnt") + suffix = "d" if self.settings.build_type == "Debug" else "" + self.cpp_info.libs = [f"xlnt{suffix}"] + if not self.options.shared: + self.cpp_info.defines.append("XLNT_STATIC") + + # TODO: to remove in conan v2 + self.cpp_info.filenames["cmake_find_package"] = "Xlnt" + self.cpp_info.filenames["cmake_find_package_multi"] = "Xlnt" + self.cpp_info.names["cmake_find_package"] = "xlnt" + self.cpp_info.names["cmake_find_package_multi"] = "xlnt" diff --git a/recipes/xlnt/all/patches/0001-fix-cmake-and-unvendor-deps.patch b/recipes/xlnt/all/patches/0001-fix-cmake-and-unvendor-deps.patch new file mode 100644 index 0000000000000..556d5c605d3b2 --- /dev/null +++ b/recipes/xlnt/all/patches/0001-fix-cmake-and-unvendor-deps.patch @@ -0,0 +1,91 @@ +--- a/source/CMakeLists.txt ++++ b/source/CMakeLists.txt +@@ -1,9 +1,6 @@ + cmake_minimum_required(VERSION 3.1) + project(xlnt VERSION 1.5.0) + +-set(CMAKE_CXX_STANDARD ${XLNT_CXX_LANG}) +-set(CMAKE_CXX_STANDARD_REQUIRED ON) +-set(CXX_EXTENSIONS OFF) + + # Project metadata + set(PROJECT_VENDOR "Thomas Fussell") +@@ -30,12 +27,9 @@ if(MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") # level 4 warnings + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # multi-processor compilation + elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") # all warnings +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") # extra warnings + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas") # ignore MSVC and Clang pragmas + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized") # GCC diagnostic with lots of false positives + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything") # all warnings + # blacklist warnings that are not relevant + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat") # ignore warnings about C++98 compatibility + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat-pedantic") # ignore pedantic warnings about C++98 compatibility +@@ -54,7 +48,7 @@ if(STATIC_CRT) + ucm_set_runtime(STATIC) + endif() + +-if(APPLE) ++if(0) + # Prevent a warning about deployment target not being set by setting it to current OSX version + execute_process(COMMAND "sw_vers -productVersion | awk -F'.' '{print $1\".\"$2}'" + OUTPUT_VARIABLE OSX_VERSION) +@@ -84,8 +78,6 @@ file(GLOB WORKBOOK_HEADERS ${XLNT_INCLUDE_DIR}/xlnt/workbook/*.hpp) + file(GLOB WORKBOOK_SOURCES ${XLNT_SOURCE_DIR}/workbook/*.cpp) + file(GLOB WORKSHEET_HEADERS ${XLNT_INCLUDE_DIR}/xlnt/worksheet/*.hpp) + file(GLOB WORKSHEET_SOURCES ${XLNT_SOURCE_DIR}/worksheet/*.cpp) +-file(GLOB MINIZ_HEADERS ${THIRD_PARTY_DIR}/miniz/*.h) +-file(GLOB MINIZ_SOURCES ${THIRD_PARTY_DIR}/miniz/*.c) + + file(GLOB DETAIL_ROOT_HEADERS ${XLNT_SOURCE_DIR}/detail/*.hpp) + file(GLOB DETAIL_ROOT_SOURCES ${XLNT_SOURCE_DIR}/detail/*.cpp) +@@ -115,12 +107,12 @@ set(XLNT_HEADERS ${ROOT_HEADERS} ${CELL_HEADERS} ${CHARTS_HEADERS} + ${CHARTSHEET_HEADERS} ${DRAWING_HEADERS} ${FORMULA_HEADERS} + ${PACKAGING_HEADERS} ${STYLES_HEADERS} ${UTILS_HEADERS} + ${WORKBOOK_HEADERS} ${WORKSHEET_HEADERS} ${DETAIL_HEADERS} ${DETAIL_CRYPTO_HEADERS} +- ${DRAWING_HEADERS} ${MINIZ_HEADERS}) ++ ${DRAWING_HEADERS}) + set(XLNT_SOURCES ${CELL_SOURCES} ${CHARTS_SOURCES} ${CHARTSHEET_SOURCES} + ${DRAWING_SOURCES} ${FORMULA_SOURCES} ${PACKAGING_SOURCES} + ${STYLES_SOURCES} ${UTILS_SOURCES} ${WORKBOOK_SOURCES} + ${WORKSHEET_SOURCES} ${DETAIL_SOURCES} ${DETAIL_CRYPTO_SOURCES} +- ${DRAWING_SOURCES} ${MINIZ_SOURCES}) ++ ${DRAWING_SOURCES}) + + if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + # Set a default CMAKE_INSTALL_PREFIX if one wasn't specified +@@ -168,7 +160,7 @@ if(NOT STATIC) + PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} +- INSTALL_NAME_DIR "${XLNT_LIB_DEST_DIR}") ++ ) + else() + # Compile static library + add_library(xlnt STATIC ${XLNT_HEADERS} ${XLNT_SOURCES} $) +@@ -186,8 +178,13 @@ target_include_directories(xlnt + PRIVATE + ${XLNT_SOURCE_DIR} + ${XLNT_SOURCE_DIR}/../third-party/libstudxml +- ${XLNT_SOURCE_DIR}/../third-party/miniz +- ${XLNT_SOURCE_DIR}/../third-party/utfcpp) ++) ++find_package(miniz REQUIRED CONFIG) ++find_package(utf8cpp REQUIRED CONFIG) ++find_package(EXPAT REQUIRED MODULE) ++target_link_libraries(xlnt PRIVATE miniz::miniz utf8cpp EXPAT::EXPAT) ++target_compile_definitions(xlnt PRIVATE LIBSTUDXML_EXTERNAL_EXPAT) ++target_compile_features(xlnt PUBLIC cxx_std_11) + + # Platform- and file-specific settings, MSVC + if(MSVC) +@@ -240,7 +236,6 @@ source_group(styles FILES ${STYLES_HEADERS} ${STYLES_SOURCES}) + source_group(utils FILES ${UTILS_HEADERS} ${UTILS_SOURCES}) + source_group(workbook FILES ${WORKBOOK_HEADERS} ${WORKBOOK_SOURCES}) + source_group(worksheet FILES ${WORKSHEET_HEADERS} ${WORKSHEET_SOURCES}) +-source_group(third-party\\miniz FILES ${MINIZ_HEADERS} ${MINIZ_SOURCES}) + + # Install library + install(TARGETS xlnt EXPORT XlntTargets diff --git a/recipes/xlnt/all/patches/0002-libstudxml.patch b/recipes/xlnt/all/patches/0002-libstudxml.patch new file mode 100644 index 0000000000000..deb3c283bccdf --- /dev/null +++ b/recipes/xlnt/all/patches/0002-libstudxml.patch @@ -0,0 +1,65 @@ +--- a/third-party/libstudxml/CMakeLists.txt ++++ b/third-party/libstudxml/CMakeLists.txt +@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.1) + project(libstudxml) + + # Require C++11 compiler +-set(CMAKE_CXX_STANDARD 11) +-set(CMAKE_CXX_STANDARD_REQUIRED ON) + + set(LIBSTUDXML_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + set(LIBSTUDXML_INCLUDE_DIR ${LIBSTUDXML_ROOT_DIR}) +@@ -18,19 +16,16 @@ set(LIBSTUDXML + ${LIBSTUDXML_ROOT_DIR}/libstudxml/qname.cxx + ${LIBSTUDXML_ROOT_DIR}/libstudxml/serializer.cxx + ${LIBSTUDXML_ROOT_DIR}/libstudxml/value-traits.cxx +- ${LIBSTUDXML_ROOT_DIR}/libstudxml/content +- ${LIBSTUDXML_ROOT_DIR}/libstudxml/exception +- ${LIBSTUDXML_ROOT_DIR}/libstudxml/forward +- ${LIBSTUDXML_ROOT_DIR}/libstudxml/parser +- ${LIBSTUDXML_ROOT_DIR}/libstudxml/qname +- ${LIBSTUDXML_ROOT_DIR}/libstudxml/serializer +- ${LIBSTUDXML_ROOT_DIR}/libstudxml/value-traits) ++ ${LIBSTUDXML_ROOT_DIR}/libstudxml/qname.cxx ++ ${LIBSTUDXML_ROOT_DIR}/libstudxml/serializer.cxx ++ ${LIBSTUDXML_ROOT_DIR}/libstudxml/value-traits.cxx) + + set(GENX + ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/genx/char-props.c + ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/genx/genx.c + ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/genx/genx.h) + ++if(0) + set(EXPAT + ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmlparse.c + ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmlrole.c +@@ -48,15 +43,20 @@ set(EXPAT + ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmlrole.h + ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmltok_impl.h + ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmltok.h) ++endif() + + add_library(libstudxml OBJECT ${LIBSTUDXML} ${GENX} ${EXPAT}) ++find_package(EXPAT REQUIRED MODULE) ++target_link_libraries(libstudxml PUBLIC EXPAT::EXPAT) ++target_compile_definitions(libstudxml PUBLIC LIBSTUDXML_EXTERNAL_EXPAT) ++target_compile_features(libstudxml PUBLIC cxx_std_11) + + target_compile_definitions(libstudxml PUBLIC LIBSTUDXML_STATIC_LIB=1) + target_include_directories(libstudxml + PUBLIC ${LIBSTUDXML_ROOT_DIR} + PUBLIC ${EXPAT_INCLUDE_DIRS}) + +-if(STATIC) ++if(0) + target_compile_definitions(libstudxml PUBLIC XML_STATIC=1) + endif() + +@@ -74,6 +74,6 @@ endif() + + # When xlnt is a static library, assume expat will be linked statically too + # TODO: is this a valid assumption? +-if(STATIC) ++if(0) + target_compile_definitions(libstudxml PUBLIC XML_STATIC=1) + endif() diff --git a/recipes/xlnt/all/patches/0003-include-limits.patch b/recipes/xlnt/all/patches/0003-include-limits.patch new file mode 100644 index 0000000000000..10da95ecdd562 --- /dev/null +++ b/recipes/xlnt/all/patches/0003-include-limits.patch @@ -0,0 +1,20 @@ +--- a/source/cell/cell.cpp ++++ b/source/cell/cell.cpp +@@ -24,6 +24,7 @@ + + #include + #include ++#include + #include + + #include +--- a/source/detail/number_format/number_formatter.cpp ++++ b/source/detail/number_format/number_formatter.cpp +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + #include + #include diff --git a/recipes/xlnt/all/test_package/CMakeLists.txt b/recipes/xlnt/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..5996d0ee3e85b --- /dev/null +++ b/recipes/xlnt/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(Xlnt REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE xlnt::xlnt) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/xlnt/all/test_package/conanfile.py b/recipes/xlnt/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/xlnt/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/xlnt/all/test_package/test_package.cpp b/recipes/xlnt/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..2ca71e20dee41 --- /dev/null +++ b/recipes/xlnt/all/test_package/test_package.cpp @@ -0,0 +1,14 @@ +#include + +int main() +{ + xlnt::workbook wb; + xlnt::worksheet ws = wb.active_sheet(); + ws.cell("A1").value(5); + ws.cell("B2").value("string data"); + ws.cell("C3").formula("=RAND()"); + ws.merge_cells("C3:C4"); + ws.freeze_panes("B2"); + wb.save("example.xlsx"); + return 0; +} diff --git a/recipes/xlnt/all/test_v1_package/CMakeLists.txt b/recipes/xlnt/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/xlnt/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/xlnt/all/test_v1_package/conanfile.py b/recipes/xlnt/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/xlnt/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/xlnt/config.yml b/recipes/xlnt/config.yml new file mode 100644 index 0000000000000..7f3d5d7f62dd8 --- /dev/null +++ b/recipes/xlnt/config.yml @@ -0,0 +1,3 @@ +versions: + "1.5.0": + folder: all From 58fb538a84e00e4319524a8482df98dc46621391 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Mon, 14 Nov 2022 17:08:25 +0100 Subject: [PATCH 2/4] unvendor libstudxml --- recipes/xlnt/all/conandata.yml | 5 +- recipes/xlnt/all/conanfile.py | 15 +++-- .../0001-fix-cmake-and-unvendor-deps.patch | 46 +++++++++---- ...limits.patch => 0002-include-limits.patch} | 0 .../xlnt/all/patches/0002-libstudxml.patch | 65 ------------------- recipes/xlnt/all/test_package/conanfile.py | 11 ++-- 6 files changed, 50 insertions(+), 92 deletions(-) rename recipes/xlnt/all/patches/{0003-include-limits.patch => 0002-include-limits.patch} (100%) delete mode 100644 recipes/xlnt/all/patches/0002-libstudxml.patch diff --git a/recipes/xlnt/all/conandata.yml b/recipes/xlnt/all/conandata.yml index 1be65b044d84b..42ae51c5734e5 100644 --- a/recipes/xlnt/all/conandata.yml +++ b/recipes/xlnt/all/conandata.yml @@ -7,9 +7,6 @@ patches: - patch_file: "patches/0001-fix-cmake-and-unvendor-deps.patch" patch_description: "Fix CMakeLists and unvendor miniz & utfcpp" patch_type: "conan" - - patch_file: "patches/0002-libstudxml.patch" - patch_description: "Fix CMakeLists of libstudxml and unvendor expat" - patch_type: "conan" - - patch_file: "patches/0003-include-limits.patch" + - patch_file: "patches/0002-include-limits.patch" patch_description: "Add missing includes" patch_type: "conan" diff --git a/recipes/xlnt/all/conanfile.py b/recipes/xlnt/all/conanfile.py index 1b669356808c4..d492b1f1070d1 100644 --- a/recipes/xlnt/all/conanfile.py +++ b/recipes/xlnt/all/conanfile.py @@ -1,7 +1,9 @@ from conan import ConanFile +from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +from conan.tools.scm import Version import os required_conan_version = ">=1.53.0" @@ -40,14 +42,17 @@ def layout(self): cmake_layout(self, src_folder="src") def requirements(self): + self.requires("libstudxml/1.1.0-b.10+1") self.requires("miniz/3.0.1") self.requires("utfcpp/3.2.2") - # TODO: unvendor libstudxml (needs libstudxml >= 1.1.0 in conan-center) - self.requires("expat/2.4.9") # dependency of libstudxml actually def validate(self): if self.info.settings.compiler.get_safe("cppstd"): check_min_cppstd(self, 11) + libstudxml_version = Version(self.dependencies["libstudxml"].ref.version) + libstudxml_major_minor = f"{libstudxml_version.major}.{libstudxml_version.minor}" + if Version(libstudxml_major_minor) < "1.1": + raise ConanInvalidConfiguration(f"{self.ref} not compatible with libstudxml < 1.1") def source(self): get(self, **self.conan_data["sources"][self.version], @@ -66,10 +71,8 @@ def generate(self): def _patch_sources(self): apply_conandata_patches(self) - # For some reason this useless file can break compilation - rm(self, "version", os.path.join(self.source_folder, "third-party", "libstudxml")) # Remove unvendored third party libs - for third_party in (os.path.join("libstudxml", "libstudxml", "details", "expat"), "miniz", "utfcpp"): + for third_party in ("libstudxml", "miniz", "utfcpp"): rmdir(self, os.path.join(self.source_folder, "third-party", third_party)) def build(self): diff --git a/recipes/xlnt/all/patches/0001-fix-cmake-and-unvendor-deps.patch b/recipes/xlnt/all/patches/0001-fix-cmake-and-unvendor-deps.patch index 556d5c605d3b2..f894c2e80026b 100644 --- a/recipes/xlnt/all/patches/0001-fix-cmake-and-unvendor-deps.patch +++ b/recipes/xlnt/all/patches/0001-fix-cmake-and-unvendor-deps.patch @@ -10,7 +10,16 @@ # Project metadata set(PROJECT_VENDOR "Thomas Fussell") -@@ -30,12 +27,9 @@ if(MSVC) +@@ -18,8 +15,6 @@ set(XLNT_SOURCE_DIR ${XLNT_ROOT_DIR}/source) + set(THIRD_PARTY_DIR ${XLNT_ROOT_DIR}/third-party) + + # Include libstudxml library +-add_subdirectory(${THIRD_PARTY_DIR}/libstudxml +- ${CMAKE_CURRENT_BINARY_DIR}/third-party/libstudxml) + + if(COVERAGE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") +@@ -30,12 +25,9 @@ if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") # level 4 warnings set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # multi-processor compilation elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") @@ -23,7 +32,7 @@ # blacklist warnings that are not relevant set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat") # ignore warnings about C++98 compatibility set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat-pedantic") # ignore pedantic warnings about C++98 compatibility -@@ -54,7 +48,7 @@ if(STATIC_CRT) +@@ -54,7 +46,7 @@ if(STATIC_CRT) ucm_set_runtime(STATIC) endif() @@ -32,7 +41,7 @@ # Prevent a warning about deployment target not being set by setting it to current OSX version execute_process(COMMAND "sw_vers -productVersion | awk -F'.' '{print $1\".\"$2}'" OUTPUT_VARIABLE OSX_VERSION) -@@ -84,8 +78,6 @@ file(GLOB WORKBOOK_HEADERS ${XLNT_INCLUDE_DIR}/xlnt/workbook/*.hpp) +@@ -84,8 +76,6 @@ file(GLOB WORKBOOK_HEADERS ${XLNT_INCLUDE_DIR}/xlnt/workbook/*.hpp) file(GLOB WORKBOOK_SOURCES ${XLNT_SOURCE_DIR}/workbook/*.cpp) file(GLOB WORKSHEET_HEADERS ${XLNT_INCLUDE_DIR}/xlnt/worksheet/*.hpp) file(GLOB WORKSHEET_SOURCES ${XLNT_SOURCE_DIR}/worksheet/*.cpp) @@ -41,7 +50,7 @@ file(GLOB DETAIL_ROOT_HEADERS ${XLNT_SOURCE_DIR}/detail/*.hpp) file(GLOB DETAIL_ROOT_SOURCES ${XLNT_SOURCE_DIR}/detail/*.cpp) -@@ -115,12 +107,12 @@ set(XLNT_HEADERS ${ROOT_HEADERS} ${CELL_HEADERS} ${CHARTS_HEADERS} +@@ -115,12 +105,12 @@ set(XLNT_HEADERS ${ROOT_HEADERS} ${CELL_HEADERS} ${CHARTS_HEADERS} ${CHARTSHEET_HEADERS} ${DRAWING_HEADERS} ${FORMULA_HEADERS} ${PACKAGING_HEADERS} ${STYLES_HEADERS} ${UTILS_HEADERS} ${WORKBOOK_HEADERS} ${WORKSHEET_HEADERS} ${DETAIL_HEADERS} ${DETAIL_CRYPTO_HEADERS} @@ -56,7 +65,16 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # Set a default CMAKE_INSTALL_PREFIX if one wasn't specified -@@ -168,7 +160,7 @@ if(NOT STATIC) +@@ -159,7 +149,7 @@ if(NOT STATIC) + add_library(xlnt SHARED + ${XLNT_HEADERS} + ${XLNT_SOURCES} +- $) ++ ) + + target_compile_definitions(xlnt PRIVATE XLNT_SHARED=1) + +@@ -168,10 +158,10 @@ if(NOT STATIC) PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} @@ -64,24 +82,28 @@ + ) else() # Compile static library - add_library(xlnt STATIC ${XLNT_HEADERS} ${XLNT_SOURCES} $) -@@ -186,8 +178,13 @@ target_include_directories(xlnt +- add_library(xlnt STATIC ${XLNT_HEADERS} ${XLNT_SOURCES} $) ++ add_library(xlnt STATIC ${XLNT_HEADERS} ${XLNT_SOURCES}) + target_compile_definitions(xlnt PUBLIC XLNT_STATIC=1) + endif() + +@@ -185,9 +175,12 @@ target_include_directories(xlnt + $ PRIVATE ${XLNT_SOURCE_DIR} - ${XLNT_SOURCE_DIR}/../third-party/libstudxml +- ${XLNT_SOURCE_DIR}/../third-party/libstudxml - ${XLNT_SOURCE_DIR}/../third-party/miniz - ${XLNT_SOURCE_DIR}/../third-party/utfcpp) +) ++find_package(libstudxml REQUIRED CONFIG) +find_package(miniz REQUIRED CONFIG) +find_package(utf8cpp REQUIRED CONFIG) -+find_package(EXPAT REQUIRED MODULE) -+target_link_libraries(xlnt PRIVATE miniz::miniz utf8cpp EXPAT::EXPAT) -+target_compile_definitions(xlnt PRIVATE LIBSTUDXML_EXTERNAL_EXPAT) ++target_link_libraries(xlnt PRIVATE miniz::miniz utf8cpp libstudxml::libstudxml) +target_compile_features(xlnt PUBLIC cxx_std_11) # Platform- and file-specific settings, MSVC if(MSVC) -@@ -240,7 +236,6 @@ source_group(styles FILES ${STYLES_HEADERS} ${STYLES_SOURCES}) +@@ -240,7 +233,6 @@ source_group(styles FILES ${STYLES_HEADERS} ${STYLES_SOURCES}) source_group(utils FILES ${UTILS_HEADERS} ${UTILS_SOURCES}) source_group(workbook FILES ${WORKBOOK_HEADERS} ${WORKBOOK_SOURCES}) source_group(worksheet FILES ${WORKSHEET_HEADERS} ${WORKSHEET_SOURCES}) diff --git a/recipes/xlnt/all/patches/0003-include-limits.patch b/recipes/xlnt/all/patches/0002-include-limits.patch similarity index 100% rename from recipes/xlnt/all/patches/0003-include-limits.patch rename to recipes/xlnt/all/patches/0002-include-limits.patch diff --git a/recipes/xlnt/all/patches/0002-libstudxml.patch b/recipes/xlnt/all/patches/0002-libstudxml.patch deleted file mode 100644 index deb3c283bccdf..0000000000000 --- a/recipes/xlnt/all/patches/0002-libstudxml.patch +++ /dev/null @@ -1,65 +0,0 @@ ---- a/third-party/libstudxml/CMakeLists.txt -+++ b/third-party/libstudxml/CMakeLists.txt -@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.1) - project(libstudxml) - - # Require C++11 compiler --set(CMAKE_CXX_STANDARD 11) --set(CMAKE_CXX_STANDARD_REQUIRED ON) - - set(LIBSTUDXML_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) - set(LIBSTUDXML_INCLUDE_DIR ${LIBSTUDXML_ROOT_DIR}) -@@ -18,19 +16,16 @@ set(LIBSTUDXML - ${LIBSTUDXML_ROOT_DIR}/libstudxml/qname.cxx - ${LIBSTUDXML_ROOT_DIR}/libstudxml/serializer.cxx - ${LIBSTUDXML_ROOT_DIR}/libstudxml/value-traits.cxx -- ${LIBSTUDXML_ROOT_DIR}/libstudxml/content -- ${LIBSTUDXML_ROOT_DIR}/libstudxml/exception -- ${LIBSTUDXML_ROOT_DIR}/libstudxml/forward -- ${LIBSTUDXML_ROOT_DIR}/libstudxml/parser -- ${LIBSTUDXML_ROOT_DIR}/libstudxml/qname -- ${LIBSTUDXML_ROOT_DIR}/libstudxml/serializer -- ${LIBSTUDXML_ROOT_DIR}/libstudxml/value-traits) -+ ${LIBSTUDXML_ROOT_DIR}/libstudxml/qname.cxx -+ ${LIBSTUDXML_ROOT_DIR}/libstudxml/serializer.cxx -+ ${LIBSTUDXML_ROOT_DIR}/libstudxml/value-traits.cxx) - - set(GENX - ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/genx/char-props.c - ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/genx/genx.c - ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/genx/genx.h) - -+if(0) - set(EXPAT - ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmlparse.c - ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmlrole.c -@@ -48,15 +43,20 @@ set(EXPAT - ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmlrole.h - ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmltok_impl.h - ${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmltok.h) -+endif() - - add_library(libstudxml OBJECT ${LIBSTUDXML} ${GENX} ${EXPAT}) -+find_package(EXPAT REQUIRED MODULE) -+target_link_libraries(libstudxml PUBLIC EXPAT::EXPAT) -+target_compile_definitions(libstudxml PUBLIC LIBSTUDXML_EXTERNAL_EXPAT) -+target_compile_features(libstudxml PUBLIC cxx_std_11) - - target_compile_definitions(libstudxml PUBLIC LIBSTUDXML_STATIC_LIB=1) - target_include_directories(libstudxml - PUBLIC ${LIBSTUDXML_ROOT_DIR} - PUBLIC ${EXPAT_INCLUDE_DIRS}) - --if(STATIC) -+if(0) - target_compile_definitions(libstudxml PUBLIC XML_STATIC=1) - endif() - -@@ -74,6 +74,6 @@ endif() - - # When xlnt is a static library, assume expat will be linked statically too - # TODO: is this a valid assumption? --if(STATIC) -+if(0) - target_compile_definitions(libstudxml PUBLIC XML_STATIC=1) - endif() diff --git a/recipes/xlnt/all/test_package/conanfile.py b/recipes/xlnt/all/test_package/conanfile.py index 3a8c6c5442b33..0a6bc68712d90 100644 --- a/recipes/xlnt/all/test_package/conanfile.py +++ b/recipes/xlnt/all/test_package/conanfile.py @@ -1,5 +1,5 @@ from conan import ConanFile -from conan.tools.build import cross_building +from conan.tools.build import can_run from conan.tools.cmake import CMake, cmake_layout import os @@ -7,19 +7,20 @@ class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" - - def requirements(self): - self.requires(self.tested_reference_str) + test_type = "explicit" def layout(self): cmake_layout(self) + def requirements(self): + self.requires(self.tested_reference_str) + def build(self): cmake = CMake(self) cmake.configure() cmake.build() def test(self): - if not cross_building(self): + if can_run(self): bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") self.run(bin_path, env="conanrun") From e77327e1d14cd0b70537de807ced541a41304549 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Fri, 25 Nov 2022 20:49:54 +0100 Subject: [PATCH 3/4] Update recipes/xlnt/all/conandata.yml --- recipes/xlnt/all/conandata.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/xlnt/all/conandata.yml b/recipes/xlnt/all/conandata.yml index 42ae51c5734e5..deb2183231a72 100644 --- a/recipes/xlnt/all/conandata.yml +++ b/recipes/xlnt/all/conandata.yml @@ -5,7 +5,7 @@ sources: patches: "1.5.0": - patch_file: "patches/0001-fix-cmake-and-unvendor-deps.patch" - patch_description: "Fix CMakeLists and unvendor miniz & utfcpp" + patch_description: "Fix CMakeLists and unvendor dependencies" patch_type: "conan" - patch_file: "patches/0002-include-limits.patch" patch_description: "Add missing includes" From 4c79460938dff444ca7484f0d11f907e4c22283e Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Mon, 28 Nov 2022 10:15:28 +0100 Subject: [PATCH 4/4] Update recipes/xlnt/all/conandata.yml Co-authored-by: Chris Mc --- recipes/xlnt/all/conandata.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/xlnt/all/conandata.yml b/recipes/xlnt/all/conandata.yml index deb2183231a72..e00cfba4123d9 100644 --- a/recipes/xlnt/all/conandata.yml +++ b/recipes/xlnt/all/conandata.yml @@ -9,4 +9,4 @@ patches: patch_type: "conan" - patch_file: "patches/0002-include-limits.patch" patch_description: "Add missing includes" - patch_type: "conan" + patch_type: "portability"