build: vendor FindLibExiv2.cmake from ECM
This commit is contained in:
parent
5705f02636
commit
08f1ab570c
|
@ -2,6 +2,8 @@ project (pineapple-pictures)
|
||||||
|
|
||||||
cmake_minimum_required (VERSION 3.9.5)
|
cmake_minimum_required (VERSION 3.9.5)
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
|
||||||
|
|
||||||
include (GNUInstallDirs)
|
include (GNUInstallDirs)
|
||||||
include (FeatureSummary)
|
include (FeatureSummary)
|
||||||
|
|
||||||
|
@ -14,8 +16,8 @@ option (EXIV2_METADATA_SUPPORT "Better image metadata support via libexiv2" ON)
|
||||||
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Widgets Svg LinguistTools)
|
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Widgets Svg LinguistTools)
|
||||||
|
|
||||||
if (EXIV2_METADATA_SUPPORT)
|
if (EXIV2_METADATA_SUPPORT)
|
||||||
find_package(Exiv2)
|
find_package(LibExiv2)
|
||||||
set_package_properties(Exiv2 PROPERTIES
|
set_package_properties(LibExiv2 PROPERTIES
|
||||||
URL "https://www.exiv2.org"
|
URL "https://www.exiv2.org"
|
||||||
DESCRIPTION "image metadata support"
|
DESCRIPTION "image metadata support"
|
||||||
TYPE OPTIONAL
|
TYPE OPTIONAL
|
||||||
|
@ -87,14 +89,14 @@ add_executable (${EXE_NAME}
|
||||||
|
|
||||||
target_link_libraries (${EXE_NAME} Qt5::Widgets Qt5::Svg)
|
target_link_libraries (${EXE_NAME} Qt5::Widgets Qt5::Svg)
|
||||||
|
|
||||||
if (Exiv2_FOUND)
|
if (LibExiv2_FOUND)
|
||||||
message(INFO ${LibExiv2_INCLUDE_DIRS})
|
message(INFO ${LibExiv2_INCLUDE_DIRS})
|
||||||
target_include_directories(${EXE_NAME}
|
target_include_directories(${EXE_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${LibExiv2_INCLUDE_DIRS}
|
${LibExiv2_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
target_link_libraries (${EXE_NAME}
|
target_link_libraries (${EXE_NAME}
|
||||||
Exiv2
|
LibExiv2::LibExiv2
|
||||||
)
|
)
|
||||||
target_compile_definitions(${EXE_NAME} PRIVATE
|
target_compile_definitions(${EXE_NAME} PRIVATE
|
||||||
HAVE_EXIV2_VERSION="${LibExiv2_VERSION}"
|
HAVE_EXIV2_VERSION="${LibExiv2_VERSION}"
|
||||||
|
|
|
@ -11,7 +11,8 @@ Yet another image viewer.
|
||||||
## Get it!
|
## Get it!
|
||||||
|
|
||||||
- [GitHub Release Page](https://github.com/BLumia/pineapple-pictures/releases)
|
- [GitHub Release Page](https://github.com/BLumia/pineapple-pictures/releases)
|
||||||
- Archlinux AUR: [pineapple-pictures-git](https://aur.archlinux.org/packages/pineapple-pictures-git/)
|
- Archlinux AUR: [pineapple-pictures](https://aur.archlinux.org/packages/pineapple-pictures/) | [pineapple-pictures-git](https://aur.archlinux.org/packages/pineapple-pictures-git/)
|
||||||
|
- Debian (sid / testing): `sudo apt install pineapple-pictures`
|
||||||
|
|
||||||
## Build it manually:
|
## Build it manually:
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ Current state, we need:
|
||||||
|
|
||||||
- `cmake`: as the build system.
|
- `cmake`: as the build system.
|
||||||
- `qt5` with `qt5-svg` and `qt5-tools`: since the app is using Qt.
|
- `qt5` with `qt5-svg` and `qt5-tools`: since the app is using Qt.
|
||||||
|
- `libexiv2`: able to display more image metadata. (optional, but recommended)
|
||||||
|
|
||||||
Then we can build it with any proper c++ compiler like g++ or msvc.
|
Then we can build it with any proper c++ compiler like g++ or msvc.
|
||||||
|
|
||||||
|
@ -32,6 +34,8 @@ $ cmake --build . # or simply using `make` if you are using Makefile as the cmak
|
||||||
|
|
||||||
After that, a `ppic` executable file will be available to use. You can also optionally install it by using the target `install` (or simply `make install` in case you are using Makefile). After the build process, you can also use `cpack` to make a package.
|
After that, a `ppic` executable file will be available to use. You can also optionally install it by using the target `install` (or simply `make install` in case you are using Makefile). After the build process, you can also use `cpack` to make a package.
|
||||||
|
|
||||||
|
The project will try to build with `exiv2` when it's available at build time, if you would like to build the project without `exiv2`, pass `-DEXIV2_METADATA_SUPPORT=OFF` to `cmake`. The project will also not use `exiv2` if it's not found, the `EXIV2_METADATA_SUPPORT` option can be useful if you have `exiv2` but specifically don't want to use it.
|
||||||
|
|
||||||
Image formats supports rely on Qt's imageformats plugins, just get the plugins you need from your distro's package manager will be fine. For Windows user, you may need build and install the imageformats plugin manually, read the content below.
|
Image formats supports rely on Qt's imageformats plugins, just get the plugins you need from your distro's package manager will be fine. For Windows user, you may need build and install the imageformats plugin manually, read the content below.
|
||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
@ -64,4 +68,4 @@ Feel free to open up an issue to request a new language to translate.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This program released under MIT license
|
Pineapple Pictures as a whole is licensed under MIT license. Individual files may have a different, but compatible license.
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
## 立即获取!
|
## 立即获取!
|
||||||
|
|
||||||
- [GitHub Release 页面](https://github.com/BLumia/pineapple-pictures/releases) | [gitee 发布页面](https://gitee.com/blumia/pineapple-pictures/releases)
|
- [GitHub Release 页面](https://github.com/BLumia/pineapple-pictures/releases) | [gitee 发布页面](https://gitee.com/blumia/pineapple-pictures/releases)
|
||||||
- Archlinux AUR: [pineapple-pictures-git](https://aur.archlinux.org/packages/pineapple-pictures-git/)
|
- Archlinux AUR: [pineapple-pictures](https://aur.archlinux.org/packages/pineapple-pictures/) | [pineapple-pictures-git](https://aur.archlinux.org/packages/pineapple-pictures-git/)
|
||||||
|
- Debian (sid / testing): `sudo apt install pineapple-pictures`
|
||||||
|
|
||||||
## 手动构建步骤:
|
## 手动构建步骤:
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
|
|
||||||
- `cmake`: 我们所使用的构建系统
|
- `cmake`: 我们所使用的构建系统
|
||||||
- 包含 `qt5-svg` 与 `qt5-tools` 组件的 `qt5`: 此应用基于 Qt
|
- 包含 `qt5-svg` 与 `qt5-tools` 组件的 `qt5`: 此应用基于 Qt
|
||||||
|
- `libexiv2`: 用以获取和显示更多的图像元信息(可选,推荐)
|
||||||
|
|
||||||
然后我们就可以使用任何常规的 c++ 编译器如 g++ 或 msvc 来进行构建了
|
然后我们就可以使用任何常规的 c++ 编译器如 g++ 或 msvc 来进行构建了
|
||||||
|
|
||||||
|
@ -32,6 +34,8 @@ $ cmake --build . # 如果你使用 Makefile 作为 CMake 生成器,也可以
|
||||||
|
|
||||||
完毕后,一个名为 `ppic` 的可执行程序即会被生成以供使用。您也可以选择通过使用 CMake 生成的 `install` 目标继续将其安装到您的设备上(假设您使用 Makefile,即可执行 `make install` 来进行安装)。构建步骤完毕后,您也可以使用 `cpack` 来对应用程序进行打包。
|
完毕后,一个名为 `ppic` 的可执行程序即会被生成以供使用。您也可以选择通过使用 CMake 生成的 `install` 目标继续将其安装到您的设备上(假设您使用 Makefile,即可执行 `make install` 来进行安装)。构建步骤完毕后,您也可以使用 `cpack` 来对应用程序进行打包。
|
||||||
|
|
||||||
|
当 `exiv2` 在构建时可用时,此项目将尝试使用其进行构建,若您不希望使用 `exiv2`,请传递 `-DEXIV2_METADATA_SUPPORT=OFF` 参数给 `cmake`。此项目在找不到 `exiv2` 时并不会使用 `exiv2`,`EXIV2_METADATA_SUPPORT` 选项可供尽管存在可用的 `exiv2` 但您明确不希望启用其支持时使用。
|
||||||
|
|
||||||
此应用的图片格式支持依赖于 Qt 的 imageformats 插件,直接从您所用的发行版获取对应的图像格式插件即可。对于 Windows 用户,您可能需要手动构建和使用图像格式插件。下方给出了进一步的说明。
|
此应用的图片格式支持依赖于 Qt 的 imageformats 插件,直接从您所用的发行版获取对应的图像格式插件即可。对于 Windows 用户,您可能需要手动构建和使用图像格式插件。下方给出了进一步的说明。
|
||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
@ -64,4 +68,4 @@ $ cmake --build . # 如果你使用 Makefile 作为 CMake 生成器,也可以
|
||||||
|
|
||||||
## 许可协议
|
## 许可协议
|
||||||
|
|
||||||
此项目使用 MIT 协议进行发布。
|
菠萝看图整体使用 MIT 协议进行发布。项目所随的部分源文件可能具备不同但与之兼容的许可协议。
|
||||||
|
|
96
cmake/FindLibExiv2.cmake
Normal file
96
cmake/FindLibExiv2.cmake
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
#.rst:
|
||||||
|
# FindLibExiv2
|
||||||
|
# ------------
|
||||||
|
#
|
||||||
|
# Try to find the Exiv2 library.
|
||||||
|
#
|
||||||
|
# This will define the following variables:
|
||||||
|
#
|
||||||
|
# ``LibExiv2_FOUND``
|
||||||
|
# True if (the requested version of) Exiv2 is available
|
||||||
|
#
|
||||||
|
# ``LibExiv2_VERSION``
|
||||||
|
# The version of Exiv2
|
||||||
|
#
|
||||||
|
# ``LibExiv2_INCLUDE_DIRS``
|
||||||
|
# The include dirs of Exiv2 for use with target_include_directories()
|
||||||
|
#
|
||||||
|
# ``LibExiv2_LIBRARIES``
|
||||||
|
# The Exiv2 library for use with target_link_libraries().
|
||||||
|
# This can be passed to target_link_libraries() instead of
|
||||||
|
# the ``LibExiv2::LibExiv2`` target
|
||||||
|
#
|
||||||
|
# If ``LibExiv2_FOUND`` is TRUE, it will also define the following imported
|
||||||
|
# target:
|
||||||
|
#
|
||||||
|
# ``LibExiv2::LibExiv2``
|
||||||
|
# The Exiv2 library
|
||||||
|
#
|
||||||
|
# In general we recommend using the imported target, as it is easier to use.
|
||||||
|
# Bear in mind, however, that if the target is in the link interface of an
|
||||||
|
# exported library, it must be made available by the package config file.
|
||||||
|
#
|
||||||
|
# Since 5.53.0.
|
||||||
|
#
|
||||||
|
#=============================================================================
|
||||||
|
# SPDX-FileCopyrightText: 2018 Christophe Giboudeaux <christophe@krop.fr>
|
||||||
|
# SPDX-FileCopyrightText: 2010 Alexander Neundorf <neundorf@kde.org>
|
||||||
|
# SPDX-FileCopyrightText: 2008 Gilles Caulier <caulier.gilles@gmail.com>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
#=============================================================================
|
||||||
|
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
pkg_check_modules(PC_EXIV2 QUIET exiv2)
|
||||||
|
|
||||||
|
find_path(LibExiv2_INCLUDE_DIRS NAMES exiv2/exif.hpp
|
||||||
|
HINTS ${PC_EXIV2_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(LibExiv2_LIBRARIES NAMES exiv2 libexiv2
|
||||||
|
HINTS ${PC_EXIV2_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(LibExiv2_VERSION ${PC_EXIV2_VERSION})
|
||||||
|
|
||||||
|
if(NOT LibExiv2_VERSION AND DEFINED LibExiv2_INCLUDE_DIRS)
|
||||||
|
# With exiv >= 0.27, the version #defines are in exv_conf.h instead of version.hpp
|
||||||
|
foreach(_exiv2_version_file "version.hpp" "exv_conf.h")
|
||||||
|
if(EXISTS "${LibExiv2_INCLUDE_DIRS}/exiv2/${_exiv2_version_file}")
|
||||||
|
file(READ "${LibExiv2_INCLUDE_DIRS}/exiv2/${_exiv2_version_file}" _exiv_version_file_content)
|
||||||
|
string(REGEX MATCH "#define EXIV2_MAJOR_VERSION[ ]+\\([0-9]+\\)" EXIV2_MAJOR_VERSION_MATCH ${_exiv_version_file_content})
|
||||||
|
string(REGEX MATCH "#define EXIV2_MINOR_VERSION[ ]+\\([0-9]+\\)" EXIV2_MINOR_VERSION_MATCH ${_exiv_version_file_content})
|
||||||
|
string(REGEX MATCH "#define EXIV2_PATCH_VERSION[ ]+\\([0-9]+\\)" EXIV2_PATCH_VERSION_MATCH ${_exiv_version_file_content})
|
||||||
|
if(EXIV2_MAJOR_VERSION_MATCH)
|
||||||
|
string(REGEX REPLACE ".*_MAJOR_VERSION[ ]+\\((.*)\\)" "\\1" EXIV2_MAJOR_VERSION ${EXIV2_MAJOR_VERSION_MATCH})
|
||||||
|
string(REGEX REPLACE ".*_MINOR_VERSION[ ]+\\((.*)\\)" "\\1" EXIV2_MINOR_VERSION ${EXIV2_MINOR_VERSION_MATCH})
|
||||||
|
string(REGEX REPLACE ".*_PATCH_VERSION[ ]+\\((.*)\\)" "\\1" EXIV2_PATCH_VERSION ${EXIV2_PATCH_VERSION_MATCH})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(LibExiv2_VERSION "${EXIV2_MAJOR_VERSION}.${EXIV2_MINOR_VERSION}.${EXIV2_PATCH_VERSION}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(LibExiv2
|
||||||
|
FOUND_VAR LibExiv2_FOUND
|
||||||
|
REQUIRED_VARS LibExiv2_LIBRARIES LibExiv2_INCLUDE_DIRS
|
||||||
|
VERSION_VAR LibExiv2_VERSION
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(LibExiv2_INCLUDE_DIRS LibExiv2_LIBRARIES)
|
||||||
|
|
||||||
|
if(LibExiv2_FOUND AND NOT TARGET LibExiv2::LibExiv2)
|
||||||
|
add_library(LibExiv2::LibExiv2 UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(LibExiv2::LibExiv2 PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${LibExiv2_LIBRARIES}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${LibExiv2_INCLUDE_DIRS}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FeatureSummary)
|
||||||
|
set_package_properties(LibExiv2 PROPERTIES
|
||||||
|
URL "https://www.exiv2.org"
|
||||||
|
DESCRIPTION "Image metadata support"
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user