Skip to content

Commit

Permalink
Merge pull request #2291 from meganz/hotfix/mcmd-w64-support
Browse files Browse the repository at this point in the history
SDK-1251. Support 64 bits MEGAcmd build (hotfix for develop)
  • Loading branch information
polmr authored Oct 23, 2020
2 parents 91a8bfd + 4a30e6a commit 4d23b33
Show file tree
Hide file tree
Showing 90 changed files with 6,078 additions and 1 deletion.
15 changes: 14 additions & 1 deletion bindings/qt/sdk.pri
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ debug:DEBUG_SUFFIX = "d"
else:DEBUG_SUFFIX = ""
debug:DASH_DEBUG_SUFFIX = "-d"
else:DASH_DEBUG_SUFFIX = ""
debug:UNDERSCORE_DEBUG_SUFFIX = "_d"
else:UNDERSCORE_DEBUG_SUFFIX = ""

debug:win32:DEBUG_SUFFIX_WO = "d"
else:DEBUG_SUFFIX_WO = ""

Expand Down Expand Up @@ -499,7 +502,17 @@ else {
LIBS += $$MEGASDK_BASE_PATH/bindings/qt/3rdparty/libs/libfreeimage.a
}
else {
LIBS += -lfreeimage
vcpkg:LIBS += -lfreeimage$$DEBUG_SUFFIX
!vcpkg:LIBS += -lfreeimage
}

vcpkg {
LIBS += -ljpeg$$DEBUG_SUFFIX -ltiff$$DEBUG_SUFFIX -llibpng16$$DEBUG_SUFFIX \
-lIlmImf-2_3$$UNDERSCORE_DEBUG_SUFFIX -lIex-2_3$$UNDERSCORE_DEBUG_SUFFIX -lIlmThread-2_3$$UNDERSCORE_DEBUG_SUFFIX \
-lIexMath-2_3$$UNDERSCORE_DEBUG_SUFFIX -lIlmImfUtil-2_3$$UNDERSCORE_DEBUG_SUFFIX -lImath-2_3$$UNDERSCORE_DEBUG_SUFFIX \
-llibwebpmux$$DEBUG_SUFFIX -lwebpdecoder$$DEBUG_SUFFIX -lwebpdemux$$DEBUG_SUFFIX -lwebp$$DEBUG_SUFFIX \
-ljpegxr$$DEBUG_SUFFIX -ljxrglue$$DEBUG_SUFFIX -lHalf-2_3$$UNDERSCORE_DEBUG_SUFFIX \
-llzma$$DEBUG_SUFFIX -ljasper$$DEBUG_SUFFIX -lraw$$DEBUG_SUFFIX -lopenjp2
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions contrib/cmake/preferred-ports.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ x264/157-3034848280-7
zlib/1.2.11-5
opengl/0.0-5
freeglut/3.0.0-9
freeimage/3.18.0-8
libpng/1.6.37-6
tiff/4.0.10-8
libwebp/1.0.2-8
giflib/5.1.4-3
jxrlib/2019.10.9
openexr/2.3.0-5
sdl1/1.2.15-12
154 changes: 154 additions & 0 deletions contrib/cmake/vcpkg_extra_ports/freeimage/3.18.0-8/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
cmake_minimum_required(VERSION 3.4)

include(GNUInstallDirs)

project(FreeImage C CXX)

if(MSVC)
add_definitions("-D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_CXX_FLAGS "/wd4828 ${CMAKE_CXX_FLAGS}")
endif()

if(BUILD_SHARED_LIBS)
add_definitions("-DOPENEXR_DLL")
endif()

find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
find_package(JPEG REQUIRED)
find_package(TIFF REQUIRED)
find_package(OpenJPEG REQUIRED)
find_package(WebP REQUIRED)
find_package(JXR REQUIRED)
find_package(LibRaw REQUIRED)
find_package(OpenEXR REQUIRED)

option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(INSTALL_HEADERS "Install the development headers" ON)

set(REAL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Source)

# Add a debug postfix
set(CMAKE_DEBUG_POSTFIX "d")

# List the public header files
set(PUBLIC_HEADERS ${REAL_SOURCE_DIR}/FreeImage.h)

# List the private header files
set(ROOT_PRIVATE_HEADERS ${REAL_SOURCE_DIR}/CacheFile.h
${REAL_SOURCE_DIR}/FreeImageIO.h
${REAL_SOURCE_DIR}/MapIntrospector.h
${REAL_SOURCE_DIR}/Plugin.h
${REAL_SOURCE_DIR}/Quantizers.h
${REAL_SOURCE_DIR}/ToneMapping.h
${REAL_SOURCE_DIR}/Utilities.h)

file(GLOB FREEIMAGE_PRIVATE_HEADERS ${REAL_SOURCE_DIR}/FreeImage/*.h)
file(GLOB FREEIMAGE_TOOLKIT_PRIVATE_HEADERS ${REAL_SOURCE_DIR}/FreeImageToolkit/*.h)
file(GLOB METADATA_PRIVATE_HEADERS ${REAL_SOURCE_DIR}/Metadata/*.h)

set(PRIVATE_HEADERS ${ROOT_PRIVATE_HEADERS}
${FREEIMAGE_PRIVATE_HEADERS}
${FREEIMAGE_TOOLKIT_PRIVATE_HEADERS}
${METADATA_PRIVATE_HEADERS})

# List the source files
file(GLOB DEPRECATION_SRCS ${REAL_SOURCE_DIR}/DeprecationManager/*.cpp)
file(GLOB FREEIMAGE_TOOLKIT_SRCS ${REAL_SOURCE_DIR}/FreeImageToolkit/*.cpp)
file(GLOB FREEIMAGE_SRCS ${REAL_SOURCE_DIR}/FreeImage/*.cpp)
file(GLOB METADATA_SRCS ${REAL_SOURCE_DIR}/Metadata/*.cpp)

# The G3 plugin is disabled because it require the private copy of tiff
list(REMOVE_ITEM FREEIMAGE_SRCS ${REAL_SOURCE_DIR}/FreeImage/PluginG3.cpp)

# The JPEGTransform plugin is disable because it requires a private copy of jpeg
list(REMOVE_ITEM FREEIMAGE_TOOLKIT_SRCS ${REAL_SOURCE_DIR}/FreeImageToolkit/JPEGTransform.cpp)


set(SRCS ${DEPRECATION_SRCS}
${FREEIMAGE_SRCS}
${FREEIMAGE_TOOLKIT_SRCS}
${METADATA_SRCS}
)

# If FreeImage is used as a static library, FREEIMAGE_LIB
# needs to be defined (at the C preprocessor level) to correctly
# define (to nothing instead of _declspec(dllimport) ) the DLL_API macro.
# For this purpouse we include (depending on the BUILD_SHARED_LIBS )
# the appropriate FreeImageConfig.h .
if(BUILD_SHARED_LIBS)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/FreeImageConfig-dynamic.h ${CMAKE_CURRENT_BINARY_DIR}/FreeImageConfig.h)
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/FreeImageConfig-static.h ${CMAKE_CURRENT_BINARY_DIR}/FreeImageConfig.h)
endif()
list(APPEND PUBLIC_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/FreeImageConfig.h)

add_library(FreeImage ${SRCS} ${PRIVATE_HEADERS} ${PUBLIC_HEADERS})

if(BUILD_SHARED_LIBS)
target_compile_definitions(FreeImage PRIVATE -DFREEIMAGE_EXPORTS)
else()
target_compile_definitions(FreeImage PRIVATE -DFREEIMAGE_LIB)
endif()

target_include_directories(FreeImage PRIVATE ${REAL_SOURCE_DIR}
${ZLIB_INCLUDE_DIRS}
${JPEG_INCLUDE_DIRS}
${TIFF_INCLUDE_DIRS}
${PNG_INCLUDE_DIRS}
${OPENJPEG_INCLUDE_DIRS}
${WEBP_INCLUDE_DIRS}
${JXR_INCLUDE_DIRS}
${LibRaw_INCLUDE_DIRS}
${OpenEXR_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR})


target_link_libraries(FreeImage ${ZLIB_LIBRARIES}
${JPEG_LIBRARIES}
${TIFF_LIBRARIES}
${PNG_LIBRARIES}
${OPENJPEG_LIBRARIES}
${WEBP_LIBRARIES}
${JXR_LIBRARIES}
${LibRaw_LIBRARIES}
${OpenEXR_LIBRARIES})

target_compile_definitions(FreeImage PRIVATE ${PNG_DEFINITIONS})

# FreeImagePlus
file(GLOB FREEIMAGEPLUS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Wrapper/FreeImagePlus/src/*.cpp)
add_library(FreeImagePlus
${FREEIMAGEPLUS_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/Wrapper/FreeImagePlus/FreeImagePlus.h
${CMAKE_CURRENT_SOURCE_DIR}/Wrapper/FreeImagePlus/FreeImagePlus.rc)

if(BUILD_SHARED_LIBS)
target_compile_definitions(FreeImagePlus PRIVATE -DFIP_EXPORTS)
else()
target_compile_definitions(FreeImagePlus PRIVATE -DFREEIMAGE_LIB)
endif()

target_include_directories(FreeImagePlus PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Wrapper/FreeImagePlus
${CMAKE_CURRENT_BINARY_DIR}
${REAL_SOURCE_DIR})

target_link_libraries(FreeImagePlus PUBLIC FreeImage)

list(APPEND PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Wrapper/FreeImagePlus/FreeImagePlus.h)

install(TARGETS FreeImage
COMPONENT runtime
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib)

install(TARGETS FreeImagePlus
COMPONENT runtime-cpp
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib)

if(INSTALL_HEADERS)
install(FILES ${PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()
5 changes: 5 additions & 0 deletions contrib/cmake/vcpkg_extra_ports/freeimage/3.18.0-8/CONTROL
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Source: freeimage
Version: 3.18.0-8
Build-Depends: zlib, libpng, libjpeg-turbo, tiff, openjpeg, libwebp[all] (!uwp), libraw, jxrlib, openexr
Homepage: https://sourceforge.net/projects/freeimage/
Description: Support library for graphics image formats
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef FREEIMAGE_CONFIG_H
#define FREEIMAGE_CONFIG_H

#undef FREEIMAGE_LIB

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef FREEIMAGE_CONFIG_H
#define FREEIMAGE_CONFIG_H

#define FREEIMAGE_LIB

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
diff --git a/Source/FreeImage.h b/Source/FreeImage.h
index e2d1c5a..cc66b7d 100644
--- a/Source/FreeImage.h
+++ b/Source/FreeImage.h
@@ -410,7 +410,11 @@ FI_ENUM(FREE_IMAGE_FORMAT) {
FIF_DDS = 24,
FIF_GIF = 25,
FIF_HDR = 26,
- FIF_FAXG3 = 27,
+/* vcpkg: The G3 fax format plugin is deliberately disabled in our build of
+ FreeImage, since it requires usage of the vendored copy of libtiff. */
+#if 0
+ FIF_FAXG3 = 27,
+#endif
FIF_SGI = 28,
FIF_EXR = 29,
FIF_J2K = 30,
@@ -476,6 +480,9 @@ FI_ENUM(FREE_IMAGE_DITHER) {
/** Lossless JPEG transformations
Constants used in FreeImage_JPEGTransform
*/
+/* vcpkg: The JPEGTransform functions are deliberately disabled in our build
+ of FreeImage, since they require usage of the vendored copy of libjpeg. */
+#if 0
FI_ENUM(FREE_IMAGE_JPEG_OPERATION) {
FIJPEG_OP_NONE = 0, //! no transformation
FIJPEG_OP_FLIP_H = 1, //! horizontal flip
@@ -486,6 +493,7 @@ FI_ENUM(FREE_IMAGE_JPEG_OPERATION) {
FIJPEG_OP_ROTATE_180 = 6, //! 180-degree rotation
FIJPEG_OP_ROTATE_270 = 7 //! 270-degree clockwise (or 90 ccw)
};
+#endif

/** Tone mapping operators.
Constants used in FreeImage_ToneMapping.
@@ -1077,6 +1085,9 @@ DLL_API const char* DLL_CALLCONV FreeImage_TagToString(FREE_IMAGE_MDMODEL model,
// JPEG lossless transformation routines
// --------------------------------------------------------------------------

+/* vcpkg: The JPEGTransform functions are deliberately disabled in our build
+ of FreeImage, since they require usage of the vendored copy of libjpeg. */
+#if 0
DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransform(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(TRUE));
DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(TRUE));
DLL_API BOOL DLL_CALLCONV FreeImage_JPEGCrop(const char *src_file, const char *dst_file, int left, int top, int right, int bottom);
@@ -1085,7 +1096,7 @@ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformFromHandle(FreeImageIO* src_io,
DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombined(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE));
DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE));
DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedFromMemory(FIMEMORY* src_stream, FIMEMORY* dst_stream, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE));
-
+#endif

// --------------------------------------------------------------------------
// Image manipulation toolkit
diff --git a/Source/FreeImage/Plugin.cpp b/Source/FreeImage/Plugin.cpp
index 57ebffd..a93440f 100644
--- a/Source/FreeImage/Plugin.cpp
+++ b/Source/FreeImage/Plugin.cpp
@@ -263,7 +263,11 @@ FreeImage_Initialise(BOOL load_local_plugins_only) {
s_plugins->AddNode(InitDDS);
s_plugins->AddNode(InitGIF);
s_plugins->AddNode(InitHDR);
- s_plugins->AddNode(InitG3);
+/* vcpkg: The G3 fax format plugin is deliberately disabled in our build of FreeImage
++ since it requires usage of the vendored copy of libtiff. */
+#if 0
+ s_plugins->AddNode(InitG3);
+#endif
s_plugins->AddNode(InitSGI);
s_plugins->AddNode(InitEXR);
s_plugins->AddNode(InitJ2K);
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/Source/FreeImage/PluginJPEG.cpp b/Source/FreeImage/PluginJPEG.cpp
index 8db177d..efa2c4e 100644
--- a/Source/FreeImage/PluginJPEG.cpp
+++ b/Source/FreeImage/PluginJPEG.cpp
@@ -503,7 +503,7 @@ marker_is_icc(jpeg_saved_marker_ptr marker) {
return FALSE. You might want to issue an error message instead.
*/
static BOOL
-jpeg_read_icc_profile(j_decompress_ptr cinfo, JOCTET **icc_data_ptr, unsigned *icc_data_len) {
+jpeg_read_icc_profile_(j_decompress_ptr cinfo, JOCTET **icc_data_ptr, unsigned *icc_data_len) {
jpeg_saved_marker_ptr marker;
int num_markers = 0;
int seq_no;
@@ -745,7 +745,7 @@ read_markers(j_decompress_ptr cinfo, FIBITMAP *dib) {
BYTE *icc_profile = NULL;
unsigned icc_length = 0;

- if( jpeg_read_icc_profile(cinfo, &icc_profile, &icc_length) ) {
+ if( jpeg_read_icc_profile_(cinfo, &icc_profile, &icc_length) ) {
// copy ICC profile data
FreeImage_CreateICCProfile(dib, icc_profile, icc_length);
// clean up
@@ -785,7 +785,7 @@ jpeg_write_comment(j_compress_ptr cinfo, FIBITMAP *dib) {
Write JPEG_APP2 marker (ICC profile)
*/
static BOOL
-jpeg_write_icc_profile(j_compress_ptr cinfo, FIBITMAP *dib) {
+jpeg_write_icc_profile_(j_compress_ptr cinfo, FIBITMAP *dib) {
// marker identifying string "ICC_PROFILE" (null-terminated)
BYTE icc_signature[12] = { 0x49, 0x43, 0x43, 0x5F, 0x50, 0x52, 0x4F, 0x46, 0x49, 0x4C, 0x45, 0x00 };

@@ -1038,7 +1038,7 @@ write_markers(j_compress_ptr cinfo, FIBITMAP *dib) {
jpeg_write_comment(cinfo, dib);

// write ICC profile
- jpeg_write_icc_profile(cinfo, dib);
+ jpeg_write_icc_profile_(cinfo, dib);

// write IPTC profile
jpeg_write_iptc_profile(cinfo, dib);
Loading

0 comments on commit 4d23b33

Please sign in to comment.