-
Notifications
You must be signed in to change notification settings - Fork 282
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
Fix c++11 0.27 #1194
Fix c++11 0.27 #1194
Conversation
cmake/compilerFlags.cmake
Outdated
@@ -1,5 +1,9 @@ | |||
# These flags applies to exiv2lib, the applications, and to the xmp code | |||
|
|||
if ( EXIV2_BUILD_USE_C++11 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we wound need to following. Replace these lines by:
if ( EXIV2_BUILD_USE_C++11 )
set(CMAKE_CXX_STANDARD 11)
else()
set(CMAKE_CXX_STANDARD 98)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
And more important is to remove all the usages of:
target_compile_features(XXX PRIVATE cxx_std_98)
cmake/compilerFlags.cmake
Outdated
@@ -90,6 +89,10 @@ if ( MINGW OR UNIX OR MSYS ) # MINGW, Linux, APPLE, CYGWIN | |||
endif() | |||
endif() | |||
endif() | |||
if ( EXIV2_BUILD_USE_C++11 ) | |||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, replace the usage of CMAKE_CXX_FLAGS
by the more appropriate usage of add_compile_options
:
add_compile_options(-Wno-deprecated)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed that 100%. I don't mess with the compile_options for -Wno-deprecated
The user can pass that from the command when required. And that's what I've documented in README.md.
include/exiv2/config.h
Outdated
#include <unistd.h> | ||
template <typename T> | ||
using auto_ptr = std::unique_ptr<T>; | ||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a clever trick, I did not think about that.
I think you can remove lines 103 & 104 from here. We do not need the using
instruction when not using C++11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember what using
does. I got the code from StackOverflow (in the comment).
@@ -91,10 +91,6 @@ generate_export_header(exiv2lib | |||
STATIC_DEFINE exiv2lib_STATIC | |||
) | |||
|
|||
target_compile_features(exiv2lib_int PRIVATE cxx_std_98) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some other usages of target_compile_features
in the unitTests and samples folders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got rid of all the target_compile_features
magic.
Thanks for the review @piponazo I believe I've removed every
I now understand what Mr Bruins was shouting about. We shouldn't try to dictate the tools. We only have to document how to use them! So we don't need any special magic about USE_C++11. The correct way to do this is documented in README.md as: 2.17 Building with C++11 and other compilersExiv2 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 v0.28 and later do not use auto_ptr and will build with all compilers. To generate a build with C++11: $ cd <exiv2dir>
$ mkdir build ; cd build
$ cmake .. -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_FLAGS=-Wno-deprecated
$ make The option -DCMAKE_CXX_FLAGS=-Wno-deprecated suppresses warnings from C++11 concerning auto_ptr and other deprecated features. |
This has been very useful. It shines a clear light on our release strategy from here. We should only do maintenance on 0.27-maintenance. So, we leave the auto_ptr alone. It is what it is. We should port new features/fixes in 0.27-maintenance into How does that sound to you? |
…hough this is working on 0.27-maintenance)
This pull request introduces 3 alerts when merging f1182b8 into 6e5fdb0 - view on LGTM.com new alerts:
|
README.md
Outdated
|
||
### 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 will compile with C++11 and C++14. As auto_ptr support is no longer in C++17, you cannot build with that system. Exiv2 v0.28 and later do not use auto_ptr and are fully supported with all compilers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would replace here the last part of the sentence: "supported with all compilers".
We should say that we require a C++ compiler with support for the C++11 standard.
```bash | ||
$ cd <exiv2dir> | ||
$ mkdir build ; cd build | ||
$ cmake .. -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_FLAGS=-Wno-deprecated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! This is exactly how it should be used. I did not think about it before.
Ey @clanmills this PR broke the CI in most of the services, let me know if I can help you with this. |
The CI is broken because the output log is so long with all the deprecation warnings. We should probably update the CI to use I removed the geotag related stuff from the PR, and it removed the files from the 0.27-maintenance branch. Let me get the product back together and I'll build it on the Mac Mini (macOS, Ubuntu, Cygwin, MinGW, VS2019, SunOS, FreeBSD and NetBSD). Then I'll relax. |
This is a "quick hack" to provide support for C++11 in Exiv2 v0.27.3. If the review is favourable, this can go into v0.27.3 RC2.
A "proper" fix is to port #601 to
0.27-maintenance
and I'm willing to do that if we ever do Exiv2 v0.27.4. I'm unwilling to make such a major change to the code for 0.27.3.I don't know if we need to do further "dots". The API for v0.28 is different and applications will have to adjust to build with v0.28. And we have removed features (video, ssh and eps) from 0.28.
I feel the way forward is to focus on getting 0.28 published later in 2020.
By the way, there are changes in this PR relating to samples/geotag.cpp. Those are irrelevant and should be on another branch. Git strikes again.