Definition of new CMake presets & usage in CI jobs

Additional interesting changes in this commit:
- conan: use cmake-conan for better CMake-Conan integration
- cmake+doc: Remove deprecated EXIV2_ENABLE_WIN_UNICODE
- Ignore CMakeUserPresets.json
- doc: Add notes about the usage of CMake presets
This commit is contained in:
Luis Diaz 2022-04-26 16:40:27 +02:00 committed by Luis Díaz Más
parent d4c7e1168d
commit e1ed1df0d7
14 changed files with 327 additions and 253 deletions

View File

@ -24,18 +24,8 @@ jobs:
- name: build and compile
run: |
mkdir build && cd build && \
cmake -GNinja -DEXIV2_ENABLE_PNG=ON \
-DEXIV2_BUILD_SAMPLES=ON \
-DEXIV2_ENABLE_WEBREADY=ON \
-DEXIV2_ENABLE_CURL=ON \
-DEXIV2_ENABLE_BMFF=ON \
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON \
-DCMAKE_CXX_COMPILER=$(which clang++) \
-DEXIV2_BUILD_FUZZ_TESTS=ON \
-DEXIV2_TEAM_USE_SANITIZERS=ON \
.. && \
cmake --build . --parallel
cmake --preset linux-sanitizers -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=$(which clang++) -DEXIV2_BUILD_FUZZ_TESTS=ON -DEXIV2_BUILD_UNIT_TESTS=OFF
cmake --build build --parallel
- name: Fuzz
run: |

View File

@ -39,20 +39,8 @@ jobs:
- name: Build
run: |
cd build && \
cmake -GNinja \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DBUILD_SHARED_LIBS=${{matrix.shared_libraries}} \
-DEXIV2_BUILD_SAMPLES=ON \
-DEXIV2_ENABLE_PNG=ON \
-DEXIV2_ENABLE_WEBREADY=ON \
-DEXIV2_ENABLE_CURL=ON \
-DEXIV2_BUILD_UNIT_TESTS=ON \
-DEXIV2_ENABLE_BMFF=ON \
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON \
-DCMAKE_INSTALL_PREFIX=install \
.. && \
cmake --build . --parallel
cmake --preset base_linux -S . -B build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.shared_libraries}}
cmake --build build --parallel
- name: Install
run: |

View File

@ -37,21 +37,8 @@ jobs:
- name: Build
run: |
cd build && \
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_SHARED_LIBS=ON \
-DEXIV2_ENABLE_PNG=ON \
-DEXIV2_ENABLE_WEBREADY=ON \
-DEXIV2_ENABLE_CURL=ON \
-DEXIV2_BUILD_UNIT_TESTS=ON \
-DEXIV2_ENABLE_BMFF=ON \
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON \
-DEXIV2_BUILD_SAMPLES=ON \
-DBUILD_WITH_COVERAGE=ON \
-DCMAKE_INSTALL_PREFIX=install \
.. && \
cmake --build . --parallel
cmake --preset linux-coverage -S . -B build
cmake --build build --parallel
- name: Tests + Upload coverage
run: |
@ -78,7 +65,6 @@ jobs:
- name: install dependencies
run: |
sudo apt-get update
sudo apt-get install valgrind ninja-build
pip3 install conan==1.45.0
@ -96,9 +82,8 @@ jobs:
- name: Build
run: |
cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DEXIV2_ENABLE_PNG=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_ENABLE_CURL=ON -DEXIV2_BUILD_UNIT_TESTS=ON -DEXIV2_ENABLE_BMFF=ON -DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON -DBUILD_WITH_COVERAGE=OFF -DCMAKE_INSTALL_PREFIX=install ..
cmake --build . --parallel
cmake --preset linux-release -S . -B build
cmake --build build --parallel
- name: Tests with valgrind
run: |
@ -132,22 +117,8 @@ jobs:
- name: Build
run: |
cd build && \
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DEXIV2_BUILD_SAMPLES=ON \
-DEXIV2_ENABLE_PNG=ON \
-DEXIV2_ENABLE_WEBREADY=ON \
-DEXIV2_ENABLE_CURL=ON \
-DEXIV2_BUILD_UNIT_TESTS=ON \
-DEXIV2_ENABLE_BMFF=ON \
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON \
-DBUILD_WITH_COVERAGE=OFF \
-DEXIV2_TEAM_USE_SANITIZERS=ON \
-DCMAKE_INSTALL_PREFIX=install \
.. && \
cmake --build . --parallel
cmake --preset linux-sanitizers -S . -B build
cmake --build build --parallel
- name: Tests
run: |
@ -163,8 +134,7 @@ jobs:
- name: install dependencies
run: |
sudo apt-get update
sudo apt-get install valgrind doxygen graphviz gettext
sudo apt-get install valgrind doxygen graphviz gettext ninja-build
pip3 install conan==1.45.0
- name: Conan common config
@ -181,22 +151,8 @@ jobs:
- name: Build
run: |
cd build && \
cmake -DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DEXIV2_BUILD_SAMPLES=ON \
-DEXIV2_ENABLE_PNG=ON \
-DEXIV2_ENABLE_WEBREADY=ON \
-DEXIV2_ENABLE_CURL=ON \
-DEXIV2_BUILD_UNIT_TESTS=ON \
-DEXIV2_ENABLE_BMFF=ON \
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON \
-DBUILD_WITH_COVERAGE=ON \
-DEXIV2_BUILD_DOC=ON \
-DEXIV2_ENABLE_NLS=ON \
-DCMAKE_CXX_FLAGS="-DEXIV2_DEBUG_MESSAGES" \
.. && \
cmake --build . --parallel
cmake --preset linux-release -S . -B build -DEXIV2_BUILD_DOC=ON -DCMAKE_CXX_FLAGS="-DEXIV2_DEBUG_MESSAGES"
cmake --build build --parallel
- name: Generate documentation
run: |

View File

@ -40,19 +40,7 @@ jobs:
- name: Configure
run: |
cd build && \
cmake -DCMAKE_BUILD_TYPE=Debug \
-DBUILD_SHARED_LIBS=ON \
-DEXIV2_ENABLE_PNG=ON \
-DEXIV2_ENABLE_WEBREADY=ON \
-DEXIV2_ENABLE_CURL=ON \
-DEXIV2_BUILD_UNIT_TESTS=ON \
-DEXIV2_ENABLE_BMFF=ON \
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON \
-DBUILD_WITH_COVERAGE=ON \
-DCMAKE_INSTALL_PREFIX=install \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
.. \
cmake --preset linux-debug-NoConan -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Static Analysis
env:

View File

@ -33,21 +33,8 @@ jobs:
- name: Build
run: |
mkdir build && cd build && \
cmake -GNinja \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DBUILD_SHARED_LIBS=${{matrix.shared_libraries}} \
-DEXIV2_BUILD_SAMPLES=ON \
-DEXIV2_ENABLE_PNG=ON \
-DEXIV2_ENABLE_WEBREADY=ON \
-DEXIV2_ENABLE_CURL=ON \
-DEXIV2_BUILD_UNIT_TESTS=ON \
-DEXIV2_ENABLE_BMFF=ON \
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON \
-DCMAKE_INSTALL_PREFIX=install \
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" \
.. && \
cmake --build . --parallel
cmake --preset base_mac -S . -B build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.shared_libraries}} -DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations"
cmake --build build --parallel
- name: Install
run: |

View File

@ -28,22 +28,8 @@ jobs:
- name: Build
run: |
mkdir build && cd build && \
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DEXIV2_BUILD_SAMPLES=ON \
-DEXIV2_ENABLE_PNG=ON \
-DEXIV2_ENABLE_WEBREADY=ON \
-DEXIV2_ENABLE_CURL=ON \
-DEXIV2_BUILD_UNIT_TESTS=ON \
-DEXIV2_ENABLE_BMFF=ON \
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON \
-DBUILD_WITH_COVERAGE=OFF \
-DEXIV2_TEAM_USE_SANITIZERS=ON \
-DCMAKE_INSTALL_PREFIX=install \
.. && \
cmake --build . --parallel
cmake --preset base_mac -S . -B build -DEXIV2_TEAM_USE_SANITIZERS=ON
cmake --build build --parallel
- name: Tests
run: |

View File

@ -73,23 +73,12 @@ jobs:
- name: Build
run: |
cmake -GNinja `
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} `
-DBUILD_SHARED_LIBS=${{matrix.shared_libraries}} `
-DEXIV2_ENABLE_NLS=OFF `
-DEXIV2_ENABLE_WEBREADY=ON `
-DEXIV2_ENABLE_BMFF=ON `
-DEXIV2_BUILD_UNIT_TESTS=ON `
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON `
-DCMAKE_INSTALL_PREFIX=install `
-S . -B build && `
cmake --preset base_windows -S . -B build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.shared_libraries}}
cmake --build build --parallel
- name: Install
run: |
cd build
cmake --install .
tree /f install
cmake --install build
- name: Test
if: ${{matrix.platform == 'x64'}}
@ -122,26 +111,26 @@ jobs:
install: >-
base-devel
pacboy: >-
toolchain:p
cc:p
gcc-libs:p
libwinpthread:p
cmake:p
ninja:p
expat:p
gettext:p
gtest:p
libiconv:p
zlib:p
curl:p
- name: Build
run: |
cmake -G"MSYS Makefiles" \
-DCMAKE_CXX_FLAGS=-Wno-deprecated \
cmake --preset base_windows -S . -B build \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DBUILD_SHARED_LIBS=${{matrix.shared_libraries}} \
-DEXIV2_BUILD_SAMPLES=ON \
-DEXIV2_ENABLE_NLS=OFF \
-DEXIV2_ENABLE_WEBREADY=ON \
-DEXIV2_ENABLE_BMFF=ON \
-DEXIV2_BUILD_UNIT_TESTS=ON \
-S . -B build && \
-DCONAN_AUTO_INSTALL=OFF \
-DCMAKE_CXX_FLAGS=-Wno-deprecated \
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=OFF
cmake --build build --parallel
- name: Test
@ -176,6 +165,7 @@ jobs:
gcc-g++
cmake
ninja
libcurl-devel
libexpat-devel
libxml2-devel
libxslt-devel
@ -190,6 +180,7 @@ jobs:
-DEXIV2_ENABLE_NLS=OFF \
-DEXIV2_ENABLE_WIN_UNICODE=OFF \
-DEXIV2_ENABLE_WEBREADY=ON \
-DEXIV2_ENABLE_CURL=ON \
-DEXIV2_ENABLE_BMFF=ON \
-DEXIV2_BUILD_UNIT_TESTS=OFF \
-S . -B build && \

View File

@ -48,28 +48,9 @@ jobs:
conan profile update settings.compiler.version=17 default
conan config set storage.path=$Env:GITHUB_WORKSPACE/conanCache
- name: Run Conan
run: |
md build
cd build
conan profile list
conan install .. --build missing
- name: Build
run: |
cmake -GNinja `
-DCMAKE_BUILD_TYPE=Release `
-DBUILD_SHARED_LIBS=ON `
-DEXIV2_BUILD_SAMPLES=ON `
-DEXIV2_ENABLE_NLS=OFF `
-DEXIV2_ENABLE_PNG=ON `
-DEXIV2_ENABLE_WEBREADY=ON `
-DEXIV2_ENABLE_BMFF=ON `
-DEXIV2_BUILD_UNIT_TESTS=ON `
-DEXIV2_ENABLE_WIN_UNICODE=OFF `
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON `
-DCMAKE_INSTALL_PREFIX=install .. `
-S . -B build && `
cmake --preset win-release -S . -B build
cmake --build build --parallel
@ -100,20 +81,8 @@ jobs:
- name: build and compile
run: |
cd build && \
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DEXIV2_BUILD_SAMPLES=ON \
-DEXIV2_ENABLE_PNG=ON \
-DEXIV2_ENABLE_WEBREADY=ON \
-DEXIV2_ENABLE_CURL=ON \
-DEXIV2_BUILD_UNIT_TESTS=ON \
-DEXIV2_ENABLE_BMFF=ON \
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON \
-DCMAKE_INSTALL_PREFIX=install \
.. && \
cmake --build . --parallel
cmake --preset linux-release-NoConan -S . -B build
cmake --build build --parallel
- name: Test
run: |
@ -141,21 +110,8 @@ jobs:
- name: build and compile
run: |
mkdir build && cd build && \
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DEXIV2_BUILD_SAMPLES=ON \
-DEXIV2_ENABLE_PNG=ON \
-DEXIV2_ENABLE_WEBREADY=ON \
-DEXIV2_ENABLE_CURL=ON \
-DEXIV2_BUILD_UNIT_TESTS=ON \
-DEXIV2_ENABLE_BMFF=ON \
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON \
-DCMAKE_INSTALL_PREFIX=install \
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" \
.. && \
cmake --build . --parallel
cmake --preset base_mac -S . -B build -DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations"
cmake --build build --parallel
- name: Test
run: |

View File

@ -36,20 +36,8 @@ jobs:
- name: Build
run: |
cd build && \
cmake -DCMAKE_BUILD_TYPE=Debug \
-DBUILD_SHARED_LIBS=ON \
-DEXIV2_ENABLE_PNG=ON \
-DEXIV2_ENABLE_WEBREADY=ON \
-DEXIV2_ENABLE_CURL=ON \
-DEXIV2_BUILD_UNIT_TESTS=ON \
-DEXIV2_ENABLE_BMFF=ON \
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON \
-DEXIV2_BUILD_SAMPLES=ON \
-DBUILD_WITH_COVERAGE=ON \
-DCMAKE_INSTALL_PREFIX=install \
.. && \
cmake --build .
cmake --preset linux-coverage -S . -B build
cmake --build build
- name: Tests + Upload coverage
run: |

View File

@ -39,16 +39,7 @@ jobs:
- name: Build packaged release
run: |
cmake -GNinja -S . -B build \
-DEXIV2_TEAM_PACKAGING=ON \
-DBUILD_SHARED_LIBS=ON \
-DEXIV2_ENABLE_WEBREADY=OFF \
-DEXIV2_ENABLE_NLS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DEXIV2_ENABLE_BMFF=ON \
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DEXIV2_BUILD_DOC=ON
cmake --preset linux-all -S . -B build -DEXIV2_TEAM_PACKAGING=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
cmake --build build -t doc
cmake --build build -t package
@ -137,16 +128,7 @@ jobs:
- name: Build packaged release
run: |
cmake -GNinja -S . -B build `
-DEXIV2_TEAM_PACKAGING=ON `
-DBUILD_SHARED_LIBS=ON `
-DEXIV2_ENABLE_WEBREADY=OFF `
-DEXIV2_ENABLE_NLS=OFF `
-DCMAKE_BUILD_TYPE=Release `
-DEXIV2_ENABLE_BMFF=ON `
-DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON `
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON `
-DEXIV2_BUILD_DOC=ON
cmake --preset win-release -S . -B build -DEXIV2_TEAM_PACKAGING=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DEXIV2_BUILD_DOC=ON
cmake --build build -t doc
cmake --build build -t package

1
.gitignore vendored
View File

@ -25,5 +25,6 @@ doc/html
contrib/vms/.vagrant
/.vscode
.vs/
CMakeUserPresets.json
*cppcheck*

149
CMakePresets.json Normal file
View File

@ -0,0 +1,149 @@
{
"version": 3,
"configurePresets": [
{
"name": "base_ninja",
"description": "Base preset to use ninja as generator",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-${presetName}",
"installDir": "${sourceDir}/build-${presetName}/install",
"cacheVariables": {
"BUILD_SHARED_LIBS": true,
"CONAN_AUTO_INSTALL": true,
"EXIV2_BUILD_SAMPLES": true,
"EXIV2_ENABLE_WEBREADY": true,
"EXIV2_ENABLE_CURL": true,
"EXIV2_ENABLE_PNG": true,
"EXIV2_ENABLE_BMFF": true,
"EXIV2_BUILD_UNIT_TESTS": true,
"EXIV2_TEAM_WARNINGS_AS_ERRORS": true,
"EXIV2_ENABLE_NLS": false
}
},
{
"name": "base_windows",
"description": "Base preset for Windows (specially useful for CI jobs)",
"displayName": "Base preset for Windows (specially useful for CI jobs)",
"inherits": "base_ninja",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "base_linux",
"description": "Base preset for Linux",
"displayName": "Base preset for Linux with default compiler: GCC (specially useful for CI jobs)",
"inherits": "base_ninja",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"cacheVariables": {
"BUILD_WITH_CCACHE": true
}
},
{
"name": "base_mac",
"description": "Base preset for macOS (no conan usage)",
"displayName": "Base preset for macOS with default compiler: AppleClang (specially useful for CI jobs)",
"inherits": "base_ninja",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CONAN_AUTO_INSTALL": false
}
},
{
"name": "msvc",
"displayName": "Visual Studio cl toolchain (also usable from VS Code)",
"inherits": "base_windows",
"architecture": {
"value": "x64",
"strategy": "external"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "win-debug",
"displayName": "Windows Debug with configured architecture",
"description": "Sets Debug build type with the preloaded Visual Studio Environment",
"inherits": "base_windows",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "win-release",
"displayName": "Windows Release with configured architecture",
"description": "Sets Release build type with the preloaded Visual Studio Environment",
"inherits": "base_windows",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "linux-debug",
"displayName": "Linux Debug (Ninja Generator) with default architecture",
"inherits": "base_linux",
"cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" }
},
{
"name": "linux-release",
"displayName": "Linux Release (Ninja Generator) with default architecture",
"inherits": "base_linux",
"cacheVariables": { "CMAKE_BUILD_TYPE": "Release" }
},
{
"name": "linux-debug-NoConan",
"displayName": "Same as linux-debug but without automatic conan execution",
"inherits": "linux-debug",
"cacheVariables": { "CONAN_AUTO_INSTALL": false }
},
{
"name": "linux-release-NoConan",
"displayName": "Same as linux-release but without automatic conan execution",
"inherits": "linux-release",
"cacheVariables": { "CONAN_AUTO_INSTALL": false }
},
{
"name": "linux-coverage",
"displayName": "Same as linux-debug-NoConan with coverage enabled",
"inherits": "linux-debug-NoConan",
"cacheVariables": { "BUILD_WITH_COVERAGE": true }
},
{
"name": "linux-sanitizers",
"displayName": "Same as linux-debug-NoConan with sanitizers enabled",
"inherits": "linux-debug-NoConan",
"cacheVariables": { "EXIV2_TEAM_USE_SANITIZERS": true }
},
{
"name": "linux-all",
"displayName": "Same as linux-release-NoConan and with rest of things enabled (doc + NLS)",
"description": "requires installation of packages: doxygen graphviz gettext",
"inherits": "linux-release-NoConan",
"cacheVariables": {
"EXIV2_ENABLE_NLS": true,
"EXIV2_BUILD_DOC": true
}
}
]
}

143
README.md
View File

@ -32,6 +32,7 @@ The file ReadMe.txt in a build bundle describes how to install the library on th
- [Building, Installing, Using and Uninstalling Exiv2](#B_I_U)
- [Build, Install, Use and Uninstall Exiv2 on a UNIX-like system](#B_I_U_Unix)
- [Build and Install Exiv2 with Visual Studio](#B_I_U_VisualStudio)
- [Configure the project with CMake presets](#CMakePresets)
- [Build Options](#BuildOptions)
- [Dependencies](#Dependencies)
- [Building and linking your code with Exiv2](#BuildAndLinkYourCode)
@ -126,7 +127,7 @@ path.
## Build and Install Exiv2 with Visual Studio
We recommend that you use conan to download the Exiv2 external dependencies on Windows. On other platforms (macOS, Linux and others), traditionally the platform package managers have been used. These are discussed at [Platform Notes](#PlatformNotes). The options to configure and compile the project using Visual Studio are similar to UNIX like systems.
We recommend to use conan to download the Exiv2 external dependencies on Windows. On other platforms (macOS, Linux and others), traditionally the platform package managers have been used. However, conan can be used in any platform/architecture to bring the project dependencies. These are discussed at [Platform Notes](#PlatformNotes). The options to configure and compile the project using Visual Studio are similar to UNIX like systems.
See [README-CONAN](README-CONAN.md) for more information about Conan.
When you build, you may install with the following command.
@ -136,6 +137,99 @@ When you build, you may install with the following command.
```
This will create and copy the exiv2 build artefacts to `%ProgramFiles%/exiv2`. To be able to run the `exiv2` command line application from any terminal you should modify your path to include `%ProgramFiles%/exiv2/bin`.
[TOC](#TOC)
<div id="CMakePresets">
## Configure the project with the CMake presets
CMake presets (see documentation [here](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html)) were added recently to the project to ease the CMake configuration process for typical configurations. The presets are defined in the file `CMakePresets.json` and they can be used from the terminal or interpreted by different IDEs. Please note that one needs to use a recent version of CMake (>= 3.21) supporting the presets feature.
One can list the available presets using the `--list-presets` option:
```bash
# Running the command from a Windows terminal
$ cmake --list-presets
Available configure presets:
"msvc" - Visual Studio cl toolchain (also usable from VS Code)
"win-debug" - Windows Debug with configured architecture
"win-release" - Windows Release with configured architecture
# Running the command from a Linux terminal
$ cmake --list-presets
Available configure presets:
"linux-debug" - Linux Debug with default architecture
"linux-release" - Linux Release with default architecture
```
The project configuration with a specific preset can be choosen with the CMake `--preset` option. In the following terminal output we comment out some interesting things happening during the project configuration:
```bash
# Configuring the project using a preset
$ cmake --preset win-release
Preset CMake variables:
# Note that with the usage of a preset, we pass many different options to CMake.
BUILD_SHARED_LIBS:BOOL="TRUE"
CMAKE_BUILD_TYPE="Release"
CMAKE_INSTALL_PREFIX:PATH="C:/dev/personal/exiv2/build-win-release/install"
# A build & install directory are configured with the preset
CONAN_AUTO_INSTALL:BOOL="TRUE"
EXIV2_BUILD_SAMPLES:BOOL="TRUE"
EXIV2_BUILD_UNIT_TESTS:BOOL="TRUE"
EXIV2_ENABLE_BMFF:BOOL="TRUE"
EXIV2_ENABLE_CURL:BOOL="TRUE"
EXIV2_ENABLE_NLS:BOOL="FALSE"
EXIV2_ENABLE_PNG:BOOL="TRUE"
EXIV2_ENABLE_WEBREADY:BOOL="TRUE"
EXIV2_TEAM_WARNINGS_AS_ERRORS:BOOL="TRUE"
# Conan can be automatically detected in your system and it is run automatically to bring the
# project dependencies
-- Conan: Detected VS runtime: MD
-- Conan: checking conan executable
-- Conan: Found program C:/dev/envs/conan/Scripts/conan.exe
-- Conan: Version found Conan version 1.47.0
-- Conan executing: C:/dev/envs/conan/Scripts/conan.exe install .. --remote conancenter --build missing --options webready=True --settings arch=x86_64 --settings build_type=Release --settings compiler=Visual Studio --settings compiler.version=17 --settings compiler.runtime=MD
...
# CMake finds the project dependencies which were automatically handled by conan
-- Conan: Using autogenerated FindZLIB.cmake
-- Library zlib found C:/Users/luis/.conan/data/zlib/1.2.11/_/_/package/-- Conan: Using autogenerated FindCURL.cmake
-- Library libcurl_imp found C:/Users/luis/.conan/data/libcurl/7.79.0/_/_/package/
...
# CMake finish the project configuration and prints a report
-- Install prefix: C:/dev/personal/exiv2/build-win-release/install
-- ------------------------------------------------------------------
-- CMake Generator: Ninja
-- CMAKE_BUILD_TYPE: Release
-- Compiler info: MSVC (C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.30.30705/bin/Hostx64/x64/cl.exe) ; version: 19.30.30705.0
-- CMAKE_CXX_STANDARD:17
-- --- Compiler flags ---
-- General: /DWIN32 /D_WINDOWS /W3 /GR /EHsc
/MP
/utf-8
/WX
-- Extra:
-- Debug: /MDd /Zi /Ob0 /Ox /Zo
-- Release: /MD /O2 /DNDEBUG
-- RelWithDebInfo: /MD /Zi /O2 /DNDEBUG
-- MinSizeRel: /MD /O1 /DNDEBUG
-- --- Linker flags ---
-- General: /machine:x64 /WX
-- Debug: /debug /INCREMENTAL
-- Release: /INCREMENTAL:NO
-- RelWithDebInfo: /debug /INCREMENTAL
-- MinSizeRel: /INCREMENTAL:NO
--
...
-- Build files have been written to: C:/dev/personal/exiv2/build-win-release
```
Note that the usage of CMake presets allow the project contributors to use the same set of options easily in different environments (using terminal, IDEs or CI).
[TOC](#TOC)
<div id="BuildOptions">
@ -145,7 +239,7 @@ There are two groups of CMake options which are relevant to the project: global
| Options | Purpose (_default_) |
|:------------- |:------------- |
| CMAKE\_INSTALL\_PREFIX<br/>CMAKE\_BUILD\_TYPE<br/>BUILD\_SHARED\_LIBS | Where to install on your computer _**(/usr/local)**_<br/>Type of build _**(Release)**_ See: [Debugging Exiv2](#Debugging) <br/>Build exiv2lib as shared or static _**(On)**_ |
| CMAKE\_INSTALL\_PREFIX<br/>CMAKE\_BUILD\_TYPE<br/>BUILD\_SHARED\_LIBS | Where to install on your computer _**(/usr/local)**_<br/>Type of build _**(Release)**_ See: [Debugging Exiv2](#Debugging) <br/>Build exiv2lib as SHARED or STATIC |
Options defined at `exiv2/CMakeLists.txt` include:
@ -160,10 +254,10 @@ option( EXIV2_ENABLE_BMFF "Build with BMFF support" ON
577 rmills@rmillsmm:~/gnu/github/exiv2/exiv2 $
```
Options are defined on the CMake command-line:
Using the command-line, these variables can be set/updated using the option `-D`:
```bash
$ cmake -DBUILD_SHARED_LIBS=On -DEXIV2_ENABLE_NLS=Off
$ cmake -DBUILD_SHARED_LIBS=ON -DEXIV2_ENABLE_NLS=OFF
```
[TOC](#TOC)
@ -175,9 +269,9 @@ The following Exiv2 features require external libraries:
| Feature | Package | Default | To change default | Availability |
|:-------------------------- |:-------- |:--------:| :---------------------------- |:----------- |
| PNG image support | zlib | ON | -DEXIV2\_ENABLE\_PNG=Off | [http://zlib.net/](http://zlib.net/) |
| XMP support | expat | ON | -DEXIV2\_ENABLE\_XMP=Off | [http://expat.sourceforge.net](http://expat.sourceforge.net)/<br/>Use _**Expat 2.2.6**_ and later |
| Natural language system | gettext | OFF | -DEXIV2\_ENABLE\_NLS=On | [http://www.gnu.org/software/gettext/](http://www.gnu.org/software/gettext/) |
| PNG image support | zlib | ON | -DEXIV2\_ENABLE\_PNG=OFF | [http://zlib.net/](http://zlib.net/) |
| XMP support | expat | ON | -DEXIV2\_ENABLE\_XMP=OFF | [http://expat.sourceforge.net](http://expat.sourceforge.net)/<br/>Use _**Expat 2.2.6**_ and later |
| Natural language system | gettext | OFF | -DEXIV2\_ENABLE\_NLS=ON | [http://www.gnu.org/software/gettext/](http://www.gnu.org/software/gettext/) |
| Character set conversion | libiconv | | Disabled for Visual Studio.<br>Linked when installed on UNIX like platforms. | [https://www.gnu.org/software/libiconv/](https://www.gnu.org/software/libiconv/) |
On UNIX systems, you may install the dependencies using the distribution's package management system. Install the
@ -297,7 +391,7 @@ Localisation is supported on a UNIX-like platform: Linux, macOS, Cygwin and Min
Crowdin have provided Exiv2 with a free open-source license to use their services. The Exiv2 localisation project is located at [https://crowdin.com/project/exiv2](https://crowdin.com/project/exiv2). You will also need to register to have a free user account on Crowdin. The Crowdin setup is discussed here: [https://github.com/Exiv2/exiv2/issues/1510](https://github.com/Exiv2/exiv2/issues/1510). It is recommended that you coordinate with Leonardo before contributing localisation changes on Crowdin. You can contact Leonardo by via GitHub.
To build localisation support, use the CMake option `-DEXIV2_ENABLE_NLS=On`. You must install the `gettext` package with your package manager or from source. The `gettext` package is available from [http://www.gnu.org/software/gettext/](http://www.gnu.org/software/gettext/) and includes the library `libintl` and utilities to build localisation files. If CMake produces error messages which mention libintl or gettext, you should verify that the package `gettext` has been correctly built and installed.
To build localisation support, use the CMake option `-DEXIV2_ENABLE_NLS=ON`. You must install the `gettext` package with your package manager or from source. The `gettext` package is available from [http://www.gnu.org/software/gettext/](http://www.gnu.org/software/gettext/) and includes the library `libintl` and utilities to build localisation files. If CMake produces error messages which mention libintl or gettext, you should verify that the package `gettext` has been correctly built and installed.
You must install the build to test localisation. This ensures that the localisation message files can be found at run-time. You cannot test localisation in the directory `build\bin`.
@ -386,11 +480,11 @@ $
Building documentation requires installing special tools. You will probably prefer to
read the documentation on-line from the project website: https://exiv2.org
To build documentation, use the CMake option **`-DEXIV2_BUILD_DOC=On`**.
To build documentation, use the CMake option **`-DEXIV2_BUILD_DOC=ON`**.
Additionally, you will require an additional build step to actually build the documentation.
```bash
$ cmake ..options.. -DEXIV2_BUILD_DOC=On
$ cmake ..options.. -DEXIV2_BUILD_DOC=ON
$ cmake --build . --target doc
```
@ -437,7 +531,7 @@ When the Exiv2 websites are updated, the generated tag webpages are reformatted
## Building Exiv2 Packages
To enable the building of Exiv2 packages, use the CMake option `-DEXIV2_TEAM_PACKAGING=On`.
To enable the building of Exiv2 packages, use the CMake option `-DEXIV2_TEAM_PACKAGING=ON`.
You should not build Exiv2 Packages. This feature is intended for use by Team Exiv2 to create Platform and Source Packages on the buildserver.
@ -451,7 +545,7 @@ Create and build exiv2 for your platform.
$ git clone https://github.com/exiv2/exiv2
$ mkdir -p exiv2/build
$ cd exiv2/build
$ cmake .. -G "Unix Makefiles" -DEXIV2_TEAM_PACKAGING=On
$ cmake .. -G "Unix Makefiles" -DEXIV2_TEAM_PACKAGING=ON
...
-- Build files have been written to: .../build
$ cmake --build . --config Release
@ -603,19 +697,19 @@ Installing and using ccache (and other similar utilities), is platform dependent
$ sudo apt install --yes ccache
```
To build with ccache, use the CMake option **-DBUILD\_WITH\_CCACHE=On**
To build with ccache, use the CMake option **-DBUILD\_WITH\_CCACHE=ON**
```bash
$ cd <exiv2dir>
$ mkdir build ; cd build ; cd build
$ cmake .. -G "Unix Makefiles" -DBUILD_WITH_CCACHE=On
$ cmake .. -G "Unix Makefiles" -DBUILD_WITH_CCACHE=ON
$ cmake --build .
# Build again to appreciate the performance gain
$ cmake --build . --target clean
$ cmake --build .
```
Due to the way in which ccache is installed in Fedora (and other Linux distros), ccache effectively replaces the compiler. A default build or **-DBUILD\_WITH\_CCACHE=Off** is not effective and the environment variable CCACHE_DISABLE is required to disable ccache. [https://github.com/Exiv2/exiv2/issues/361](https://github.com/Exiv2/exiv2/issues/361)
Due to the way in which ccache is installed in Fedora (and other Linux distros), ccache effectively replaces the compiler. A default build or **-DBUILD\_WITH\_CCACHE=OFF** is not effective and the environment variable CCACHE_DISABLE is required to disable ccache. [https://github.com/Exiv2/exiv2/issues/361](https://github.com/Exiv2/exiv2/issues/361)
[TOC](#TOC)
<div id="ThreadSafety">
@ -707,10 +801,9 @@ $ make
Note, you may wish to choose to build with optional features and/or build static libraries. To do this, request appropriately on the mingw64-cmake command:
```bash
$ mingw64-cmake .. -DEXIV2_TEAM_EXTRA_WARNINGS=On \
-DEXIV2_ENABLE_WEBREADY=On \
-DEXIV2_ENABLE_WIN_UNICODE=On \
-DBUILD_SHARED_LIBS=Off
$ mingw64-cmake .. -DEXIV2_TEAM_EXTRA_WARNINGS=ON \
-DEXIV2_ENABLE_WEBREADY=ON \
-DBUILD_SHARED_LIBS=OFF
```
The options available for cross-compiling are the same as provided for all builds. See: [Build Options](#BuildOptions)
@ -773,7 +866,7 @@ You will find that 3 tests fail at the end of the test suite. It is safe to ign
## Static and Shared Libraries
You can build either static or shared libraries. Both can be linked with either static or shared run-time libraries. You specify the shared/static with the option `-BUILD_SHARED_LIBS=On|Off` You specify the run-time with the option `-DEXIV2_ENABLE_DYNAMIC_RUNTIME=On|Off`. The default for both options default is On. So you build shared and use the shared libraries which are `.dll` on Windows (msvc, Cygwin and MinGW/msys), `.dylib` on macOS and `.so` on Linux and UNIX.
You can build either static or shared libraries. Both can be linked with either static or shared run-time libraries. You specify the shared/static with the option `-BUILD_SHARED_LIBS=ON|OFF` You specify the run-time with the option `-DEXIV2_ENABLE_DYNAMIC_RUNTIME=ON|OFF`. The default for both options default is ON. So you build shared and use the shared libraries which are `.dll` on Windows (msvc, Cygwin and MinGW/msys), `.dylib` on macOS and `.so` on Linux and UNIX.
CMake creates your build artefacts in the directories `bin` and `lib`. The `bin` directory contains your executables and .DLLs. The `lib` directory contains your static libraries. When you install exiv2, the build artefacts are copied to your system's prefix directory which by default is `/usr/local/`. If you wish to test and use your build without installing, you will have to set you PATH appropriately. Linux/Unix users should also set `LD_LIBRARY_PATH` and macOS users should set `DYLD_LIBRARY_PATH`.
@ -806,13 +899,13 @@ This is discussed: [https://github.com/Exiv2/exiv2/issues/1230](https://github.c
**Attention is drawn to the possibility that bmff support may be the subject of patent rights. _Exiv2 shall not be held responsible for identifying any or all such patent rights. Exiv2 shall not be held responsible for the legal consequences of the use of this code_.**
Access to the bmff code is guarded in two ways. Firstly, you have to build the library with the CMake option: `-DEXIV2_ENABLE_BMFF=On`. Secondly, the application must enable bmff support at run-time by calling the following function.
Access to the bmff code is guarded in two ways. Firstly, you have to build the library with the CMake option: `-DEXIV2_ENABLE_BMFF=ON`. Secondly, the application must enable bmff support at run-time by calling the following function.
```cpp
EXIV2API bool enableBMFF(bool enable);
```
The return value from `enableBMFF()` is true if the library has been build with bmff support (CMake option -DEXIV2_ENABLE_BMFF=On).
The return value from `enableBMFF()` is true if the library has been build with bmff support (CMake option -DEXIV2_ENABLE_BMFF=ON).
Applications may wish to provide a preference setting to enable bmff support and thereby place the responsibility for the use of this code with the user of the application.
@ -928,7 +1021,7 @@ The Variable EXIV2\_PORT or EXIV2\_HTTP can be set to None to skip http tests.
You can run tests directly from the build:
```bash
$ cmake .. -G "Unix Makefiles" -DEXIV2_BUILD_UNIT_TESTS=On
$ cmake .. -G "Unix Makefiles" -DEXIV2_BUILD_UNIT_TESTS=ON
... lots of output and build summary ...
$ cmake --build .
... lots of output ...
@ -993,7 +1086,7 @@ As a summary, the procedure is:
c:\...\exiv2>mkdir build
c:\...\exiv2>cd build
c:\...\exiv2\build>conan install .. --build missing --profile msvc2019Release
c:\...\exiv2\build>cmake .. -DEXIV2_BUILD_UNIT_TESTS=On -G "Visual Studio 16 2019"
c:\...\exiv2\build>cmake .. -DEXIV2_BUILD_UNIT_TESTS=ON -G "Visual Studio 16 2019"
c:\...\exiv2\build>cmake --build . --config Release
... lots of output from compiler and linker ...
c:\...\exiv2\build>ctest -C Release
@ -1012,7 +1105,7 @@ set EXIV2_PORT=
## Unit Tests
The code for the unit tests is in `<exiv2dir>/unitTests`. To include unit tests in the build, use the *CMake* option `-DEXIV2_BUILD_UNIT_TESTS=On`.
The code for the unit tests is in `<exiv2dir>/unitTests`. To include unit tests in the build, use the *CMake* option `-DEXIV2_BUILD_UNIT_TESTS=ON`.
There is a discussion on the web about installing GTest: [https://github.com/Exiv2/exiv2/issues/575](https://github.com/Exiv2/exiv2/issues/575)

View File

@ -1,5 +1,24 @@
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
if (CONAN_AUTO_INSTALL)
# Download automatically the cmake-conan integration file
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake"
TLS_VERIFY ON)
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_cmake_autodetect(settings)
conan_cmake_install(PATH_OR_REFERENCE ..
BUILD missing
REMOTE conancenter
OPTIONS webready=True
SETTINGS ${settings})
endif()
if (APPLE)
# On Apple, we use the conan cmake_paths generator
if (EXISTS ${CMAKE_BINARY_DIR}/conan_paths.cmake)