Skip to content

Commit

Permalink
Fixed vcpkg related problems on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBeckebans committed Jul 24, 2024
1 parent 7929857 commit d2ec10a
Show file tree
Hide file tree
Showing 18 changed files with 216 additions and 396 deletions.
2 changes: 1 addition & 1 deletion cmake-vs2019-win64.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ REM cd ..
del /s /q build
mkdir build
cd build
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_PREFIX_PATH="C:\Qt\5.15.2\msvc2019_64" ..
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_MODULE_PATH="cmake/packages" -DCMAKE_PREFIX_PATH="C:\Qt\5.15.2\msvc2019_64" ..
pause
4 changes: 3 additions & 1 deletion vcpkg-overlay-ports/freeimage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ target_link_libraries(FreeImage ${ZLIB_LIBRARIES}
WebP::webp WebP::webpdemux WebP::libwebpmux WebP::webpdecoder
${JXR_LIBRARIES}
${LibRaw_LIBRARIES}
OpenEXR::IlmImf)
OpenEXR::OpenEXR
Imath::Imath)

target_compile_definitions(FreeImage PRIVATE ${PNG_DEFINITIONS})

Expand Down Expand Up @@ -160,6 +161,7 @@ find_dependency(WebP CONFIG)
find_dependency(JXR)
find_dependency(LibRaw)
find_dependency(OpenEXR)
find_dependency(Imath)
include(\"\${CMAKE_CURRENT_LIST_DIR}/freeimage-targets.cmake\")
")

Expand Down
2 changes: 1 addition & 1 deletion vcpkg-overlay-ports/freeimage/FreeImageConfig-static.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef FREEIMAGE_CONFIG_H
#define FREEIMAGE_CONFIG_H

#define FREEIMAGE_LIB
#define FREEIMAGE_LIB

#endif
43 changes: 24 additions & 19 deletions vcpkg-overlay-ports/freeimage/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,39 @@ vcpkg_from_sourceforge(
fix-function-overload.patch
use-typedef-as-already-declared.patch
use-functions-to-override-libtiff-warning-error-handlers.patch
remove_auto_ptr.patch
rawlib-build-fix.patch
)

file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
file(COPY ${CMAKE_CURRENT_LIST_DIR}/FreeImageConfig-static.h DESTINATION ${SOURCE_PATH})
file(COPY ${CMAKE_CURRENT_LIST_DIR}/FreeImageConfig-dynamic.h DESTINATION ${SOURCE_PATH})
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt"
"${CMAKE_CURRENT_LIST_DIR}/FreeImageConfig-static.h"
"${CMAKE_CURRENT_LIST_DIR}/FreeImageConfig-dynamic.h"
DESTINATION "${SOURCE_PATH}"
)

# This is not strictly necessary, but to make sure
# that no "internal" libraries are used we remove them
file(REMOVE_RECURSE ${SOURCE_PATH}/Source/LibJPEG)
file(REMOVE_RECURSE ${SOURCE_PATH}/Source/LibPNG)
file(REMOVE_RECURSE ${SOURCE_PATH}/Source/LibTIFF4)
file(REMOVE_RECURSE ${SOURCE_PATH}/Source/ZLib)
file(REMOVE_RECURSE ${SOURCE_PATH}/Source/LibOpenJPEG)
file(REMOVE_RECURSE ${SOURCE_PATH}/Source/LibJXR)
file(REMOVE_RECURSE ${SOURCE_PATH}/Source/LibWebP)
file(REMOVE_RECURSE ${SOURCE_PATH}/Source/LibRawLite)
file(REMOVE_RECURSE ${SOURCE_PATH}/Source/OpenEXR)
file(REMOVE_RECURSE
"${SOURCE_PATH}/Source/LibJPEG"
"${SOURCE_PATH}/Source/LibPNG"
"${SOURCE_PATH}/Source/LibTIFF4"
"${SOURCE_PATH}/Source/ZLib"
"${SOURCE_PATH}/Source/LibOpenJPEG"
"${SOURCE_PATH}/Source/LibJXR"
"${SOURCE_PATH}/Source/LibWebP"
"${SOURCE_PATH}/Source/LibRawLite"
"${SOURCE_PATH}/Source/OpenEXR"
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS_DEBUG
-DINSTALL_HEADERS=OFF
-DINSTALL_HEADERS=OFF
)

vcpkg_install_cmake()
vcpkg_fixup_cmake_targets()
vcpkg_cmake_install()
vcpkg_cmake_config_fixup()

vcpkg_copy_pdbs()

file(INSTALL ${SOURCE_PATH}/license-fi.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/license-fi.txt")
31 changes: 31 additions & 0 deletions vcpkg-overlay-ports/freeimage/rawlib-build-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/Source/FreeImage/PluginRAW.cpp b/Source/FreeImage/PluginRAW.cpp
index c7f8758a..a57fd5f1 100644
--- a/Source/FreeImage/PluginRAW.cpp
+++ b/Source/FreeImage/PluginRAW.cpp
@@ -46,6 +46,14 @@ private:
long _eof;
INT64 _fsize;

+ // Minimal change to make version 3.18.0 of FreeImage compile with
+ // LibRaw 0.20 and later versions.
+ // Once the port of FreeImage has been updated to a version greater
+ // than 3.18.0, this patch should be removed as it will not be needed.
+#if LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0, 20)
+ LibRaw_abstract_datastream * const substream = nullptr;
+#endif
+
public:
LibRaw_freeimage_datastream(FreeImageIO *io, fi_handle handle) : _io(io), _handle(handle) {
long start_pos = io->tell_proc(handle);
@@ -694,7 +702,11 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
// --------------------------------------------

// (-s [0..N-1]) Select one raw image from input file
+#if LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0, 20)
+ RawProcessor->imgdata.rawparams.shot_select = 0;
+#else
RawProcessor->imgdata.params.shot_select = 0;
+#endif
// (-w) Use camera white balance, if possible (otherwise, fallback to auto_wb)
RawProcessor->imgdata.params.use_camera_wb = 1;
// (-M) Use any color matrix from the camera metadata. This option only affects Olympus, Leaf, and Phase One cameras.
35 changes: 35 additions & 0 deletions vcpkg-overlay-ports/freeimage/remove_auto_ptr.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
diff --git a/Source/FreeImage/MultiPage.cpp b/Source/FreeImage/MultiPage.cpp
index 4f2605188..8af384aff 100644
--- a/Source/FreeImage/MultiPage.cpp
+++ b/Source/FreeImage/MultiPage.cpp
@@ -31,6 +31,8 @@
#pragma warning (disable : 4786) // identifier was truncated to 'number' characters
#endif

+#include <memory>
+
#include "CacheFile.h"
#include "FreeImageIO.h"
#include "Plugin.h"
@@ -271,8 +273,8 @@ FreeImage_OpenMultiBitmap(FREE_IMAGE_FORMAT fif, const char *filename, BOOL crea
}
}

- std::auto_ptr<FIMULTIBITMAP> bitmap (new FIMULTIBITMAP);
- std::auto_ptr<MULTIBITMAPHEADER> header (new MULTIBITMAPHEADER);
+ std::unique_ptr<FIMULTIBITMAP> bitmap (new FIMULTIBITMAP);
+ std::unique_ptr<MULTIBITMAPHEADER> header (new MULTIBITMAPHEADER);
header->m_filename = filename;
// io is default
header->node = node;
@@ -337,8 +339,8 @@ FreeImage_OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_h
PluginNode *node = list->FindNodeFromFIF(fif);

if (node) {
- std::auto_ptr<FIMULTIBITMAP> bitmap (new FIMULTIBITMAP);
- std::auto_ptr<MULTIBITMAPHEADER> header (new MULTIBITMAPHEADER);
+ std::unique_ptr<FIMULTIBITMAP> bitmap (new FIMULTIBITMAP);
+ std::unique_ptr<MULTIBITMAPHEADER> header (new MULTIBITMAPHEADER);
header->io = *io;
header->node = node;
header->fif = fif;
32 changes: 30 additions & 2 deletions vcpkg-overlay-ports/freeimage/use-external-openexr.patch
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,38 @@ index b286430..82b3b72 100644
+#include <OpenEXR/ImfRgba.h>
+#include <OpenEXR/ImfArray.h>
+#include <OpenEXR/ImfPreviewImage.h>
+#include <OpenEXR/half.h>
+#include <Imath/half.h>


// ==========================================================
@@ -66,11 +66,11 @@ public:
return ((unsigned)n != _io->read_proc(c, 1, n, _handle));
}

- virtual Imath::Int64 tellg() {
+ virtual uint64_t tellg() {
return _io->tell_proc(_handle);
}

- virtual void seekg(Imath::Int64 pos) {
+ virtual void seekg(uint64_t pos) {
_io->seek_proc(_handle, (unsigned)pos, SEEK_SET);
}

@@ -100,11 +100,11 @@ public:
}
}

- virtual Imath::Int64 tellp() {
+ virtual uint64_t tellp() {
return _io->tell_proc(_handle);
}

- virtual void seekp(Imath::Int64 pos) {
+ virtual void seekp(uint64_t pos) {
_io->seek_proc(_handle, (unsigned)pos, SEEK_SET);
}
};
diff --git a/Source/FreeImage/PluginTIFF.cpp b/Source/FreeImage/PluginTIFF.cpp
index 562fdd7..ce12649 100644
--- a/Source/FreeImage/PluginTIFF.cpp
Expand All @@ -38,7 +66,7 @@ index 562fdd7..ce12649 100644
#include <tiffio.h>
#include "../Metadata/FreeImageTag.h"
-#include "../OpenEXR/Half/half.h"
+#include <OpenEXR/half.h>
+#include <Imath/half.h>

#include "FreeImageIO.h"
#include "PSDParser.h"
12 changes: 11 additions & 1 deletion vcpkg-overlay-ports/freeimage/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"name": "freeimage",
"version": "3.18.0",
"port-version": 22,
"port-version": 25,
"description": "Support library for graphics image formats",
"homepage": "https://sourceforge.net/projects/freeimage/",
"license": "GPL-2.0-only OR GPL-3.0-only OR FreeImage",
"dependencies": [
"imath",
"jxrlib",
"libjpeg-turbo",
"libpng",
Expand All @@ -16,6 +18,14 @@
"openexr",
"openjpeg",
"tiff",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
},
"zlib"
]
}
22 changes: 22 additions & 0 deletions vcpkg-overlay-ports/openexr/0001-hide-symbols-by-default.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1dcf0f42..1aa72b68 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,16 @@ if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()

+if(POLICY CMP0063)
+ # ensure that CMAKE_CXX_VISIBILITY_PRESET and CMAKE_VISIBILITY_INLINES_HIDDEN also apply
+ # for static libraries
+ # https://cmake.org/cmake/help/latest/policy/CMP0063.html
+ cmake_policy(SET CMP0063 NEW)
+endif()
+
+set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+set(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE)
+
#######################################
# Create project and include cmake
# configuration files

87 changes: 0 additions & 87 deletions vcpkg-overlay-ports/openexr/0001-remove_find_package_macro.patch

This file was deleted.

Loading

0 comments on commit d2ec10a

Please sign in to comment.