-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add freeimage 3.18.0 #2672
Add freeimage 3.18.0 #2672
Changes from all commits
68e30b4
506b6b9
b7ed643
c3a3837
c3e34fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(FreeImage C CXX) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
set(FREEIMAGE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder) | ||
|
||
find_package(ZLIB REQUIRED) | ||
find_package(PNG REQUIRED) | ||
find_package(JPEG REQUIRED) | ||
find_package(OpenJPEG REQUIRED) | ||
find_package(libwebp REQUIRED) | ||
find_package(JXR REQUIRED) | ||
find_package(libraw REQUIRED) | ||
find_package(OpenEXR REQUIRED) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
# FreeImage | ||
|
||
file(GLOB FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/*.cpp ${FREEIMAGE_FOLDER}/Source/FreeImage/*.c) | ||
list(REMOVE_ITEM FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/PluginG3.cpp) | ||
list(REMOVE_ITEM FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/PluginTIFF.cpp) | ||
if(MSVC) | ||
list(APPEND FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/FreeImage.rc) | ||
endif(MSVC) | ||
|
||
file(GLOB FREEIMAGETOOLKIT_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImageToolkit/*.cpp ${FREEIMAGE_FOLDER}/Source/FreeImageToolkit/*.c) | ||
list(REMOVE_ITEM FREEIMAGETOOLKIT_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImageToolkit/JPEGTransform.cpp) | ||
|
||
file(GLOB METADATA_SOURCES ${FREEIMAGE_FOLDER}/Source/Metadata/*.cpp ${FREEIMAGE_FOLDER}/Source/Metadata/*.c) | ||
list(REMOVE_ITEM METADATA_SOURCES ${FREEIMAGE_FOLDER}/Source/Metadata/XTIFF.cpp) | ||
|
||
add_library(FreeImage ${FREEIMAGE_SOURCES} ${FREEIMAGETOOLKIT_SOURCES} ${METADATA_SOURCES}) | ||
set_target_properties(FreeImage PROPERTIES OUTPUT_NAME "freeimage") | ||
target_include_directories(FreeImage PRIVATE | ||
${FREEIMAGE_FOLDER}/Source | ||
${FREEIMAGE_FOLDER}/Source/FreeImage | ||
${FREEIMAGE_FOLDER}/Source/FreeImageToolkit | ||
${FREEIMAGE_FOLDER}/Source/Metadata | ||
) | ||
target_link_libraries(FreeImage PRIVATE | ||
ZLIB::ZLIB | ||
JPEG::JPEG | ||
OpenJPEG::OpenJPEG | ||
PNG::PNG | ||
libwebp::libwebp | ||
OpenEXR::OpenEXR | ||
libraw::libraw | ||
JXR::JXR | ||
) | ||
if(BUILD_SHARED_LIBS) | ||
target_compile_definitions(FreeImage PUBLIC FREEIMAGE_EXPORTS) | ||
else() | ||
target_compile_definitions(FreeImage PUBLIC FREEIMAGE_LIB) | ||
endif() | ||
|
||
install(TARGETS FreeImage | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
) | ||
set(FREEIMAGE_HEADERS ${FREEIMAGE_FOLDER}/Source/FreeImage.h) | ||
install(FILES ${FREEIMAGE_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
||
# FreeImagePlus | ||
|
||
set(FREEIMAGEPLUS_HEADERS ${FREEIMAGE_FOLDER}/Wrapper/FreeImagePlus/FreeImagePlus.h) | ||
file(GLOB FREEIMAGEPLUS_SOURCES ${FREEIMAGE_FOLDER}/Wrapper/FreeImagePlus/src/*.cpp ${FREEIMAGE_FOLDER}/Wrapper/FreeImagePlus/src/*.c) | ||
if(MSVC) | ||
list(APPEND FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Wrapper/FreeImagePlus/FreeImagePlus.rc) | ||
endif(MSVC) | ||
add_library(FreeImagePlus ${FREEIMAGEPLUS_SOURCES} ${FREEIMAGEPLUS_HEADERS}) | ||
set_target_properties(FreeImagePlus PROPERTIES OUTPUT_NAME "freeimageplus") | ||
target_link_libraries(FreeImagePlus PUBLIC FreeImage) | ||
target_include_directories(FreeImagePlus PRIVATE | ||
${FREEIMAGE_FOLDER}/Wrapper/FreeImagePlus | ||
${FREEIMAGE_FOLDER}/Source | ||
) | ||
if(BUILD_SHARED_LIBS) | ||
target_compile_definitions(FreeImagePlus PRIVATE FIP_EXPORTS) | ||
endif() | ||
|
||
install(TARGETS FreeImagePlus | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
) | ||
install(FILES ${FREEIMAGEPLUS_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
sources: | ||
"3.18.0": | ||
url: "http://downloads.sourceforge.net/project/freeimage/Source Distribution/3.18.0/FreeImage3180.zip" | ||
sha256: "f41379682f9ada94ea7b34fe86bf9ee00935a3147be41b6569c9605a53e438fd" | ||
patches: | ||
"3.18.0": | ||
- patch_file: "patches/001_disable_TIFF.patch" | ||
base_path: "source_subfolder" | ||
- patch_file: "patches/002_disable_JPEGTransform.patch" | ||
base_path: "source_subfolder" | ||
- patch_file: "patches/003_link_conan.patch" | ||
base_path: "source_subfolder" |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,99 @@ | ||||||
from conans import ConanFile, CMake, tools | ||||||
import os | ||||||
import shutil | ||||||
|
||||||
|
||||||
class FreeImageConan(ConanFile): | ||||||
name = "freeimage" | ||||||
description = "Open Source library project for developers who would like to support popular graphics image formats"\ | ||||||
"like PNG, BMP, JPEG, TIFF and others as needed by today's multimedia applications." | ||||||
homepage = "https://freeimage.sourceforge.io" | ||||||
url = "https://github.com/conan-io/conan-center-index" | ||||||
license = "FreeImage", "GPL-3.0-or-later", "GPL-2.0-or-later" | ||||||
topics = ("conan", "freeimage", "image", "decoding", "graphics") | ||||||
exports_sources = ["CMakeLists.txt", "patches/*"] | ||||||
generators = "cmake", "cmake_find_package" | ||||||
settings = "os", "arch", "compiler", "build_type" | ||||||
options = { | ||||||
"shared": [True, False], | ||||||
"fPIC": [True, False], | ||||||
} | ||||||
default_options = { | ||||||
"shared": False, | ||||||
"fPIC": True, | ||||||
} | ||||||
|
||||||
_cmake = None | ||||||
|
||||||
@property | ||||||
def _source_subfolder(self): | ||||||
return "source_subfolder" | ||||||
|
||||||
@property | ||||||
def _build_subfolder(self): | ||||||
return "build_subfolder" | ||||||
|
||||||
def config_options(self): | ||||||
if self.settings.os == "Windows": | ||||||
del self.options.fPIC | ||||||
|
||||||
def configure(self): | ||||||
tools.check_min_cppstd(self, "11") | ||||||
if self.options.shared: | ||||||
del self.options.fPIC | ||||||
self.output.warn("TIFF and G3 plugins are disabled.") | ||||||
|
||||||
def requirements(self): | ||||||
self.requires("zlib/1.2.11") | ||||||
self.requires("libjpeg/9d") | ||||||
self.requires("openjpeg/2.3.1") | ||||||
self.requires("libpng/1.6.37") | ||||||
self.requires("libwebp/1.1.0") | ||||||
self.requires("openexr/2.5.2 ") | ||||||
self.requires("libraw/0.19.5") | ||||||
self.requires("jxrlib/cci.20170615") | ||||||
|
||||||
def source(self): | ||||||
tools.get(**self.conan_data["sources"][self.version]) | ||||||
extracted_dir = "FreeImage" | ||||||
os.rename(extracted_dir, self._source_subfolder) | ||||||
|
||||||
def _configure_cmake(self): | ||||||
if self._cmake: | ||||||
return self._cmake | ||||||
self._cmake = CMake(self) | ||||||
self._cmake.configure(build_dir=self._build_subfolder) | ||||||
return self._cmake | ||||||
|
||||||
def build(self): | ||||||
# tools.rmdir(os.path.join(self._source_subfolder, "Source", "LibJPEG")) | ||||||
tools.rmdir(os.path.join(self._source_subfolder, "Source", "LibPNG")) | ||||||
tools.rmdir(os.path.join(self._source_subfolder, "Source", "LibTIFF4")) | ||||||
# tools.rmdir(os.path.join(self._source_subfolder, "Source", "ZLib")) | ||||||
tools.rmdir(os.path.join(self._source_subfolder, "Source", "LibOpenJPEG")) | ||||||
tools.rmdir(os.path.join(self._source_subfolder, "Source", "LibJXR")) | ||||||
tools.rmdir(os.path.join(self._source_subfolder, "Source", "LibWebP")) | ||||||
tools.rmdir(os.path.join(self._source_subfolder, "Source", "LibRawLite")) | ||||||
tools.rmdir(os.path.join(self._source_subfolder, "Source", "OpenEXR")) | ||||||
|
||||||
for patch in self.conan_data.get("patches", {}).get(self.version, {}): | ||||||
tools.patch(**patch) | ||||||
cmake = self._configure_cmake() | ||||||
cmake.build() | ||||||
|
||||||
def package(self): | ||||||
cmake = self._configure_cmake() | ||||||
cmake.install() | ||||||
self.copy("license-fi.txt", dst="licenses", src=self._source_subfolder) | ||||||
self.copy("license-gplv3.txt", dst="licenses", src=self._source_subfolder) | ||||||
self.copy("license-gplv2.txt", dst="licenses", src=self._source_subfolder) | ||||||
|
||||||
def package_info(self): | ||||||
self.cpp_info.libs = tools.collect_libs(self) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
self.cpp_info.names["pkg_config"] = "freeimage" | ||||||
self.cpp_info.names["cmake_find_package"] = "FreeImage" | ||||||
self.cpp_info.names["cmake_find_package_multi"] = "FreeImage" | ||||||
Comment on lines
+95
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These names are not official, aren't they?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's right. I just use the most popular pattern. (Ex: https://github.com/OGRECave/ogre/blob/master/CMake/Packages/FindFreeImage.cmake) |
||||||
|
||||||
if not self.options.shared: | ||||||
self.cpp_info.defines.append("FREEIMAGE_LIB") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- Source/FreeImage/Plugin.cpp | ||
+++ Source/FreeImage/Plugin.cpp | ||
@@ -254,7 +254,9 @@ | ||
s_plugins->AddNode(InitPNM, NULL, "PPMRAW", "Portable Pixelmap (RAW)", "ppm", "^P6"); | ||
s_plugins->AddNode(InitRAS); | ||
s_plugins->AddNode(InitTARGA); | ||
+#if 0 | ||
s_plugins->AddNode(InitTIFF); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't our libtiff recipe working? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FreeImage need a private copy of libtiff. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Too many modifications? Dammit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's painful. Look at vcpkg port, It's really annoying There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See https://sourceforge.net/p/freeimage/discussion/36111/thread/c326f1be79/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really know how to fix it:
Both have huge drawbacks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, if you're saying that it's a lot of work to make it truly use external dependencies. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that big patches to unvendor all these deps -like in the vcpkg port- are fine. The last version of freeimage is 2.5 years old. |
||
+#endif | ||
s_plugins->AddNode(InitWBMP); | ||
s_plugins->AddNode(InitPSD); | ||
s_plugins->AddNode(InitCUT); | ||
@@ -263,7 +265,9 @@ | ||
s_plugins->AddNode(InitDDS); | ||
s_plugins->AddNode(InitGIF); | ||
s_plugins->AddNode(InitHDR); | ||
+#if 0 | ||
s_plugins->AddNode(InitG3); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What library are we missing? |
||
+#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,36 @@ | ||
--- Source/FreeImage.h | ||
+++ Source/FreeImage.h | ||
@@ -476,6 +476,7 @@ | ||
/** Lossless JPEG transformations | ||
Constants used in FreeImage_JPEGTransform | ||
*/ | ||
+#if 0 | ||
FI_ENUM(FREE_IMAGE_JPEG_OPERATION) { | ||
FIJPEG_OP_NONE = 0, //! no transformation | ||
FIJPEG_OP_FLIP_H = 1, //! horizontal flip | ||
@@ -486,6 +487,7 @@ | ||
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. | ||
@@ -1088,7 +1090,7 @@ | ||
// -------------------------------------------------------------------------- | ||
// JPEG lossless transformation routines | ||
// -------------------------------------------------------------------------- | ||
- | ||
+#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); | ||
@@ -1097,7 +1099,7 @@ | ||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can libjpeg be removed? You're adding libjpeg to the requires list.
Same question for the Zlib directory.