fast_excel 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -1
  3. data/CHANGELOG.md +3 -1
  4. data/Rakefile +4 -1
  5. data/fast_excel.gemspec +1 -1
  6. data/lib/fast_excel/binding/workbook.rb +9 -0
  7. data/lib/fast_excel/binding/worksheet.rb +2 -2
  8. data/lib/fast_excel/binding.rb +16 -13
  9. data/libxlsxwriter/.cirrus.yml +9 -0
  10. data/libxlsxwriter/.github/workflows/cmake_actions.yml +10 -6
  11. data/libxlsxwriter/.github/workflows/code_style.yml +2 -0
  12. data/libxlsxwriter/.github/workflows/make_32_actions.yml +43 -0
  13. data/libxlsxwriter/.github/workflows/windows_build.yml +7 -6
  14. data/libxlsxwriter/.github/workflows/zig_build.yml +1 -3
  15. data/libxlsxwriter/.gitignore +9 -7
  16. data/libxlsxwriter/.indent.pro +6 -0
  17. data/libxlsxwriter/CMakeLists.txt +377 -238
  18. data/libxlsxwriter/Changes.txt +189 -0
  19. data/libxlsxwriter/LICENSE.txt +1 -1
  20. data/libxlsxwriter/Makefile +36 -4
  21. data/libxlsxwriter/Readme.md +1 -1
  22. data/libxlsxwriter/build.zig +181 -92
  23. data/libxlsxwriter/build.zig.zon +15 -4
  24. data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +4 -0
  25. data/libxlsxwriter/include/xlsxwriter/app.h +2 -1
  26. data/libxlsxwriter/include/xlsxwriter/chart.h +134 -1
  27. data/libxlsxwriter/include/xlsxwriter/chartsheet.h +2 -1
  28. data/libxlsxwriter/include/xlsxwriter/comment.h +2 -1
  29. data/libxlsxwriter/include/xlsxwriter/common.h +12 -8
  30. data/libxlsxwriter/include/xlsxwriter/content_types.h +3 -1
  31. data/libxlsxwriter/include/xlsxwriter/core.h +2 -1
  32. data/libxlsxwriter/include/xlsxwriter/custom.h +2 -1
  33. data/libxlsxwriter/include/xlsxwriter/drawing.h +2 -1
  34. data/libxlsxwriter/include/xlsxwriter/format.h +34 -3
  35. data/libxlsxwriter/include/xlsxwriter/hash_table.h +2 -1
  36. data/libxlsxwriter/include/xlsxwriter/metadata.h +5 -1
  37. data/libxlsxwriter/include/xlsxwriter/packager.h +6 -1
  38. data/libxlsxwriter/include/xlsxwriter/relationships.h +3 -1
  39. data/libxlsxwriter/include/xlsxwriter/rich_value.h +51 -0
  40. data/libxlsxwriter/include/xlsxwriter/rich_value_rel.h +50 -0
  41. data/libxlsxwriter/include/xlsxwriter/rich_value_structure.h +53 -0
  42. data/libxlsxwriter/include/xlsxwriter/rich_value_types.h +49 -0
  43. data/libxlsxwriter/include/xlsxwriter/shared_strings.h +2 -1
  44. data/libxlsxwriter/include/xlsxwriter/styles.h +2 -1
  45. data/libxlsxwriter/include/xlsxwriter/table.h +2 -1
  46. data/libxlsxwriter/include/xlsxwriter/theme.h +2 -1
  47. data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +4 -4
  48. data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +3 -3
  49. data/libxlsxwriter/include/xlsxwriter/utility.h +58 -7
  50. data/libxlsxwriter/include/xlsxwriter/vml.h +2 -1
  51. data/libxlsxwriter/include/xlsxwriter/workbook.h +59 -2
  52. data/libxlsxwriter/include/xlsxwriter/worksheet.h +159 -13
  53. data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +11 -10
  54. data/libxlsxwriter/include/xlsxwriter.h +5 -4
  55. data/libxlsxwriter/libxlsxwriter.podspec +6 -6
  56. data/libxlsxwriter/src/Makefile +2 -1
  57. data/libxlsxwriter/src/app.c +2 -1
  58. data/libxlsxwriter/src/chart.c +360 -63
  59. data/libxlsxwriter/src/chartsheet.c +2 -1
  60. data/libxlsxwriter/src/comment.c +2 -1
  61. data/libxlsxwriter/src/content_types.c +22 -1
  62. data/libxlsxwriter/src/core.c +2 -1
  63. data/libxlsxwriter/src/custom.c +2 -1
  64. data/libxlsxwriter/src/drawing.c +7 -3
  65. data/libxlsxwriter/src/format.c +21 -1
  66. data/libxlsxwriter/src/hash_table.c +2 -1
  67. data/libxlsxwriter/src/metadata.c +176 -20
  68. data/libxlsxwriter/src/packager.c +306 -6
  69. data/libxlsxwriter/src/relationships.c +25 -1
  70. data/libxlsxwriter/src/rich_value.c +191 -0
  71. data/libxlsxwriter/src/rich_value_rel.c +142 -0
  72. data/libxlsxwriter/src/rich_value_structure.c +162 -0
  73. data/libxlsxwriter/src/rich_value_types.c +199 -0
  74. data/libxlsxwriter/src/shared_strings.c +2 -1
  75. data/libxlsxwriter/src/styles.c +31 -7
  76. data/libxlsxwriter/src/table.c +2 -1
  77. data/libxlsxwriter/src/theme.c +2 -1
  78. data/libxlsxwriter/src/utility.c +136 -46
  79. data/libxlsxwriter/src/vml.c +2 -1
  80. data/libxlsxwriter/src/workbook.c +191 -10
  81. data/libxlsxwriter/src/worksheet.c +514 -34
  82. data/libxlsxwriter/src/xmlwriter.c +17 -22
  83. data/libxlsxwriter/third_party/minizip/Makefile.orig +1 -1
  84. data/libxlsxwriter/third_party/minizip/configure.ac +1 -1
  85. data/libxlsxwriter/third_party/minizip/ioapi.h +6 -6
  86. data/libxlsxwriter/third_party/minizip/miniunz.c +16 -2
  87. data/libxlsxwriter/third_party/minizip/unzip.c +4 -4
  88. data/libxlsxwriter/third_party/minizip/unzip.h +1 -1
  89. data/libxlsxwriter/third_party/minizip/zip.c +5 -5
  90. data/libxlsxwriter/third_party/minizip/zip.h +3 -3
  91. data/libxlsxwriter/version.txt +1 -1
  92. data/test/validations_test.rb +3 -3
  93. data/test/worksheet_test.rb +10 -2
  94. metadata +11 -4
  95. data/libxlsxwriter/cmake/FindMINIZIP.cmake +0 -121
  96. data/libxlsxwriter/cmake/FindPackage.cmake +0 -183
  97. data/libxlsxwriter/cmake/i686-toolchain.cmake +0 -7
@@ -1,154 +1,210 @@
1
- # :copyright: (c) 2017 Alex Huszagh.
2
- # :license: FreeBSD, see LICENSE.txt for more details.
3
-
4
- # Description
5
- # ===========
6
- #
7
- # Use:
8
- # Move to a custom directory, ideally out of source, and
9
- # type `cmake $LXW_SOURCE $FLAGS`, where `LXW_SOURCE` is the
10
- # path to the libxlsxwriter project, and `FLAGS` are custom
11
- # flags to pass to the compiler.
12
- #
13
- # Example:
14
- # For example, in the project directory, to build libxlsxwriter
15
- # and the unittests in release mode, type:
16
- # mkdir build && cd build
17
- # cmake .. -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
18
- # cmake --build . --config Release
19
- # ctest -C Release -V
20
- # cmake --build . --config Release --target install
21
- #
22
- # If using a Makefile generator, you may use the simpler
23
- # mkdir build && cd build
24
- # cmake .. -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
25
- # make
26
- # make test
27
- # make install
28
- #
29
- # Flags:
30
- # ZLIB_ROOT
31
- # The ZLIB root directory can be specified either through
32
- # an environment variable (`export ZLIB_ROOT=/usr/include`)
33
- # or using a flag with CMake (`-DZLIB_ROOT:STRING=/usr/include`).
34
- # This sets the preferred search path for the ZLIB installation.
35
- #
36
- # BUILD_TESTS
37
- # Build unittests (default off). To build the unittests,
38
- # pass `-DBUILD_TESTS=ON` during configuration.
39
- #
40
- # BUILD_EXAMPLES
41
- # Build example files (default off). To build the examples,
42
- # pass `-DBUILD_EXAMPLES=ON` during configuration.
43
- #
44
- # USE_STANDARD_TMPFILE
45
- # Use the standard tmpfile() function (default off). To enable
46
- # the standard tmpfile, pass `-DUSE_STANDARD_TMPFILE=ON`
47
- # during configuration. This may produce bugs while cross-
48
- # compiling or using MinGW/MSYS.
49
- #
50
- # USE_DTOA_LIBRARY
51
- # Use the third party emyg_dtoa() library (default off). The
52
- # emyg_dtoa() library is used to avoid sprintf double issues with
53
- # different locale settings. To enable this library, pass
54
- # `-DUSE_DTOA_LIBRARY=ON` during configuration.
55
- #
56
- # USE_NO_MD5
57
- # Compile without third party MD5 support. This will turn off the
58
- # functionality of avoiding duplicate image files in the output xlsx
59
- # file. To enable this option pass `-DUSE_NO_MD5=ON` during
60
- # configuration.
61
- #
62
- # USE_OPENSSL_MD5 Compile with OpenSSL MD5 support. This will link
63
- # against libcrypto for MD5 support rather than using the local MD5
64
- # support. MD5 support is required to avoid duplicate image files in
65
- # the output xlsx file. To enable this option pass
66
- # `-DUSE_OPENSSL_MD5=ON` during configuration.
67
- #
68
- # USE_STATIC_MSVC_RUNTIME
69
- # Use the static msvc runtime library when compiling with msvc (default off)
70
- # To enable, pass `-DUSE_STATIC_MSVC_RUNTIME` during configuration.
71
- #
72
- # Toolchains:
73
- # On multiarch Linux systems, which can build and run multiple
74
- # binary targets on the same system, we include an `i686-toolchain`
75
- # file to enable building i686 (x86 32-bit) targets on x86_64 systems.
76
- # To use the i686 toolchain, pass the `-DCMAKE_TOOLCHAIN_FILE` option
77
- # during CMake configuration. For example, from the build directory,
78
- # you would use:
79
- # cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/i686-toolchain.cmake
80
- #
81
- # CMake Options:
82
- # CMake sets debug and release builds with the `CMAKE_BUILD_TYPE`
83
- # option, which can be set as a flag during configuration.
84
- # To build in release mode, pass `-DCMAKE_BUILD_TYPE=Release`
85
- # during configuration.
86
- #
87
- # CMake sets the creation of static and shared libraries with the
88
- # `BUILD_SHARED_LIBS` option, which can be set as a flag during
89
- # configuration. To build a static library, pass
90
- # `-DBUILD_SHARED_LIBS=OFF` during configuration.
91
- #
92
- # Generators:
93
- # CMake also supports custom build generators, such as MakeFiles,
94
- # Ninja, Visual Studio, and XCode. For example, to generate
95
- # a Visual Studio solution, configure with:
96
- # cmake .. -G "Visual Studio 14 2015 Win64"
97
- #
98
- # For more information on using generators, see:
99
- # https://cmake.org/cmake/help/v3.0/manual/cmake-generators.7.html
100
- #
101
-
102
- set(CMAKE_LEGACY_CYGWIN_WIN32 1)
103
- if(MSVC)
104
- cmake_minimum_required(VERSION 3.4)
105
- else()
106
- cmake_minimum_required(VERSION 3.1)
107
- endif()
1
+ # :copyright: 2014-2026. John McNamara, Alex Huszagh.
2
+ # :license: SPDX-License-Identifier: BSD-2-Clause
3
+
4
+ # CMake file for libxlsxwriter
5
+ # ============================
6
+ #
7
+ # To build libxlsxwriter with CMake move to a custom directory, ideally outside
8
+ # the root of the source tree, and type `cmake $LXW_SOURCE_LOCATION $FLAGS`,
9
+ # where `LXW_SOURCE_LOCATION` is the path to the libxlsxwriter project, and
10
+ # `FLAGS` are custom flags to pass to the compiler.
11
+ #
12
+ # For example, in the project directory, you can build libxlsxwriter as follows:
13
+ #
14
+ # ```
15
+ # mkdir build
16
+ # cd build
17
+ #
18
+ # cmake .. -DCMAKE_BUILD_TYPE=Release
19
+ # cmake --build . --config Release
20
+ #
21
+ # ```
22
+ #
23
+ # Or to build and run the tests (this can take several minutes):
24
+ #
25
+ # ```
26
+ # mkdir build
27
+ # cd build
28
+ #
29
+ # cmake .. -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
30
+ # cmake --build . --config Release
31
+ # ctest -C Release -V
32
+ # cmake --build . --config Release --target install
33
+ # ```
34
+ #
35
+ # If the tests run successfully, you can install the library as follows:
36
+ #
37
+ # ```
38
+ # cmake --build . --config Release --target install
39
+ # ```
40
+ #
41
+ # The libxlsxwriter CMake options are shown below.
42
+
43
+ # ---------------------
44
+ # Project configuration
45
+ # ---------------------
46
+ cmake_minimum_required(VERSION 3.16)
47
+
48
+ set(XLSX_PROJECT_NAME
49
+ "xlsxwriter"
50
+ CACHE STRING
51
+ "Libxlsxwriter is a C library for creating new Excel XLSX files"
52
+ )
108
53
 
109
- SET(XLSX_PROJECT_NAME "xlsxwriter" CACHE STRING "Optional project and binary name")
110
54
  set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
111
55
  project(${XLSX_PROJECT_NAME} C)
112
56
  enable_testing()
113
57
 
114
- # POLICY
115
- # ------
58
+ # -------------------
59
+ # Compilation options
60
+ # -------------------
61
+
62
+ # `USE_SYSTEM_MINIZIP`
63
+ #
64
+ # Libxlsxwriter uses the `minizip` component of `zlib`to create the xlsx zip
65
+ # file container. The vendored source files for `minizip` are included in the
66
+ # src tree of libxlsxwriter and are statically linked by default.
67
+ #
68
+ # You can use this option if you have the `minizip` library already installed on
69
+ # your system and prefer to dynamically link against it.
70
+ #
71
+ # To enable this option pass `-DUSE_SYSTEM_MINIZIP=ON` during configuration.
72
+ option(
73
+ USE_SYSTEM_MINIZIP
74
+ "Use system minizip library instead of the vendored copy"
75
+ OFF
76
+ )
77
+
78
+ # `USE_STANDARD_TMPFILE`
79
+ #
80
+ # Uses the standard library `tmpfile` function to handle temp files instead of
81
+ # the vendored `tmpfileplus` function. Turning this off eliminates a dependency.
82
+ # This option is not recommended for Windows as it doesn't support a
83
+ # configurable location and the default location may be in a privileged
84
+ # directory.
85
+ #
86
+ # To enable this option pass `-DUSE_STANDARD_TMPFILE=ON` during configuration.
87
+ option(
88
+ USE_STANDARD_TMPFILE
89
+ "Use the C standard library tmpfile() instead of tmpfileplus"
90
+ OFF
91
+ )
92
+
93
+ # `USE_OPENSSL_MD5`
94
+ #
95
+ # Uses OpenSSL to provide a MD5 digest of image files in order to avoid storing
96
+ # duplicates instead of the vendored OpenWall MD5 functions. This will link
97
+ # against libcrypto for MD5 support rather than using the local MD5 support.
98
+ #
99
+ # To enable this option pass `-DUSE_OPENSSL_MD5=ON` during configuration.
100
+ option(
101
+ USE_OPENSSL_MD5
102
+ "Build libxlsxwriter with the OpenSSL MD5 support instead of built in version"
103
+ OFF
104
+ )
116
105
 
117
- # The use of the word ZLIB_ROOT should still work prior to "3.12.0",
118
- # just it's been generalized for all packages now. Just set the policy
119
- # to new, so we use it, and it will be used prior to 3.12 anyway.
120
- if(${CMAKE_VERSION} VERSION_GREATER "3.12" OR ${CMAKE_VERSION} VERSION_EQUAL "3.12")
121
- cmake_policy(SET CMP0074 NEW)
106
+ # `USE_NO_MD5`
107
+ #
108
+ # Compile without third party MD5 support. This will turn off the functionality
109
+ # of avoiding duplicate image files in the output xlsx file. This can reduce the
110
+ # executable size slightly if you aren't using images.
111
+ #
112
+ # To enable this option pass `-DUSE_NO_MD5=ON` during configuration.
113
+ option(
114
+ USE_NO_MD5
115
+ "Build libxlsxwriter without MD5 support for eliminating duplicate images"
116
+ OFF
117
+ )
118
+
119
+ # `USE_DTOA_LIBRARY`
120
+ #
121
+ # Use the third party Milo Yip DTOA library to handle string formatting of
122
+ # doubles. This is used to avoid issues with double formatting in different
123
+ # locales and gives better performance with numeric data.
124
+ #
125
+ # To enable this library, pass `-DUSE_DTOA_LIBRARY=ON` during configuration.
126
+ option(
127
+ USE_DTOA_LIBRARY
128
+ "Use the Milo Yip DTOA library to handle string formatting of doubles."
129
+ OFF
130
+ )
131
+
132
+ # `USE_MEM_FILE`
133
+ #
134
+ # Use in memory files instead of temp files using the
135
+ # `fmemopen()`/`open_memstream()` functions. This option isn't available with
136
+ # MSVC.
137
+ #
138
+ # To enable this option pass `-DUSE_MEM_FILE=ON` during configuration.
139
+ if(NOT MSVC)
140
+ option(
141
+ USE_MEM_FILE
142
+ "Use fmemopen()/open_memstream() in place of temporary files"
143
+ OFF
144
+ )
122
145
  endif()
123
146
 
124
- # OPTIONS
125
- # -------
126
- SET(ZLIB_ROOT "" CACHE STRING "Optional root for the ZLIB installation")
147
+ # `BUILD_TESTS`
148
+ #
149
+ # Compile the unit and function tests for libxlsxwriter. This functional tests
150
+ # require the Python pytest library. The tests can be run with `ctest` after
151
+ # compilation. The uint tests do not work with MSVC and are turned off for that
152
+ # platform. Note, the tests can take a while to compile and run.
153
+ #
154
+ # To enable this option pass `-DBUILD_TESTS=ON` during configuration.
155
+ option(
156
+ BUILD_TESTS
157
+ "Build the libxlsxwriter unit and functional tests (requires pytest)"
158
+ OFF
159
+ )
160
+
161
+ # TODO LXW_TARGET_BIG_ENDIAN
127
162
 
128
- option(BUILD_TESTS "Build libxlsxwriter tests" OFF)
163
+ # `BUILD_EXAMPLES`
164
+ #
165
+ # Compile the libxlsxwriter example programs.
166
+ #
167
+ # To enable this option pass `-DBUILD_EXAMPLES=ON` during configuration.
129
168
  option(BUILD_EXAMPLES "Build libxlsxwriter examples" OFF)
130
- option(USE_SYSTEM_MINIZIP "Use system minizip installation" OFF)
131
- option(USE_STANDARD_TMPFILE "Use the C standard library's tmpfile()" OFF)
132
- option(USE_NO_MD5 "Build libxlsxwriter without third party MD5 lib" OFF)
133
- option(USE_OPENSSL_MD5 "Build libxlsxwriter with the OpenSSL MD5 lib" OFF)
134
- option(USE_MEM_FILE "Use fmemopen()/open_memstream() in place of temporary files" OFF)
135
- option(IOAPI_NO_64 "Disable 64-bit filesystem support" OFF)
136
- option(USE_DTOA_LIBRARY "Use the locale independent third party Milo Yip DTOA library" OFF)
137
169
 
170
+ # `BUILD_FUZZERS`
171
+ #
172
+ # Compile the fuzzer harnesses.
173
+ #
174
+ # To enable this option pass `-DBUILD_FUZZERS=ON` during configuration.
175
+ option(BUILD_FUZZERS "Build harness(es) for fuzzing" OFF)
176
+
177
+ # `IOAPI_NO_64`
178
+ #
179
+ # Turn off `IOAPI_NO_64` support in minizip ioapi.c.
180
+ #
181
+ # To enable this option pass `-DIOAPI_NO_64=ON` during configuration.
182
+ option(IOAPI_NO_64 "Disable 64-bit filesystem support with minizip" OFF)
183
+
184
+ # `USE_STATIC_MSVC_RUNTIME`
185
+ #
186
+ # Compile as a static library with the static MSVC runtime library.
187
+ #
188
+ # To enable this option pass `-DUSE_STATIC_MSVC_RUNTIME=ON` during configuration.
138
189
  if(MSVC)
139
190
  option(USE_STATIC_MSVC_RUNTIME "Use the static runtime library" OFF)
140
191
  endif()
141
192
 
142
- if(DEFINED ENV{${ZLIB_ROOT}})
193
+ # `ZLIB_ROOT`
194
+ #
195
+ # The `ZLIB `root directory can be specified either through an environment
196
+ # variable (`export ZLIB_ROOT=/usr/include`) or using a flag with CMake
197
+ # (`-DZLIB_ROOT:STRING=/usr/include`). This sets the preferred search path for
198
+ # the ZLIB installation.
199
+ set(ZLIB_ROOT "" CACHE STRING "Optional root for the ZLIB installation")
200
+ if(DEFINED ENV{ZLIB_ROOT})
143
201
  set(ZLIB_ROOT $ENV{ZLIB_ROOT})
144
202
  endif()
145
203
 
146
- if(IOAPI_NO_64)
147
- list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS IOAPI_NO_64=1)
148
- endif()
204
+ # -------------------------
205
+ # Configure the compilation
206
+ # -------------------------
149
207
 
150
- # CONFIGURATIONS
151
- # --------------
152
208
  if(USE_SYSTEM_MINIZIP)
153
209
  list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_SYSTEM_MINIZIP)
154
210
  endif()
@@ -176,91 +232,140 @@ if(USE_DTOA_LIBRARY)
176
232
  list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_DTOA_LIBRARY)
177
233
  endif()
178
234
 
235
+ if(IOAPI_NO_64)
236
+ list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS IOAPI_NO_64=1)
237
+ endif()
238
+
179
239
  if(NOT BUILD_SHARED_LIBS)
180
240
  if(UNIX)
181
241
  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
182
242
  elseif(MINGW OR MSYS)
183
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -static-libgcc -Wno-char-subscripts -Wno-long-long")
243
+ set(CMAKE_C_FLAGS
244
+ "${CMAKE_C_FLAGS} -static -static-libgcc -Wno-char-subscripts -Wno-long-long"
245
+ )
184
246
  list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_FILE32API)
185
247
  elseif(MSVC)
186
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Fd\"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb\"")
187
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Ox /Zi /Fd\"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb\"")
188
- set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /Zi /Fd\"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb\"")
189
- set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /Fd\"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb\"")
248
+ set(CMAKE_C_FLAGS_DEBUG
249
+ "${CMAKE_C_FLAGS_DEBUG} /Fd\"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb\""
250
+ )
251
+ set(CMAKE_C_FLAGS_RELEASE
252
+ "${CMAKE_C_FLAGS_RELEASE} /Ox /Zi /Fd\"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb\""
253
+ )
254
+ set(CMAKE_C_FLAGS_MINSIZEREL
255
+ "${CMAKE_C_FLAGS_MINSIZEREL} /Zi /Fd\"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb\""
256
+ )
257
+ set(CMAKE_C_FLAGS_RELWITHDEBINFO
258
+ "${CMAKE_C_FLAGS_RELWITHDEBINFO} /Fd\"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb\""
259
+ )
190
260
  endif()
191
261
  endif()
192
262
 
193
263
  if(MSVC AND USE_STATIC_MSVC_RUNTIME)
194
- foreach(flag_var CMAKE_C_FLAGS
195
- CMAKE_C_FLAGS_DEBUG
196
- CMAKE_C_FLAGS_RELEASE
197
- CMAKE_C_FLAGS_MINSIZEREL
198
- CMAKE_C_FLAGS_RELWITHDEBINFO)
264
+ foreach(
265
+ flag_var
266
+ CMAKE_C_FLAGS
267
+ CMAKE_C_FLAGS_DEBUG
268
+ CMAKE_C_FLAGS_RELEASE
269
+ CMAKE_C_FLAGS_MINSIZEREL
270
+ CMAKE_C_FLAGS_RELWITHDEBINFO
271
+ )
199
272
  if(${flag_var} MATCHES "/MD")
200
273
  string(REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
201
274
  endif()
202
275
  endforeach()
203
276
  endif()
204
277
 
205
- # Configure pkg-config
206
- file(READ "include/xlsxwriter.h" ver)
278
+ # -----------------------------
279
+ # Create the xlsxwriter.pc file
280
+ # -----------------------------
281
+ set(PREFIX ${CMAKE_INSTALL_PREFIX})
207
282
 
283
+ file(READ "include/xlsxwriter.h" ver)
208
284
  string(REGEX MATCH "LXW_VERSION \"([^\"]+)\"" _ ${ver})
209
285
  set(VERSION ${CMAKE_MATCH_1})
210
286
  string(REGEX MATCH "LXW_SOVERSION \"([^\"]+)\"" _ ${ver})
211
287
  set(SOVERSION ${CMAKE_MATCH_1})
212
- set(PREFIX ${CMAKE_INSTALL_PREFIX})
213
288
 
289
+ set(ENABLED_OPTIONS "zlib")
290
+ if(USE_SYSTEM_MINIZIP)
291
+ string(APPEND ENABLED_OPTIONS " minizip")
292
+ endif()
293
+ if(USE_OPENSSL_MD5)
294
+ string(APPEND ENABLED_OPTIONS " libcrypto")
295
+ endif()
296
+
297
+ # Expand out the xlsxwriter.pc file.
214
298
  configure_file(dev/release/pkg-config.txt xlsxwriter.pc @ONLY)
215
299
 
216
- # INCLUDES
217
- # --------
300
+ # ----------------
301
+ # Set the includes
302
+ # ----------------
218
303
  enable_language(CXX)
219
304
  list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
220
305
 
221
- # ZLIB
222
- find_package(ZLIB "1.0" REQUIRED)
306
+ # Set the zlib includes.
307
+ find_package(ZLIB "1.2.8" REQUIRED)
223
308
  list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
224
- message("zlib version: " ${ZLIB_VERSION})
225
309
 
226
- # MINIZIP
227
- if (USE_SYSTEM_MINIZIP)
228
- find_package(MINIZIP "1.0" REQUIRED)
229
- list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIRS})
310
+ # Set the minizip includes.
311
+ if(USE_SYSTEM_MINIZIP)
312
+ if(MSVC)
313
+ find_package(MINIZIP NAMES unofficial-minizip REQUIRED)
314
+ set(MINIZIP_LIBRARIES unofficial::minizip::minizip)
315
+ else()
316
+ find_package(PkgConfig REQUIRED)
317
+ pkg_check_modules(MINIZIP minizip)
318
+ list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIRS}/..)
319
+ endif()
230
320
  endif()
231
321
 
232
- # LIBRARY
233
- # -------
322
+ # Set the openssl includes.
323
+ if(USE_OPENSSL_MD5)
324
+ find_package(OpenSSL REQUIRED)
325
+ include_directories(${OPENSSL_INCLUDE_DIR})
326
+ endif()
327
+
328
+ # ----------------------------
329
+ # Set the library dependencies
330
+ # ----------------------------
234
331
  list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS NOCRYPT NOUNCRYPT)
235
332
 
236
- # Ensure CRT Secure warnings are disabled
333
+ # Ensure CRT Secure warnings are disabled.
237
334
  if(MSVC)
238
335
  list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS)
239
336
  endif()
240
337
 
241
- # Ensure "TESTING" macro is defined if building tests
338
+ # Ensure "TESTING" macro is defined if building tests.
242
339
  if(BUILD_TESTS)
243
340
  list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS TESTING)
244
341
  endif()
245
342
 
246
- # Define "LXW_BIG_ENDIAN" macro on big-endian architectures
343
+ # Define "LXW_BIG_ENDIAN" macro on big-endian architectures.
247
344
  include(TestBigEndian)
248
- TEST_BIG_ENDIAN(LXW_TARGET_BIG_ENDIAN)
345
+ test_big_endian(LXW_TARGET_BIG_ENDIAN)
249
346
  if(LXW_TARGET_BIG_ENDIAN)
250
347
  list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS LXW_BIG_ENDIAN)
251
348
  endif()
252
349
 
350
+ # Set the source files.
253
351
  file(GLOB LXW_SOURCES src/*.c)
254
352
  file(GLOB_RECURSE LXW_HEADERS RELATIVE include *.h)
255
353
 
354
+ # If not using the system minizip, add the vendored minizip source files.
256
355
  if(NOT USE_SYSTEM_MINIZIP)
257
- list(APPEND LXW_SOURCES third_party/minizip/ioapi.c third_party/minizip/zip.c)
356
+ list(
357
+ APPEND
358
+ LXW_SOURCES
359
+ third_party/minizip/ioapi.c
360
+ third_party/minizip/zip.c
361
+ )
258
362
  if(MSVC)
259
363
  list(APPEND LXW_SOURCES third_party/minizip/iowin32.c)
260
364
  endif()
261
365
  endif()
262
366
 
263
- if (NOT USE_STANDARD_TMPFILE)
367
+ # If not using the system tmpfile, add the vendored tmpfileplus files.
368
+ if(NOT USE_STANDARD_TMPFILE)
264
369
  list(APPEND LXW_SOURCES third_party/tmpfileplus/tmpfileplus.c)
265
370
  endif()
266
371
 
@@ -268,66 +373,71 @@ if(NOT USE_OPENSSL_MD5 AND NOT USE_NO_MD5)
268
373
  list(APPEND LXW_SOURCES third_party/md5/md5.c)
269
374
  endif()
270
375
 
271
- if(USE_OPENSSL_MD5)
272
- find_package(OpenSSL REQUIRED)
273
- if(OpenSSL_FOUND)
274
- include_directories(${OPENSSL_INCLUDE_DIR})
275
- message(STATUS "OpenSSL version: ${OPENSSL_VERSION}")
276
- endif()
277
- endif()
278
-
279
- if (USE_DTOA_LIBRARY)
376
+ if(USE_DTOA_LIBRARY)
280
377
  list(APPEND LXW_SOURCES third_party/dtoa/emyg_dtoa.c)
281
378
  endif()
282
379
 
380
+ # Set project metadata.
283
381
  set(LXW_PROJECT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
284
382
  set(LXW_LIB_DIR "${LXW_PROJECT_DIR}/lib")
285
383
  add_library(${PROJECT_NAME} "")
286
384
  set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${SOVERSION})
287
- target_sources(${PROJECT_NAME}
288
- PRIVATE ${LXW_SOURCES}
289
- PUBLIC ${LXW_HEADERS}
385
+ target_sources(${PROJECT_NAME} PRIVATE ${LXW_SOURCES} PUBLIC ${LXW_HEADERS})
386
+
387
+ target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB)
388
+
389
+ if(MINIZIP_LINK_LIBRARIES)
390
+ target_link_libraries(${PROJECT_NAME} PRIVATE ${MINIZIP_LINK_LIBRARIES})
391
+ else()
392
+ target_link_libraries(${PROJECT_NAME} PRIVATE ${MINIZIP_LIBRARIES})
393
+ endif()
394
+
395
+ target_link_libraries(
396
+ ${PROJECT_NAME}
397
+ PRIVATE ${LIB_CRYPTO} ${OPENSSL_CRYPTO_LIBRARY}
398
+ )
399
+
400
+ target_compile_definitions(
401
+ ${PROJECT_NAME}
402
+ PRIVATE ${LXW_PRIVATE_COMPILE_DEFINITIONS}
290
403
  )
291
- target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${ZLIB_LIBRARIES} ${MINIZIP_LIBRARIES} ${LIB_CRYPTO} ${OPENSSL_CRYPTO_LIBRARY})
292
- target_compile_definitions(${PROJECT_NAME} PRIVATE ${LXW_PRIVATE_COMPILE_DEFINITIONS})
293
404
 
294
- # /utf-8 needs VS2015 Update 2 or above.
295
- # In CMake 3.7 and above, we can use (MSVC_VERSION GREATER_EQUAL 1900) here.
296
- if(MSVC AND NOT (MSVC_VERSION LESS 1900))
405
+ # Ensure MSVC supports /utf-8.
406
+ if(MSVC AND MSVC_VERSION GREATER_EQUAL 1900)
297
407
  target_compile_options(${PROJECT_NAME} PRIVATE /utf-8)
298
408
  endif()
299
409
 
300
- if (WINDOWSSTORE)
301
- target_compile_definitions(${PROJECT_NAME} PRIVATE -DIOWIN32_USING_WINRT_API)
410
+ if(WINDOWSSTORE)
411
+ target_compile_definitions(
412
+ ${PROJECT_NAME}
413
+ PRIVATE -DIOWIN32_USING_WINRT_API
414
+ )
302
415
  endif()
303
416
 
304
- target_include_directories(${PROJECT_NAME}
417
+ target_include_directories(
418
+ ${PROJECT_NAME}
305
419
  PRIVATE ${LXW_PRIVATE_INCLUDE_DIRS}
306
420
  PUBLIC include include/xlsxwriter
307
421
  )
308
422
 
309
- # TESTS
310
- # -----
311
-
312
- # Create test and runner.
313
- #
314
- # Args:
315
- # sources Name of variable holding source files
316
- # target Test name
317
- #
423
+ # ------------------------
424
+ # Set up and run the tests
425
+ # ------------------------
318
426
 
319
- macro(CreateTest sources target)
427
+ # Macro for handling unit tests.
428
+ macro(create_test sources target)
320
429
  set(output_name xlsxwriter_${target})
321
430
  set(dependencies ${output_name})
322
431
 
323
432
  add_executable(${output_name} ${${sources}})
324
433
  target_link_libraries(${output_name} ${PROJECT_NAME})
325
434
  target_compile_definitions(${output_name} PRIVATE TESTING COLOR_OK)
326
- add_test(NAME ${output_name}
435
+ add_test(
436
+ NAME ${output_name}
327
437
  COMMAND ${output_name}
328
438
  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
329
439
  )
330
- endmacro(CreateTest)
440
+ endmacro(create_test)
331
441
 
332
442
  file(GLOB LXW_UTILITY_SOURCES test/unit/utility/test*.c)
333
443
  file(GLOB LXW_XMLWRITER_SOURCES test/unit/xmlwriter/test*.c)
@@ -346,70 +456,80 @@ file(GLOB LXW_CUSTOM_SOURCES test/unit/custom/test*.c)
346
456
  file(GLOB LXW_FUNCTIONAL_SOURCES test/functional/src/*.c)
347
457
 
348
458
  if(NOT MSVC)
349
- # Skip unit tests on Windows since ctest.h doesn't support it.
350
- set(LXW_UNIT_SOURCES
351
- test/unit/test_all.c
352
- ${LXW_UTILITY_SOURCES}
353
- ${LXW_XMLWRITER_SOURCES}
354
- ${LXW_WORKSHEET_SOURCES}
355
- ${LXW_SST_SOURCES}
356
- ${LXW_WORKBOOK_SOURCES}
357
- ${LXW_APP_SOURCES}
358
- ${LXW_CONTENTTYPES_SOURCES}
359
- ${LXW_CORE_SOURCES}
360
- ${LXW_RELATIONSHIPS_SOURCES}
361
- ${LXW_FORMAT_SOURCES}
362
- ${LXW_STYLES_SOURCES}
363
- ${LXW_DRAWING_SOURCES}
364
- ${LXW_CHART_SOURCES}
365
- ${LXW_CUSTOM_SOURCES}
366
- )
459
+ # Skip unit tests on Windows since ctest.h doesn't support it.
460
+ set(LXW_UNIT_SOURCES
461
+ test/unit/test_all.c
462
+ ${LXW_UTILITY_SOURCES}
463
+ ${LXW_XMLWRITER_SOURCES}
464
+ ${LXW_WORKSHEET_SOURCES}
465
+ ${LXW_SST_SOURCES}
466
+ ${LXW_WORKBOOK_SOURCES}
467
+ ${LXW_APP_SOURCES}
468
+ ${LXW_CONTENTTYPES_SOURCES}
469
+ ${LXW_CORE_SOURCES}
470
+ ${LXW_RELATIONSHIPS_SOURCES}
471
+ ${LXW_FORMAT_SOURCES}
472
+ ${LXW_STYLES_SOURCES}
473
+ ${LXW_DRAWING_SOURCES}
474
+ ${LXW_CHART_SOURCES}
475
+ ${LXW_CUSTOM_SOURCES}
476
+ )
367
477
  else()
368
- set(LXW_UNIT_SOURCES
369
- test/cpp/test_compilation.cpp
370
- )
478
+ set(LXW_UNIT_SOURCES test/cpp/test_compilation.cpp)
371
479
  endif()
372
480
 
373
481
  if(BUILD_TESTS)
374
- # unit tests
375
- CreateTest(LXW_UNIT_SOURCES unit)
482
+ # Unit tests.
483
+ create_test(LXW_UNIT_SOURCES unit)
376
484
 
377
- # functional tests
485
+ # Functional tests.
378
486
  find_package(Python COMPONENTS Interpreter REQUIRED)
379
487
  find_program(Pytest_EXECUTABLE NAMES pytest)
380
488
 
381
- if (NOT Pytest_EXECUTABLE)
382
- message("Please install the Python pytest library to run functional tests:")
489
+ if(NOT Pytest_EXECUTABLE)
490
+ message(
491
+ "Please install the Python pytest library to run the functional tests:"
492
+ )
383
493
  message(" pip install pytest\n")
384
494
  endif()
385
495
 
386
496
  foreach(source ${LXW_FUNCTIONAL_SOURCES})
387
- get_filename_component(basename ${source} NAME_WE)
388
- add_executable(${basename} ${source})
389
- target_link_libraries(${basename} xlsxwriter)
390
- set_target_properties(${basename} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "test/functional/src")
497
+ get_filename_component(basename ${source} NAME_WE)
498
+ add_executable(${basename} ${source})
499
+ target_link_libraries(${basename} xlsxwriter)
500
+ set_target_properties(
501
+ ${basename}
502
+ PROPERTIES RUNTIME_OUTPUT_DIRECTORY "test/functional/src"
503
+ )
391
504
  endforeach(source)
392
505
 
393
- add_custom_command(TARGET xlsxwriter_unit POST_BUILD
394
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/test/functional test/functional
506
+ add_custom_command(
507
+ TARGET xlsxwriter_unit
508
+ POST_BUILD
509
+ COMMAND
510
+ ${CMAKE_COMMAND} -E copy_directory
511
+ ${CMAKE_SOURCE_DIR}/test/functional test/functional
395
512
  )
396
513
 
397
514
  if(USE_NO_MD5)
398
- add_test(NAME functional
515
+ add_test(
516
+ NAME functional
399
517
  COMMAND pytest -v test/functional -m "not skipif"
400
518
  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
401
519
  )
402
520
  else()
403
- add_test(NAME functional
521
+ add_test(
522
+ NAME functional
404
523
  COMMAND pytest -v test/functional
405
524
  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
406
525
  )
407
526
  endif()
408
-
409
527
  endif()
410
528
 
411
- # EXAMPLES
412
- # --------
529
+ # ------------------------------------
530
+ # Compile and run the example programs
531
+ # ------------------------------------
532
+
413
533
  file(GLOB LXW_EXAMPLE_SOURCES examples/*.c)
414
534
 
415
535
  if(BUILD_EXAMPLES)
@@ -417,22 +537,41 @@ if(BUILD_EXAMPLES)
417
537
  get_filename_component(basename ${source} NAME_WE)
418
538
  add_executable(${basename} ${source})
419
539
  target_link_libraries(${basename} ${PROJECT_NAME})
420
- set_target_properties(${basename} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "examples")
540
+ set_target_properties(
541
+ ${basename}
542
+ PROPERTIES RUNTIME_OUTPUT_DIRECTORY "examples"
543
+ )
421
544
  endforeach(source)
422
545
  endif()
423
546
 
424
- # INSTALL
425
- # -------
547
+ # -----------------
548
+ # Fuzzing harnesses
549
+ # -----------------
550
+ if(BUILD_FUZZERS AND DEFINED ENV{LIB_FUZZING_ENGINE})
551
+ add_subdirectory(dev/fuzzing)
552
+ endif()
553
+
554
+ # -------------------
555
+ # Install the library
556
+ # -------------------
426
557
  include(GNUInstallDirs)
427
558
 
428
- install(TARGETS ${PROJECT_NAME}
559
+ install(
560
+ TARGETS ${PROJECT_NAME}
429
561
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
430
562
  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
431
563
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
432
564
  )
565
+
433
566
  install(FILES include/xlsxwriter.h DESTINATION include)
434
- install(DIRECTORY include/xlsxwriter
567
+
568
+ install(
569
+ DIRECTORY include/xlsxwriter
435
570
  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
436
- FILES_MATCHING PATTERN "*.h"
571
+ FILES_MATCHING
572
+ PATTERN "*.h"
573
+ )
574
+ install(
575
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/xlsxwriter.pc
576
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
437
577
  )
438
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/xlsxwriter.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)