Skip to content
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

CMake target for creating local coverage reports #1640

Merged
merged 2 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ mark_as_advanced(

option( BUILD_WITH_CCACHE "Use ccache to speed up compilations" OFF )
option( BUILD_WITH_COVERAGE "Add compiler flags to generate coverage stats" OFF )
include(cmake/gcovr.cmake REQUIRED)

set( PACKAGE_BUGREPORT "http://github.com/exiv2/exiv2" )
set( PACKAGE_URL "https://exiv2.org")
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -745,20 +745,20 @@ You will find that 3 tests fail at the end of the test suite. It is safe to ign

### 2.17 Building with C++11 and other compilers

Exiv2 uses the default compiler for your system. Exiv2 v0.27 was written to the C++ 1998 standard and uses `auto_ptr`. The C++11 and C++14 compilers will issue deprecation warnings about auto\_ptr. As _auto\_ptr support has been removed from C++17, you cannot build Exiv2 v0.27 with C++17 or later compilers._ Exiv2 v1.0 and later do not use `auto_ptr` and will build with all modern C++ Standard Compilers.
Exiv2 uses the default compiler for your system. Exiv2 v0.27 was written to the C++ 1998 standard and uses `auto_ptr`. The C++11 and C++14 compilers will issue deprecation warnings about `auto_ptr`. As `auto_ptr` support has been removed from C++17, you cannot build Exiv2 v0.27 with C++17 or later compilers._ Exiv2 v1.0 and later do not use `auto_ptr` and will require a compiler compliant with the C++11 Standard.

To build with C++11:
To build Exiv2 v0.27.X with C++11:

```bash
$ cd <exiv2dir>
$ mkdir build ; cd build
$ cmake .. -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_FLAGS=-Wno-deprecated
$ make
cd <exiv2dir>
mkdir build ; cd build
cmake .. -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_FLAGS=-Wno-deprecated
make
```

The option -DCMAKE\_CXX\_STANDARD=11 specifies the C++ Language Standard. Possible values are 98, 11 or 14.
The option -DCMAKE\_CXX\_STANDARD=11 specifies the C++ Language Standard. Possible values are 98, 11, 14, 17 or 20.

The option -DCMAKE\_CXX\_FLAGS=-Wno-deprecated suppresses warnings from C++11 concerning auto\_ptr. The compiler will issue deprecation warnings about video, eps and ssh code in Exiv2 v0.27. This is intentional. These features of Exiv2 will not be available in Exiv2 v1.0.
The option -DCMAKE\_CXX\_FLAGS=-Wno-deprecated suppresses warnings from C++11 concerning `auto_ptr`. The compiler will issue deprecation warnings about video, eps and ssh code in Exiv2 v0.27. This is intentional. These features of Exiv2 will not be available in Exiv2 v1.0.

**Caution:** Visual Studio users should not use -DCMAKE\_CXX\_FLAGS=-Wno-deprecated.

Expand Down
20 changes: 20 additions & 0 deletions cmake/gcovr.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Intentd usage
# cmake -DBUILD_WITH_COVERAGE=yes ../
# make -j
# make tests
# make coverage

if(BUILD_WITH_COVERAGE)
find_program (GCOVR gcovr)

if(GCOVR)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/coverage_output )
add_custom_command(OUTPUT _run_gcovr_parser
POST_BUILD
COMMAND ${GCOVR} --root ${CMAKE_SOURCE_DIR} --object-dir=${CMAKE_BINARY_DIR} --html --html-details -o coverage_output/coverage.html
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target (coverage DEPENDS _run_gcovr_parser)
endif()

endif(BUILD_WITH_COVERAGE)