diff --git a/CMakeLists.txt b/CMakeLists.txt index f8cb8a4e..99e694a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,6 @@ project(exiv2 # use TWEAK to categorize the build # 0.27.3.19 = RC1 Not for release LANGUAGES CXX C ) - include(cmake/mainSetup.cmake REQUIRED) # options and their default values @@ -29,8 +28,9 @@ option( EXIV2_ENABLE_SSH "USE Libssh for SshIo (WEBREADY)" option( EXIV2_BUILD_SAMPLES "Build sample applications" ON ) option( EXIV2_BUILD_EXIV2_COMMAND "Build exiv2 command-line executable" ON ) -option( EXIV2_BUILD_UNIT_TESTS "Build unit tests" OFF ) +option( EXIV2_BUILD_UNIT_TESTS "Build unit tests" ON ) option( EXIV2_BUILD_DOC "Add 'doc' target to generate documentation" OFF ) +option( EXIV2_BUILD_USE_C++11 "Use the C++11 compiler" OFF ) # Only intended to be used by Exiv2 developers/contributors option( EXIV2_TEAM_EXTRA_WARNINGS "Add more sanity checks using compiler flags" OFF ) diff --git a/cmake/compilerFlags.cmake b/cmake/compilerFlags.cmake index e2a15abb..9a0f4565 100644 --- a/cmake/compilerFlags.cmake +++ b/cmake/compilerFlags.cmake @@ -1,5 +1,9 @@ # These flags applies to exiv2lib, the applications, and to the xmp code +if ( EXIV2_BUILD_USE_C++11 ) + set(CMAKE_CXX_STANDARD 11) +endif() + if ( MINGW OR UNIX OR MSYS ) # MINGW, Linux, APPLE, CYGWIN if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) set(COMPILER_IS_GCC ON) @@ -22,10 +26,6 @@ if ( MINGW OR UNIX OR MSYS ) # MINGW, Linux, APPLE, CYGWIN if (COMPILER_IS_GCC OR COMPILER_IS_CLANG) - # On Solaris target_compile_features(${application} PRIVATE cxx_std_98) fails to set this flag - if ( CMAKE_HOST_SOLARIS ) - add_compile_options(-std=gnu++98) - endif() # This fails under Fedora, MinGW GCC 8.3.0 and CYGWIN/MSYS 9.3.0 if (NOT (MINGW OR CMAKE_HOST_SOLARIS OR CYGWIN OR MSYS) ) @@ -58,7 +58,6 @@ if ( MINGW OR UNIX OR MSYS ) # MINGW, Linux, APPLE, CYGWIN # This seems to be causing issues in the Fedora_MinGW GitLab job #add_compile_options(-fasynchronous-unwind-tables) - if ( EXIV2_TEAM_USE_SANITIZERS ) # ASAN is available in gcc from 4.8 and UBSAN from 4.9 # ASAN is available in clang from 3.1 and UBSAN from 3.3 @@ -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") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated") + endif() endif () # http://stackoverflow.com/questions/10113017/setting-the-msvc-runtime-in-cmake diff --git a/cmake/printSummary.cmake b/cmake/printSummary.cmake index fefd709b..b3e804bd 100644 --- a/cmake/printSummary.cmake +++ b/cmake/printSummary.cmake @@ -49,6 +49,9 @@ if ( EXIV2_ENABLE_EXTERNAL_XMP ) else() OptionOutput( "XMP metadata support: " EXIV2_ENABLE_XMP ) endif() +if ( EXIV2_BUILD_USE_C++11 ) + OptionOutput("Use C++11: " EXIV2_BUILD_USE_C++11 ) +endif() OptionOutput( "Native language support: " EXIV2_ENABLE_NLS ) OptionOutput( "Conversion of Windows XP tags: " EXIV2_ENABLE_PRINTUCS2 ) OptionOutput( "Nikon lens database: " EXIV2_ENABLE_LENSDATA ) diff --git a/include/exiv2/config.h b/include/exiv2/config.h index b31ceb1f..f98896d3 100644 --- a/include/exiv2/config.h +++ b/include/exiv2/config.h @@ -93,5 +93,15 @@ typedef int pid_t; #endif ////////////////////////////////////// +// https://softwareengineering.stackexchange.com/questions/291141/how-to-handle-design-changes-for-auto-ptr-deprecation-in-c11 +#if __cplusplus >= 201103L + #include + #include + #include + template + using auto_ptr = std::unique_ptr; +#else + using std::auto_ptr; +#endif #endif // _CONFIG_H_ diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index f7c3e2a3..7628110d 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -120,7 +120,6 @@ list(APPEND APPLICATIONS remotetest) # ****************************************************************************** foreach(application ${APPLICATIONS}) target_link_libraries(${application} PRIVATE exiv2lib) - target_compile_features(${application} PRIVATE cxx_std_98) if( EXIV2_ENABLE_PNG ) target_link_libraries( ${application} PRIVATE ${ZLIB_LIBRARIES} ) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 29bbf50e..279b22a7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -91,10 +91,6 @@ generate_export_header(exiv2lib STATIC_DEFINE exiv2lib_STATIC ) -target_compile_features(exiv2lib_int PRIVATE cxx_std_98) -target_compile_features(exiv2lib PRIVATE cxx_std_98) - - # Conditional addition of sources to library targets # --------------------------------------------------------- diff --git a/src/basicio.cpp b/src/basicio.cpp index f4223f74..bd6dba00 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -80,7 +80,6 @@ typedef short nlink_t; // ***************************************************************************** // class member definitions namespace Exiv2 { - BasicIo::~BasicIo() { } diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt index 7e246a44..5c74100b 100644 --- a/unitTests/CMakeLists.txt +++ b/unitTests/CMakeLists.txt @@ -42,7 +42,6 @@ target_compile_definitions(unit_tests exiv2lib_STATIC TESTDATA_PATH="${PROJECT_SOURCE_DIR}/test/data" ) -target_compile_features(unit_tests PRIVATE cxx_std_98) if (exiv2lib_COMPILE_DEFINITIONS) target_compile_definitions(unit_tests PRIVATE ${exiv2lib_COMPILE_DEFINITIONS})