diff --git a/ports/freeimage/CMakeLists.txt b/ports/freeimage/CMakeLists.txt index 1cafdd880b..f385f508c3 100644 --- a/ports/freeimage/CMakeLists.txt +++ b/ports/freeimage/CMakeLists.txt @@ -16,6 +16,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) 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) @@ -24,35 +25,6 @@ set(REAL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Source) # Add a debug postfix set(CMAKE_DEBUG_POSTFIX "d") - -# For now the internal copy of OpenEXR is used (as a private always static library) -file(GLOB OPENEXR_PRIVATE_HEADERS ${REAL_SOURCE_DIR}/OpenEXR/Half/*.h - ${REAL_SOURCE_DIR}/OpenEXR/Iex/*.h - ${REAL_SOURCE_DIR}/OpenEXR/IexMath/*.h - ${REAL_SOURCE_DIR}/OpenEXR/IlmImf/*.h - ${REAL_SOURCE_DIR}/OpenEXR/IlmThread/*.h - ${REAL_SOURCE_DIR}/OpenEXR/Imath/*.h - ${REAL_SOURCE_DIR}/OpenEXR/*.h) - -file(GLOB OPENEXR_SRCS ${REAL_SOURCE_DIR}/OpenEXR/Half/*.cpp - ${REAL_SOURCE_DIR}/OpenEXR/Iex/*.cpp - ${REAL_SOURCE_DIR}/OpenEXR/IexMath/*.cpp - ${REAL_SOURCE_DIR}/OpenEXR/IlmImf/*.cpp - ${REAL_SOURCE_DIR}/OpenEXR/IlmThread/*.cpp - ${REAL_SOURCE_DIR}/OpenEXR/Imath/*.cpp) - -add_library(FreeImage_Private_OpenEXR STATIC ${OPENEXR_PRIVATE_HEADERS} ${OPENEXR_SRCS}) - -set(FreeImage_Private_OpenEXR_INCLUDE_DIRS ${REAL_SOURCE_DIR}/OpenEXR - ${REAL_SOURCE_DIR}/OpenEXR/Half - ${REAL_SOURCE_DIR}/OpenEXR/Iex - ${REAL_SOURCE_DIR}/OpenEXR/IexMath - ${REAL_SOURCE_DIR}/OpenEXR/IlmImf - ${REAL_SOURCE_DIR}/OpenEXR/IlmThread - ${REAL_SOURCE_DIR}/OpenEXR/Imath) - -target_include_directories(FreeImage_Private_OpenEXR PRIVATE ${FreeImage_Private_OpenEXR_INCLUDE_DIRS} - ${ZLIB_INCLUDE_DIRS}) # List the public header files set(PUBLIC_HEADERS ${REAL_SOURCE_DIR}/FreeImage.h) @@ -124,7 +96,7 @@ target_include_directories(FreeImage PRIVATE ${REAL_SOURCE_DIR} ${WEBP_INCLUDE_DIRS} ${JXR_INCLUDE_DIRS} ${LibRaw_INCLUDE_DIRS} - ${FreeImage_Private_OpenEXR_INCLUDE_DIRS} + ${OpenEXR_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}) @@ -136,7 +108,7 @@ target_link_libraries(FreeImage ${ZLIB_LIBRARIES} ${WEBP_LIBRARIES} ${JXR_LIBRARIES} ${LibRaw_LIBRARIES} - FreeImage_Private_OpenEXR) + ${OpenEXR_LIBRARIES}) target_compile_definitions(FreeImage PRIVATE ${PNG_DEFINITIONS}) diff --git a/ports/freeimage/CONTROL b/ports/freeimage/CONTROL index 9eb197b101..2d9fa15238 100644 --- a/ports/freeimage/CONTROL +++ b/ports/freeimage/CONTROL @@ -1,4 +1,4 @@ Source: freeimage -Version: 3.17.0-1 -Build-Depends: zlib, libpng, libjpeg-turbo, tiff, openjpeg, libwebp, libraw, jxrlib +Version: 3.17.0-2 +Build-Depends: zlib, libpng, libjpeg-turbo, tiff, openjpeg, libwebp, libraw, jxrlib, openexr Description: Support library for graphics image formats diff --git a/ports/freeimage/FreeImageConfig-dynamic.h b/ports/freeimage/FreeImageConfig-dynamic.h index d87b65b4c5..41dcf57d97 100644 --- a/ports/freeimage/FreeImageConfig-dynamic.h +++ b/ports/freeimage/FreeImageConfig-dynamic.h @@ -1,5 +1,6 @@ #ifndef FREEIMAGE_CONFIG_H #define FREEIMAGE_CONFIG_H +#undef FREEIMAGE_LIB #endif diff --git a/ports/freeimage/cmake/FindOpenEXR.cmake b/ports/freeimage/cmake/FindOpenEXR.cmake new file mode 100644 index 0000000000..beca25145a --- /dev/null +++ b/ports/freeimage/cmake/FindOpenEXR.cmake @@ -0,0 +1,28 @@ +find_path(OpenEXR_INCLUDE_DIRS OpenEXR/OpenEXRConfig.h) + +file(STRINGS "${OpenEXR_INCLUDE_DIRS}/OpenEXR/OpenEXRConfig.h" OPENEXR_CONFIG_H) + +string(REGEX REPLACE "^.*define OPENEXR_VERSION_MAJOR ([0-9]+).*$" "\\1" OpenEXR_VERSION_MAJOR "${OPENEXR_CONFIG_H}") +string(REGEX REPLACE "^.*define OPENEXR_VERSION_MINOR ([0-9]+).*$" "\\1" OpenEXR_VERSION_MINOR "${OPENEXR_CONFIG_H}") +set(OpenEXR_LIB_SUFFIX "${OpenEXR_VERSION_MAJOR}_${OpenEXR_VERSION_MINOR}") + +find_library(OpenEXR_LIBRARY IlmImf-${OpenEXR_LIB_SUFFIX}) +find_library(OpenEXR_UTIL_LIBRARY IlmImfUtil-${OpenEXR_LIB_SUFFIX}) + +find_library(OpenEXR_HALF_LIBRARY Half) +find_library(OpenEXR_IEX_LIBRARY Iex-${OpenEXR_LIB_SUFFIX}) +find_library(OpenEXR_THREAD_LIBRARY IlmThread-${OpenEXR_LIB_SUFFIX}) +find_library(OpenEXR_IEXMATH_LIBRARY IexMath-${OpenEXR_LIB_SUFFIX}) +find_library(OpenEXR_MATH_LIBRARY Imath-${OpenEXR_LIB_SUFFIX}) + +set(OpenEXR_LIBRARIES + ${OpenEXR_LIBRARY} + ${OpenEXR_MATH_LIBRARY} + ${OpenEXR_IEXMATH_LIBRARY} + ${OpenEXR_UTIL_LIBRARY} + ${OpenEXR_HALF_LIBRARY} + ${OpenEXR_IEX_LIBRARY} + ${OpenEXR_THREAD_LIBRARY}) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR REQUIRED_VARS OpenEXR_LIBRARIES OpenEXR_INCLUDE_DIRS) diff --git a/ports/freeimage/portfile.cmake b/ports/freeimage/portfile.cmake index e48782bf08..db8d2537a5 100644 --- a/ports/freeimage/portfile.cmake +++ b/ports/freeimage/portfile.cmake @@ -18,7 +18,6 @@ file(COPY ${CMAKE_CURRENT_LIST_DIR}/cmake DESTINATION ${SOURCE_PATH}) # This is not strictly necessary, but to make sure # that no "internal" libraries are used by removing them -# Note that the only "internal" dependency used is OpenEXR file(REMOVE_RECURSE ${SOURCE_PATH}/Source/LibJPEG) file(REMOVE_RECURSE ${SOURCE_PATH}/Source/LibPNG) file(REMOVE_RECURSE ${SOURCE_PATH}/Source/LibTIFF4) @@ -27,6 +26,7 @@ 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) vcpkg_apply_patches( SOURCE_PATH ${SOURCE_PATH} @@ -38,6 +38,7 @@ vcpkg_apply_patches( "${CMAKE_CURRENT_LIST_DIR}/use-external-png-zlib.patch" "${CMAKE_CURRENT_LIST_DIR}/use-external-rawlib.patch" "${CMAKE_CURRENT_LIST_DIR}/use-external-webp.patch" + "${CMAKE_CURRENT_LIST_DIR}/use-external-openexr.patch" "${CMAKE_CURRENT_LIST_DIR}/use-freeimage-config-include.patch" ) diff --git a/ports/freeimage/use-external-openexr.patch b/ports/freeimage/use-external-openexr.patch new file mode 100644 index 0000000000..08915da726 --- /dev/null +++ b/ports/freeimage/use-external-openexr.patch @@ -0,0 +1,44 @@ +diff --git a/Source/FreeImage/PluginEXR.cpp b/Source/FreeImage/PluginEXR.cpp +index b286430..82b3b72 100644 +--- a/Source/FreeImage/PluginEXR.cpp ++++ b/Source/FreeImage/PluginEXR.cpp +@@ -28,16 +28,16 @@ + #pragma warning (disable : 4800) // ImfVersion.h - 'const int' : forcing value to bool 'true' or 'false' (performance warning) + #endif + +-#include "../OpenEXR/IlmImf/ImfIO.h" +-#include "../OpenEXR/Iex/Iex.h" +-#include "../OpenEXR/IlmImf/ImfOutputFile.h" +-#include "../OpenEXR/IlmImf/ImfInputFile.h" +-#include "../OpenEXR/IlmImf/ImfRgbaFile.h" +-#include "../OpenEXR/IlmImf/ImfChannelList.h" +-#include "../OpenEXR/IlmImf/ImfRgba.h" +-#include "../OpenEXR/IlmImf/ImfArray.h" +-#include "../OpenEXR/IlmImf/ImfPreviewImage.h" +-#include "../OpenEXR/Half/half.h" ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + + + // ========================================================== +diff --git a/Source/FreeImage/PluginTIFF.cpp b/Source/FreeImage/PluginTIFF.cpp +index 562fdd7..ce12649 100644 +--- a/Source/FreeImage/PluginTIFF.cpp ++++ b/Source/FreeImage/PluginTIFF.cpp +@@ -39,7 +39,7 @@ + #include "Utilities.h" + #include + #include "../Metadata/FreeImageTag.h" +-#include "../OpenEXR/Half/half.h" ++#include + + #include "FreeImageIO.h" + #include "PSDParser.h"