diff --git a/recipes/freeimage/all/CMakeLists.txt b/recipes/freeimage/all/CMakeLists.txt new file mode 100644 index 0000000000000..d01ed09d2ddbf --- /dev/null +++ b/recipes/freeimage/all/CMakeLists.txt @@ -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}) diff --git a/recipes/freeimage/all/conandata.yml b/recipes/freeimage/all/conandata.yml new file mode 100644 index 0000000000000..f236720187409 --- /dev/null +++ b/recipes/freeimage/all/conandata.yml @@ -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" diff --git a/recipes/freeimage/all/conanfile.py b/recipes/freeimage/all/conanfile.py new file mode 100644 index 0000000000000..37f4f0af72a6b --- /dev/null +++ b/recipes/freeimage/all/conanfile.py @@ -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) + + self.cpp_info.names["pkg_config"] = "freeimage" + self.cpp_info.names["cmake_find_package"] = "FreeImage" + self.cpp_info.names["cmake_find_package_multi"] = "FreeImage" + + if not self.options.shared: + self.cpp_info.defines.append("FREEIMAGE_LIB") diff --git a/recipes/freeimage/all/patches/001_disable_TIFF.patch b/recipes/freeimage/all/patches/001_disable_TIFF.patch new file mode 100644 index 0000000000000..06ca47f299827 --- /dev/null +++ b/recipes/freeimage/all/patches/001_disable_TIFF.patch @@ -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); ++#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); ++#endif + s_plugins->AddNode(InitSGI); + s_plugins->AddNode(InitEXR); + s_plugins->AddNode(InitJ2K); diff --git a/recipes/freeimage/all/patches/002_disable_JPEGTransform.patch b/recipes/freeimage/all/patches/002_disable_JPEGTransform.patch new file mode 100644 index 0000000000000..6f7286ba78cf0 --- /dev/null +++ b/recipes/freeimage/all/patches/002_disable_JPEGTransform.patch @@ -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 diff --git a/recipes/freeimage/all/patches/003_link_conan.patch b/recipes/freeimage/all/patches/003_link_conan.patch new file mode 100644 index 0000000000000..fee5d70f91d83 --- /dev/null +++ b/recipes/freeimage/all/patches/003_link_conan.patch @@ -0,0 +1,155 @@ +--- Source/FreeImage/J2KHelper.cpp ++++ Source/FreeImage/J2KHelper.cpp +@@ -21,7 +21,7 @@ + + #include "FreeImage.h" + #include "Utilities.h" +-#include "../LibOpenJPEG/openjpeg.h" ++#include + #include "J2KHelper.h" + + // -------------------------------------------------------------------------- +--- Source/FreeImage/PluginEXR.cpp ++++ 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 + + + // ========================================================== +--- Source/FreeImage/PluginJ2K.cpp ++++ Source/FreeImage/PluginJ2K.cpp +@@ -21,7 +21,7 @@ + + #include "FreeImage.h" + #include "Utilities.h" +-#include "../LibOpenJPEG/openjpeg.h" ++#include + #include "J2KHelper.h" + + // ========================================================== +--- Source/FreeImage/PluginJP2.cpp ++++ Source/FreeImage/PluginJP2.cpp +@@ -21,7 +21,7 @@ + + #include "FreeImage.h" + #include "Utilities.h" +-#include "../LibOpenJPEG/openjpeg.h" ++#include + #include "J2KHelper.h" + + // ========================================================== +--- Source/FreeImage/PluginJPEG.cpp ++++ Source/FreeImage/PluginJPEG.cpp +@@ -35,9 +35,9 @@ + #undef FAR + #include + +-#include "../LibJPEG/jinclude.h" +-#include "../LibJPEG/jpeglib.h" +-#include "../LibJPEG/jerror.h" ++#include ++#include ++#include + } + + #include "FreeImage.h" +--- Source/FreeImage/PluginJXR.cpp ++++ Source/FreeImage/PluginJXR.cpp +@@ -23,7 +23,7 @@ + #include "Utilities.h" + #include "../Metadata/FreeImageTag.h" + +-#include "../LibJXR/jxrgluelib/JXRGlue.h" ++#include + + // ========================================================== + // Plugin Interface +--- Source/FreeImage/PluginPNG.cpp ++++ Source/FreeImage/PluginPNG.cpp +@@ -40,8 +40,8 @@ + + // ---------------------------------------------------------- + +-#include "../ZLib/zlib.h" +-#include "../LibPNG/png.h" ++#include ++#include + + // ---------------------------------------------------------- + +--- Source/FreeImage/PluginRAW.cpp ++++ Source/FreeImage/PluginRAW.cpp +@@ -19,7 +19,7 @@ + // Use at your own risk! + // ========================================================== + +-#include "../LibRawLite/libraw/libraw.h" ++#include + + #include "FreeImage.h" + #include "Utilities.h" +--- Source/FreeImage/PluginTIFF.cpp ++++ Source/FreeImage/PluginTIFF.cpp +@@ -37,9 +37,9 @@ + + #include "FreeImage.h" + #include "Utilities.h" +-#include "../LibTIFF4/tiffiop.h" ++#include + #include "../Metadata/FreeImageTag.h" +-#include "../OpenEXR/Half/half.h" ++#include + + #include "FreeImageIO.h" + #include "PSDParser.h" +--- Source/FreeImage/PluginWebP.cpp ++++ Source/FreeImage/PluginWebP.cpp +@@ -24,9 +24,9 @@ + + #include "../Metadata/FreeImageTag.h" + +-#include "../LibWebP/src/webp/decode.h" +-#include "../LibWebP/src/webp/encode.h" +-#include "../LibWebP/src/webp/mux.h" ++#include ++#include ++#include + + // ========================================================== + // Plugin Interface +--- Source/FreeImage/ZLibInterface.cpp ++++ Source/FreeImage/ZLibInterface.cpp +@@ -19,10 +19,10 @@ + // Use at your own risk! + // ========================================================== + +-#include "../ZLib/zlib.h" ++#include + #include "FreeImage.h" + #include "Utilities.h" + #include "../ZLib/zutil.h" /* must be the last header because of error C3163 in VS2008 (_vsnprintf defined in stdio.h) */ + + /** + Compresses a source buffer into a target buffer, using the ZLib library. diff --git a/recipes/freeimage/all/test_package/CMakeLists.txt b/recipes/freeimage/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..454c47bb2cbab --- /dev/null +++ b/recipes/freeimage/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/freeimage/all/test_package/conanfile.py b/recipes/freeimage/all/test_package/conanfile.py new file mode 100644 index 0000000000000..6630ef829f92d --- /dev/null +++ b/recipes/freeimage/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + bees = os.path.join(self.source_folder, "test.png") + self.run("{} {}".format(bin_path, bees), run_environment=True) diff --git a/recipes/freeimage/all/test_package/test.png b/recipes/freeimage/all/test_package/test.png new file mode 100644 index 0000000000000..11640c7488fb1 Binary files /dev/null and b/recipes/freeimage/all/test_package/test.png differ diff --git a/recipes/freeimage/all/test_package/test_package.cpp b/recipes/freeimage/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..ab567138dd576 --- /dev/null +++ b/recipes/freeimage/all/test_package/test_package.cpp @@ -0,0 +1,51 @@ +#include + +#include + +#define NEED_INIT defined(FREEIMAGE_LIB) || !defined(WIN32) + +void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char* message) +{ + std::cerr << "FreeImage error: " << message << std::endl; +} + +int main(int argc, char** argv ) +{ + if (argc < 2) { + std::cerr << "Need at least one argument" << std::endl; + return 1; + } + +#if NEED_INIT + FreeImage_Initialise(); +#endif + + FreeImage_SetOutputMessage(FreeImageErrorHandler); + + std::cout << "FreeImage " << FreeImage_GetVersion() << ", with:" << std::endl; + + for (int i = 0; i < FreeImage_GetFIFCount(); ++i) + { + std::cout << "\t- " << FreeImage_GetFIFExtensionList((FREE_IMAGE_FORMAT)i) << std::endl; + } + + const char * image_file = argv[1]; + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + fif = FreeImage_GetFileType(image_file, 0); + if(fif == FIF_UNKNOWN) { + fif = FreeImage_GetFIFFromFilename(image_file); + } + if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) { + FIBITMAP* dib = FreeImage_Load(fif, image_file, 0); + if(dib) + { + FreeImage_Unload(dib); + } + } + +#if NEED_INIT + FreeImage_DeInitialise(); +#endif + + return 0; +} diff --git a/recipes/freeimage/config.yml b/recipes/freeimage/config.yml new file mode 100644 index 0000000000000..7e5f545547ca1 --- /dev/null +++ b/recipes/freeimage/config.yml @@ -0,0 +1,3 @@ +versions: + "3.18.0": + folder: all