Skip to content

Commit

Permalink
[minizip,xlsxio,fmilib,collada-dom] Minizip fixes, xlsxio update (#30930
Browse files Browse the repository at this point in the history
)

* [minizip] Misc fixes

* [minizip] CMake config is unofficial

* [xlsxio] Update, fixes

* [collada-dom] Fix minizip

* [fmilib] Fix minizip

* [xlsxio] Fix vcpkg quirk
  • Loading branch information
dg0yt authored Apr 26, 2023
1 parent 463a9b7 commit 326968a
Show file tree
Hide file tree
Showing 23 changed files with 267 additions and 268 deletions.
27 changes: 14 additions & 13 deletions ports/collada-dom/use-vcpkg-minizip.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
diff --git a/dom/src/modules/LIBXMLPlugin/daeLIBXMLPlugin.cpp b/dom/src/modules/LIBXMLPlugin/daeLIBXMLPlugin.cpp
index 4536275..77651f9 100644
--- a/dom/src/modules/LIBXMLPlugin/daeLIBXMLPlugin.cpp
+++ b/dom/src/modules/LIBXMLPlugin/daeLIBXMLPlugin.cpp
@@ -32,7 +32,7 @@
#include <iomanip>
using namespace std;

-#include <zip.h> // for saving compressed files
+#include <minizip/zip.h> // for saving compressed files
#ifdef _WIN32
#include <iowin32.h>
#else
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f6c2bb6..3351ab0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -222,7 +222,8 @@ else()
endif()
endif()

-pkg_check_modules(minizip minizip)
+find_package(minizip NAMES unofficial-minizip REQUIRED)
+add_library(minizip ALIAS unofficial::minizip::minizip)
if(minizip_FOUND)
set(MINIZIP_INCLUDE_DIR ${minizip_INCLUDE_DIRS})
else()
2 changes: 1 addition & 1 deletion ports/collada-dom/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "collada-dom",
"version": "2.5.0",
"port-version": 8,
"port-version": 9,
"description": "The COLLADA Document Object Model (DOM) is an application programming interface (API) that provides a C++ object representation of a COLLADA XML instance document.",
"homepage": "https://github.com/rdiankov/collada-dom",
"license": null,
Expand Down
16 changes: 10 additions & 6 deletions ports/fmilib/devendor-sublibs.diff
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b01aba5..583e15b 100644
index 690ee5f..2816987 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -230,7 +230,7 @@ configure_file (
"${FMILibrary_BINARY_DIR}/fmilib_config.h"
)

-set(FMILIB_SHARED_SUBLIBS ${FMIXML_LIBRARIES} ${FMIZIP_LIBRARIES} ${FMICAPI_LIBRARIES} expat minizip zlib c99snprintf)
+set(FMILIB_SHARED_SUBLIBS ${FMIXML_LIBRARIES} ${FMIZIP_LIBRARIES} ${FMICAPI_LIBRARIES} c99snprintf)
+set(FMILIB_SHARED_SUBLIBS ${FMIXML_LIBRARIES} ${FMIZIP_LIBRARIES} ${FMICAPI_LIBRARIES} minizip c99snprintf)
set(FMILIB_SUBLIBS ${FMIIMPORT_LIBRARIES} ${JMUTIL_LIBRARIES} ${FMILIB_SHARED_SUBLIBS})
set(FMILIB_SHARED_SRC ${FMIIMPORTSOURCE} ${JMUTILSOURCE} ${FMIIMPORTHEADERS})

Expand Down Expand Up @@ -35,16 +35,20 @@ index ddd3c1f..3bafac3 100644
include_directories("${EXPAT_INCLUDE_DIRS}" "${FMILIB_THIRDPARTYLIBS}/FMI/" "${FMIXMLGENDIR}/FMI1" "${FMIXMLGENDIR}/FMI2")

diff --git a/Config.cmake/fmizip.cmake b/Config.cmake/fmizip.cmake
index 091fc4d..c53555f 100644
index c046d47..50e82b3 100644
--- a/Config.cmake/fmizip.cmake
+++ b/Config.cmake/fmizip.cmake
@@ -20,7 +20,8 @@ if(NOT FMIZIPDIR)
@@ -20,7 +20,12 @@ if(NOT FMIZIPDIR)

set(FMIZIP_LIBRARIES fmizip)

- add_subdirectory(Config.cmake/Minizip)
+ find_package(minizip CONFIG REQUIRED)
+ add_library(minizip ALIAS minizip::minizip)
+ add_library(minizip OBJECT
+ "${FMILIB_THIRDPARTYLIBS}/Minizip/minizip/miniunz.c"
+ "${FMILIB_THIRDPARTYLIBS}/Minizip/minizip/minizip.c"
+ )
+ find_package(unofficial-minizip CONFIG REQUIRED)
+ target_link_libraries(minizip PRIVATE unofficial::minizip::minizip)

include_directories("${FMIZIPDIR}/include" "${FMILIB_THIRDPARTYLIBS}/Minizip/minizip" "${FMILIB_THIRDPARTYLIBS}/FMI" "${FMILIB_THIRDPARTYLIBS}/Zlib/zlib-1.2.6" "${FMILibrary_BINARY_DIR}/zlib")

52 changes: 52 additions & 0 deletions ports/fmilib/minizip.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
diff --git a/ThirdParty/Minizip/minizip/miniunz.c b/ThirdParty/Minizip/minizip/miniunz.c
index 1931161..d7a8be1 100644
--- a/ThirdParty/Minizip/minizip/miniunz.c
+++ b/ThirdParty/Minizip/minizip/miniunz.c
@@ -45,6 +45,7 @@
#include <time.h>
#include <errno.h>
#include <fcntl.h>
+#include <sys/stat.h>
#include <stdarg.h>

#ifdef _WIN32
@@ -107,7 +108,7 @@ void change_file_date(filename,dosdate,tmu_date)
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
CloseHandle(hFile);
#else
-#ifdef unix || __APPLE__
+#if defined(unix) || defined(__APPLE__)
struct utimbuf ut;
struct tm newdate;
newdate.tm_sec = tmu_date.tm_sec;
@@ -137,7 +138,7 @@ int mymkdir(dirname)
int ret=0;
#ifdef _WIN32
ret = _mkdir(dirname);
-#elif unix
+#elif 1
ret = mkdir (dirname,0775);
#elif __APPLE__
ret = mkdir (dirname,0775);
diff --git a/ThirdParty/Minizip/minizip/minizip.c b/ThirdParty/Minizip/minizip/minizip.c
index e22f80d..548b6ca 100644
--- a/ThirdParty/Minizip/minizip/minizip.c
+++ b/ThirdParty/Minizip/minizip/minizip.c
@@ -101,7 +101,7 @@ uLong filetime(f, tmzip, dt)
return ret;
}
#else
-#ifdef unix || __APPLE__
+#if defined(unix) || defined(__APPLE__)
uLong filetime(f, tmzip, dt)
char *f; /* name of file to get info on */
tm_zip *tmzip; /* return value: access, modific. and creation times */
@@ -453,7 +453,7 @@ int minizip(argc,argv)
}
if( lastslash != NULL )
{
- savefilenameinzip = lastslash+1; // base filename follows last slash.
+ savefilenameinzip = lastslash+1;
}
}

7 changes: 5 additions & 2 deletions ports/fmilib/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ vcpkg_from_github(
HEAD_REF master
PATCHES
devendor-sublibs.diff
minizip.patch
fix-mergestaticlibs.diff
unofficial-export.diff
)

file(REMOVE RECURSE
file(GLOB vendored_minizip "${SOURCE_PATH}/ThirdParty/Minizip/minizip/*")
list(FILTER vendored_minizip EXCLUDE REGEX "/minizip.[ch]\$|/miniunz.[ch]\$")
file(REMOVE_RECURSE
${vendored_minizip}
"${SOURCE_PATH}/ThirdParty/Expat"
"${SOURCE_PATH}/ThirdParty/Minizip"
"${SOURCE_PATH}/ThirdParty/Zlib"
)

Expand Down
2 changes: 1 addition & 1 deletion ports/fmilib/unofficial-fmilib-config.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include(CMakeFindDependencyMacro)
find_dependency(expat CONFIG)
find_dependency(minizip CONFIG)
find_dependency(unofficial-minizip CONFIG)
include("${CMAKE_CURRENT_LIST_DIR}/unofficial-fmilib-targets.cmake")
2 changes: 1 addition & 1 deletion ports/fmilib/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fmilib",
"version": "2.4.1",
"port-version": 1,
"port-version": 2,
"description": "FMI library is intended as a foundation for applications interfacing FMUs (Functional Mockup Units) that follow FMI Standard. This version of the library supports FMI 1.0 and FMI2.0.",
"homepage": "https://www.fmi-standard.org/",
"license": "BSD-3-Clause",
Expand Down
121 changes: 64 additions & 57 deletions ports/minizip/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,104 +1,111 @@
cmake_minimum_required(VERSION 3.8)
project(minizip VERSION 1.2.13 LANGUAGES C)
cmake_minimum_required(VERSION 3.25)
project(minizip LANGUAGES C)

if(MSVC)
add_compile_options(/W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS)
endif()

find_package(ZLIB REQUIRED)
set(MIN_SRC contrib/minizip)

include_directories(${MIN_SRC} ${ZLIB_INCLUDE_DIRS})

set(MINIZIP_LIBRARIES ZLIB::ZLIB)
if(ENABLE_BZIP2)
message(STATUS "Building with bzip2 support")
find_package(BZip2)

include_directories(${BZIP2_INCLUDE_DIR})
set(MINIZIP_LIBRARIES ${MINIZIP_LIBRARIES} ${BZIP2_LIBRARIES})
else()
message(STATUS "Building without bzip2 support")
endif()

set(SRC
${MIN_SRC}/ioapi.c
${MIN_SRC}/unzip.c
${MIN_SRC}/zip.c
${MIN_SRC}/mztools.c
ioapi.c
unzip.c
zip.c
mztools.c
)
if(WIN32)
list(APPEND SRC ${MIN_SRC}/iowin32.c)
endif()

set(HEADERS
${MIN_SRC}/crypt.h
${MIN_SRC}/ioapi.h
${MIN_SRC}/unzip.h
${MIN_SRC}/zip.h
${MIN_SRC}/mztools.h
crypt.h
ioapi.h
unzip.h
zip.h
mztools.h
)
if(WIN32)
list(APPEND HEADERS ${MIN_SRC}/iowin32.h)
list(APPEND SRC iowin32.c)
list(APPEND HEADERS iowin32.h)
endif()

add_library(minizip ${SRC})
target_include_directories(minizip PUBLIC $<INSTALL_INTERFACE:include/minizip>)

target_link_libraries(minizip PRIVATE ZLIB::ZLIB)
find_package(ZLIB REQUIRED)
target_compile_definitions(minizip PRIVATE -D_ZLIB_H)
target_link_libraries(minizip PUBLIC ZLIB::ZLIB)
set(MINIZIP_REQUIRES zlib)

if(ENABLE_BZIP2)
target_link_libraries(minizip PUBLIC ${BZIP2_LIBRARIES})
message(STATUS "Building with bzip2 support")
find_package(BZip2 REQUIRED)
target_compile_definitions(minizip PRIVATE -DHAVE_BZIP2=1)
target_link_libraries(minizip PUBLIC BZip2::BZip2)
list(APPEND MINIZIP_REQUIRES bzip2)
else()
message(STATUS "Building without bzip2 support")
endif()

if(ANDROID)
target_compile_definitions(minizip PRIVATE IOAPI_NO_64)
endif()

if(NOT DISABLE_INSTALL_TOOLS)
add_executable(minizip_bin ${MIN_SRC}/minizip.c)
add_executable(miniunz_bin ${MIN_SRC}/miniunz.c)
add_executable(minizip_bin minizip.c)
add_executable(miniunz_bin miniunz.c)

target_link_libraries(minizip_bin minizip ${MINIZIP_LIBRARIES})
target_link_libraries(miniunz_bin minizip ${MINIZIP_LIBRARIES})
target_link_libraries(minizip_bin minizip)
target_link_libraries(miniunz_bin minizip)

set_target_properties(minizip_bin PROPERTIES OUTPUT_NAME minizip)
set_target_properties(miniunz_bin PROPERTIES OUTPUT_NAME miniunz)

install (
TARGETS minizip_bin miniunz_bin
RUNTIME DESTINATION bin
)
endif()

install(
TARGETS minizip
EXPORT minizipTargets
EXPORT unofficial-minizipTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

include(CMakePackageConfigHelpers)
write_basic_package_version_file("${PROJECT_BINARY_DIR}/minizipConfigVersion.cmake"
COMPATIBILITY SameMajorVersion)
write_basic_package_version_file("${PROJECT_BINARY_DIR}/unofficial-minizipConfigVersion.cmake"
VERSION "${PACKAGE_VERSION}"
COMPATIBILITY SameMajorVersion
)

configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/minizipConfig.cmake.in
minizipConfig.cmake
INSTALL_DESTINATION share/minizip)
configure_package_config_file(unofficial-minizipConfig.cmake.in
unofficial-minizipConfig.cmake
INSTALL_DESTINATION share/unofficial-minizip
)

install(FILES
"${PROJECT_BINARY_DIR}/minizipConfig.cmake"
"${PROJECT_BINARY_DIR}/minizipConfigVersion.cmake"
DESTINATION share/minizip
"${PROJECT_BINARY_DIR}/unofficial-minizipConfig.cmake"
"${PROJECT_BINARY_DIR}/unofficial-minizipConfigVersion.cmake"
DESTINATION share/unofficial-minizip
)

install(EXPORT minizipTargets
NAMESPACE minizip::
DESTINATION share/minizip
install(EXPORT unofficial-minizipTargets
NAMESPACE unofficial::minizip::
DESTINATION share/unofficial-minizip
)

if(NOT DISABLE_INSTALL_TOOLS)
install (
TARGETS minizip_bin miniunz_bin
RUNTIME DESTINATION tools/minizip
)
endif()

if(NOT DISABLE_INSTALL_HEADERS)
install(FILES ${HEADERS} DESTINATION include/minizip)
endif()

list(JOIN MINIZIP_REQUIRES " " MINIZIP_REQUIRES)
set(exec_prefix "\${prefix}")
set(libdir "\${prefix}/lib")
set(includedir "\${prefix}/include")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/minizip.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/minizip.pc"
@ONLY
)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/minizip.pc"
DESTINATION lib/pkgconfig
)

16 changes: 7 additions & 9 deletions ports/minizip/minizipConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#@PACKAGE_INIT@
message(WARNING "'find_package(minizip CONFIG)' is deprecated. Please use 'find_package(unofficial-minizip CONFIG)' instead.")

include(CMakeFindDependencyMacro)

find_dependency(ZLIB)

if (@ENABLE_BZIP2@)
find_dependency(BZip2)
find_dependency(unofficial-minizip ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} CONFIG)
if(NOT TARGET unofficial::minizip::minizip)
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
elseif(NOT TARGET minizip::minizip)
add_library(minizip::minizip INTERFACE IMPORTED)
set_target_properties(minizip::minizip PROPERTIES INTERFACE_LINK_LIBRARIES unofficial::minizip::minizip)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
check_required_components("@PROJECT_NAME@")
11 changes: 11 additions & 0 deletions ports/minizip/pkgconfig.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
diff --git a/contrib/minizip/minizip.pc.in b/contrib/minizip/minizip.pc.in
index 69b5b7f..9e43084 100644
--- a/contrib/minizip/minizip.pc.in
+++ b/contrib/minizip/minizip.pc.in
@@ -8,5 +8,5 @@ Description: Minizip zip file manipulation library
Requires:
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lminizip
-Libs.private: -lz
+Requires.private: @MINIZIP_REQUIRES@
Cflags: -I${includedir}
Loading

0 comments on commit 326968a

Please sign in to comment.