Warning, /graphics/digikam/project/bundles/3rdparty/ext_mosaicwall/mosaicwall-exiv2-cpp17.patch is written in an unsupported language. File is not indexed.
0001 diff --git a/CMakeLists.txt b/CMakeLists.txt 0002 index ec6d70e..b8d3cec 100644 0003 --- a/CMakeLists.txt 0004 +++ b/CMakeLists.txt 0005 @@ -1,17 +1,18 @@ 0006 # 0007 -# Copyright (c) 2020, Gilles Caulier, <caulier dot gilles at gmail dot com> 0008 +# Copyright (c) 2020-2023, Gilles Caulier, <caulier dot gilles at gmail dot com> 0009 # 0010 # Redistribution and use is allowed according to the terms of the BSD license. 0011 # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 0012 0013 -project(ImageMosaicWall) 0014 +cmake_minimum_required(VERSION "3.16") 0015 0016 -cmake_minimum_required(VERSION "3.1.0") 0017 +project(ImageMosaicWall) 0018 0019 -option(ENABLE_DPLUGIN "Build digiKam plugin version of Image Mosaic Wall tool (default=OFF)" OFF) 0020 -option(BUILD_WITH_QT6 "Build with Qt6, else Qt5" OFF) 0021 +option(ENABLE_DPLUGIN "Build digiKam plugin only of Image Mosaic Wall tool (default=OFF)" OFF) 0022 +option(BUILD_WITH_QT6 "Build with Qt6, else Qt5" OFF) 0023 0024 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) 0025 + 0026 if (ENABLE_DPLUGIN) 0027 include(MacroInstall) 0028 endif() 0029 @@ -24,6 +25,12 @@ endif() 0030 0031 include(FeatureSummary) 0032 0033 +if(MSVC) 0034 + add_compile_options(/utf-8) 0035 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") 0036 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-") 0037 +endif() 0038 + 0039 set(CMAKE_CXX_STANDARD 17) 0040 0041 if(CMAKE_VERSION VERSION_LESS "3.7.0") 0042 @@ -34,7 +41,6 @@ set(CMAKE_AUTOMOC ON) 0043 set(CMAKE_AUTORCC ON) 0044 set(CMAKE_AUTOUIC ON) 0045 0046 - 0047 if(BUILD_WITH_QT6) 0048 0049 find_package(Qt6 "6.5.0" REQUIRED 0050 @@ -63,10 +69,29 @@ endif() 0051 0052 find_package(Threads) 0053 0054 -find_package(exiv2 REQUIRED) 0055 +find_package(exiv2lib REQUIRED CONFIG NAMES exiv2) 0056 + 0057 +if(exiv2lib_FOUND) 0058 + 0059 + message(STATUS "Found Exiv2 version ${exiv2lib_VERSION}") 0060 + 0061 + # Work around the cmake export rules from Exiv2 since 0.28 0062 + 0063 + if("${exiv2lib_VERSION}" VERSION_GREATER "0.27.99") 0064 + 0065 + set(exiv2lib_LIBRARIES Exiv2::exiv2lib) 0066 + 0067 + else() 0068 + 0069 + set(exiv2lib_LIBRARIES exiv2lib) 0070 + 0071 + endif() 0072 + 0073 + message(STATUS "Exiv2 libraries: ${exiv2lib_LIBRARIES}") 0074 0075 -set_package_properties("exiv2" PROPERTIES 0076 - DESCRIPTION "Required to build digiKam" 0077 +endif() 0078 + 0079 +set_package_properties(exiv2lib PROPERTIES 0080 URL "https://www.exiv2.org" 0081 TYPE RECOMMENDED 0082 PURPOSE "Library to manage image metadata" 0083 @@ -74,8 +99,7 @@ set_package_properties("exiv2" PROPERTIES 0084 0085 include(i18nUtils) 0086 0087 -include_directories($<TARGET_PROPERTY:exiv2lib,INTERFACE_INCLUDE_DIRECTORIES> 0088 - $<TARGET_PROPERTY:Qt${QT_VERSION_MAJOR}::Widgets,INTERFACE_INCLUDE_DIRECTORIES> 0089 +include_directories($<TARGET_PROPERTY:Qt${QT_VERSION_MAJOR}::Widgets,INTERFACE_INCLUDE_DIRECTORIES> 0090 $<TARGET_PROPERTY:Qt${QT_VERSION_MAJOR}::Core,INTERFACE_INCLUDE_DIRECTORIES> 0091 $<TARGET_PROPERTY:Qt${QT_VERSION_MAJOR}::Gui,INTERFACE_INCLUDE_DIRECTORIES> 0092 $<TARGET_PROPERTY:Qt${QT_VERSION_MAJOR}::Concurrent,INTERFACE_INCLUDE_DIRECTORIES> 0093 @@ -93,7 +117,6 @@ set(imagemosaicwall_core_SRCS ${CMAKE_SOURCE_DIR}/mainwindow.cpp 0094 ${i18n_QM} 0095 ) 0096 0097 - 0098 if(Qt6_FOUND) 0099 0100 qt6_wrap_ui(imagemosaicwall_core_SRCS ${CMAKE_SOURCE_DIR}/mainwindow.ui 0101 @@ -119,47 +142,54 @@ set(libimagemosaicwall_core_SRCS 0102 0103 add_library(imagemosaicwallcore STATIC ${libimagemosaicwall_core_SRCS}) 0104 0105 +target_link_libraries(imagemosaicwallcore 0106 + PUBLIC 0107 + ${exiv2lib_LIBRARIES} 0108 +) 0109 + 0110 if(NOT MSVC) 0111 target_compile_options(imagemosaicwallcore PRIVATE -fPIC) 0112 endif() 0113 0114 -if(APPLE) 0115 - add_executable(ImageMosaicWall MACOSX_BUNDLE ${OSX_APP_ICON} ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp) 0116 -else() 0117 - add_executable(ImageMosaicWall ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp) 0118 -endif() 0119 +if(NOT ENABLE_DPLUGIN) 0120 0121 -target_link_libraries(ImageMosaicWall 0122 + if(APPLE) 0123 + add_executable(ImageMosaicWall MACOSX_BUNDLE ${OSX_APP_ICON} ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp) 0124 + else() 0125 + add_executable(ImageMosaicWall ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp) 0126 + endif() 0127 0128 - imagemosaicwallcore 0129 + target_link_libraries(ImageMosaicWall 0130 0131 - Qt${QT_VERSION_MAJOR}::Core 0132 - Qt${QT_VERSION_MAJOR}::Widgets 0133 - Qt${QT_VERSION_MAJOR}::Gui 0134 - Qt${QT_VERSION_MAJOR}::Concurrent 0135 + imagemosaicwallcore 0136 0137 - exiv2lib 0138 - ${CMAKE_THREAD_LIBS_INIT} 0139 -) 0140 + Qt${QT_VERSION_MAJOR}::Core 0141 + Qt${QT_VERSION_MAJOR}::Widgets 0142 + Qt${QT_VERSION_MAJOR}::Gui 0143 + Qt${QT_VERSION_MAJOR}::Concurrent 0144 + 0145 + ${CMAKE_THREAD_LIBS_INIT} 0146 + ) 0147 + 0148 + if(APPLE) 0149 + set(APPS "\${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app") 0150 + set(DIRS "\${CMAKE_INSTALL_PREFIX}/share") 0151 0152 -if(APPLE) 0153 - set(APPS "\${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app") 0154 - set(DIRS "\${CMAKE_INSTALL_PREFIX}/share") 0155 + install(TARGETS ${PROJECT_NAME} 0156 + BUNDLE DESTINATION . COMPONENT Runtime 0157 + RUNTIME DESTINATION bin COMPONENT Runtime) 0158 0159 - install(TARGETS ${PROJECT_NAME} 0160 - BUNDLE DESTINATION . COMPONENT Runtime 0161 - RUNTIME DESTINATION bin COMPONENT Runtime 0162 - ) 0163 + install(CODE " 0164 + include(BundleUtilities) 0165 + fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\") 0166 + " COMPONENT Runtime) 0167 + else() 0168 + install(TARGETS ImageMosaicWall RUNTIME DESTINATION bin) 0169 + endif() 0170 0171 - install(CODE " 0172 - include(BundleUtilities) 0173 - fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\") 0174 - " COMPONENT Runtime) 0175 else() 0176 - install(TARGETS ImageMosaicWall RUNTIME DESTINATION bin) 0177 -endif() 0178 0179 -if (ENABLE_DPLUGIN) 0180 add_subdirectory(dplugin) 0181 MACRO_ADD_UNINSTALL_TARGET() 0182 + 0183 endif() 0184 diff --git a/dplugin/CMakeLists.txt b/dplugin/CMakeLists.txt 0185 index 2842f45..f882de8 100644 0186 --- a/dplugin/CMakeLists.txt 0187 +++ b/dplugin/CMakeLists.txt 0188 @@ -35,8 +35,6 @@ target_link_libraries(Generic_ImageMosaicWall_Plugin 0189 Qt${QT_VERSION_MAJOR}::Widgets 0190 Qt${QT_VERSION_MAJOR}::Gui 0191 Qt${QT_VERSION_MAJOR}::Concurrent 0192 - 0193 - exiv2lib 0194 ) 0195 0196 MACRO_ADD_PLUGIN_INSTALL_TARGET(Generic_ImageMosaicWall_Plugin generic) 0197 diff --git a/imageprocessing.cpp b/imageprocessing.cpp 0198 index 407d943..b4609a8 100644 0199 --- a/imageprocessing.cpp 0200 +++ b/imageprocessing.cpp 0201 @@ -1,5 +1,6 @@ 0202 #include "imageprocessing.h" 0203 #include <algorithm> 0204 +#include <cstdlib> 0205 #include <QDebug> 0206 #include <QImage> 0207 #include <QImageReader> 0208 @@ -18,6 +19,18 @@ 0209 # define kerErrorMessage ErrorCode::kerErrorMessage 0210 #endif 0211 0212 +template<class RandomIt> 0213 +void my_random_shuffle(RandomIt first, RandomIt last) 0214 +{ 0215 + typedef typename std::iterator_traits<RandomIt>::difference_type diff_t; 0216 + 0217 + for (diff_t i = last - first - 1; i > 0; --i) 0218 + { 0219 + using std::swap; 0220 + swap(first[i], first[std::rand() % (i + 1)]); 0221 + } 0222 +} 0223 + 0224 ImageProcessing::ImageProcessing(QObject *parent) 0225 : QObject(parent) 0226 , m_skipBackgroundProcess(false) 0227 @@ -189,7 +202,7 @@ void ImageProcessing::calculateMosaicPositions(const QSize gridSize, const int s 0228 for (uint32_t i = startPos; i < startPos + length; ++i) 0229 positions.push_back(i); 0230 0231 - std::random_shuffle(positions.begin(), positions.end()); 0232 + my_random_shuffle(positions.begin(), positions.end()); 0233 for (auto pos : positions) 0234 { 0235 if (m_skipBackgroundProcess)