-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add xlnt/1.5.0 * unvendor libstudxml * Update recipes/xlnt/all/conandata.yml * Update recipes/xlnt/all/conandata.yml Co-authored-by: Chris Mc <prince.chrismc@gmail.com> Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
- Loading branch information
1 parent
1041fc8
commit 59fd3d5
Showing
10 changed files
with
326 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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 dependencies" | ||
patch_type: "conan" | ||
- patch_file: "patches/0002-include-limits.patch" | ||
patch_description: "Add missing includes" | ||
patch_type: "portability" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
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, rmdir | ||
from conan.tools.scm import Version | ||
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("libstudxml/1.1.0-b.10+1") | ||
self.requires("miniz/3.0.1") | ||
self.requires("utfcpp/3.2.2") | ||
|
||
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], | ||
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) | ||
# Remove unvendored third party libs | ||
for third_party in ("libstudxml", "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" |
113 changes: 113 additions & 0 deletions
113
recipes/xlnt/all/patches/0001-fix-cmake-and-unvendor-deps.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
--- 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") | ||
@@ -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") | ||
- 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 +46,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 +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) | ||
-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 +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} | ||
- ${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 | ||
@@ -159,7 +149,7 @@ if(NOT STATIC) | ||
add_library(xlnt SHARED | ||
${XLNT_HEADERS} | ||
${XLNT_SOURCES} | ||
- $<TARGET_OBJECTS:libstudxml>) | ||
+ ) | ||
|
||
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} | ||
- INSTALL_NAME_DIR "${XLNT_LIB_DEST_DIR}") | ||
+ ) | ||
else() | ||
# Compile static library | ||
- add_library(xlnt STATIC ${XLNT_HEADERS} ${XLNT_SOURCES} $<TARGET_OBJECTS:libstudxml>) | ||
+ 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 | ||
$<INSTALL_INTERFACE:${XLNT_INC_DEST_DIR}> | ||
PRIVATE | ||
${XLNT_SOURCE_DIR} | ||
- ${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) | ||
+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 +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}) | ||
-source_group(third-party\\miniz FILES ${MINIZ_HEADERS} ${MINIZ_SOURCES}) | ||
|
||
# Install library | ||
install(TARGETS xlnt EXPORT XlntTargets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- a/source/cell/cell.cpp | ||
+++ b/source/cell/cell.cpp | ||
@@ -24,6 +24,7 @@ | ||
|
||
#include <algorithm> | ||
#include <cmath> | ||
+#include <limits> | ||
#include <sstream> | ||
|
||
#include <xlnt/cell/cell.hpp> | ||
--- a/source/detail/number_format/number_formatter.cpp | ||
+++ b/source/detail/number_format/number_formatter.cpp | ||
@@ -24,6 +24,7 @@ | ||
#include <algorithm> | ||
#include <cctype> | ||
#include <cmath> | ||
+#include <limits> | ||
|
||
#include <xlnt/utils/exceptions.hpp> | ||
#include <detail/default_case.hpp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import CMake, cmake_layout | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" | ||
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 can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") | ||
self.run(bin_path, env="conanrun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <xlnt/xlnt.hpp> | ||
|
||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"1.5.0": | ||
folder: all |