WIP. C++11 support

v0.27.3
Robin Mills 5 years ago
parent e6ee72f6b3
commit cd5512e761

@ -90,6 +90,7 @@ endif ()
# http://stackoverflow.com/questions/10113017/setting-the-msvc-runtime-in-cmake # http://stackoverflow.com/questions/10113017/setting-the-msvc-runtime-in-cmake
if(MSVC) if(MSVC)
find_program(CLCACHE name clcache.exe find_program(CLCACHE name clcache.exe
PATHS ENV CLCACHE_PATH PATHS ENV CLCACHE_PATH
PATH_SUFFIXES Scripts clcache-4.1.0 PATH_SUFFIXES Scripts clcache-4.1.0
@ -136,4 +137,36 @@ if(MSVC)
# Object Level Parallelism # Object Level Parallelism
add_compile_options(/MP) add_compile_options(/MP)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN) add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
# https://stackoverflow.com/questions/44960715/how-to-enable-stdc17-in-vs2017-with-cmake
if (MSVC_VERSION GREATER_EQUAL "1700") # VS2015 and up
include(CheckCXXCompilerFlag)
# MSVC doesn't have a setting for C++11 as it's a subset of C++14
if ( ${CMAKE_CXX_STANDARD} STREQUAL "11" OR ${CMAKE_CXX_STANDARD} STREQUAL "14" )
CHECK_CXX_COMPILER_FLAG("/std:c++14" _cpp_14)
if (_cpp_14)
add_compile_options("/std:c++14")
else()
message(WARNING "Cannot set compiler option /std:c++14")
endif()
endif()
if ( ${CMAKE_CXX_STANDARD} STREQUAL "17" )
CHECK_CXX_COMPILER_FLAG("/std:c++17" _cpp_17)
if (_cpp_17)
add_compile_options("/std:c++17")
else()
message(WARNING "Cannot set compiler option /std:c++17")
endif()
endif()
if ( ${CMAKE_CXX_STANDARD} STREQUAL "20" )
CHECK_CXX_COMPILER_FLAG("/std:c++11" _cpp_20)
if (_cpp_20)
add_compile_options("/std:c++20")
else()
message(WARNING "Cannot set compiler option /std:c++20")
endif()
endif()
# https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
add_compile_options("/Zc:__cplusplus")
endif()
endif() endif()

@ -0,0 +1,88 @@
contrib/Qt/ReadMe.txt
---------------------
Exiv2 works well with Qt. To support Qt/Windows users, a daily build of Exiv2 for MinGW/32 is provided.
To build and run commandLineTool
--------------------------------
1) Either build Exiv2/MinGW/32 as documented:
http://clanmills.com/exiv2/mingw.shtml
OR
Download and install a build from the buildserver:
http://exiv2.dyndns.org:8080/userContent/builds/Categorized/Platform/mingw/
Instructions for installing the build are in the bundle ReadMe.txt
2) Generate Makefile
/c/Users/rmills/gnu/exiv2/trunk/contrib/Qt > qmake commandLinePro.pro
3) Build commandLineTool.cpp
/c/Users/rmills/gnu/exiv2/trunk/contrib/Qt > make -B LDFLAGS=-L/usr/local/lib
4) Run commandLineTool.exe
/c/Users/rmills/gnu/exiv2/trunk/contrib/Qt > release/commandLineTool.exe
Gotchas (that I know about)
1 Set PKG_CONFIG_PATH correctly
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/lib/pkgconfig"
2 Set PATH to use the toolchain for Qt
PATH="/c/Qt/Qt5.6.0/5.6/mingw49_32/bin:/c/Qt/Qt5.6.0/Tools/mingw492_32/bin:/c/MinGW/bin:/usr/bin:/usr/local/bin:/c/cygwin64/bin:."
3 You may need to copy libstdc++-6.dll to /usr/local/bin
cp $(which libstdc++-6.dll) /usr/local/bin
4 You may have to edit commandLineTool.pro to match your environment
5 DO NOT USE Cygwin Builds
6 Do not give up.
This stuff works. You may have to work quite hard to get it working.
Don't give up. It will work.
7 If you give up with MinGW, use Visual Studio.
Running MinGW bash and setting Qt tools in the path
---------------------------------------------------
I have a batch file (mingw32.bat) to get me into MinGW.
C:\>type \Users\rmills\com\mingw32.bat
@echo off
rem ------------------
: mingw32.bat
: invoke MinGW bash
:
setlocal
set "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig"
set "INCLUDE_PATH=/usr/local/inc"
set "LIBRARY_PATH=/usr/local/lib"
set "BINARY_PATH=/usr/local/bin"
rem set "PATH=c:\MinGW\bin;c:\MinGW\msys\1.0\bin;c:\MinGW\msys\1.0\local\bin;c:\Users\rmills\com;."
set "PATH=c:\Qt\Qt5.6.0\5.6\mingw49_32\bin;c:\Qt\Qt5.6.0\Tools\mingw492_32\bin;c:\MinGW\bin;\usr\bin:\usr\local\bin;c:\cygwin64\bin;c:\Users\rmills\com;."
set "PS1=\! -32- ${PWD}> "
c:\MinGW\msys\1.0\bin\bash.exe %*%
: That's all Folks
rem ------------------
UNICODE_PATH
------------
Qt users may prefer to build Exiv2 to support UNICODE_PATH. The sample application samples/exifprint.cpp works with UNICODE_PATH.
Searching for more information about Qt, MinGW and UNICODE_PATH
---------------------------------------------------------------
These matters are occasionally discussed on the forum. Please search to read discussions.
You will probably find the following helpful:
http://dev.exiv2.org/boards/3/topics/2311?r=2312#message-2312
http://dev.exiv2.org/issues/1169
http://dev.exiv2.org/boards/3/topics/2705
However there have been others and there will be more in future.
Robin Mills
http://clanmills.com
2016-09-19

@ -0,0 +1,15 @@
QT += core
QT -= gui
TARGET = commandLineTool
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
win32 {
INCLUDEPATH += $$quote(c:/Qt/5.14.2/mingw73_64/include)
INCLUDEPATH += /usr/local/include
LIBS += -L$$quote(c:/Qt/5.14.2/mingw73_64/include) -L/usr/local/lib -lexiv2
}

@ -0,0 +1,15 @@
#include <QCoreApplication>
#include <exiv2/exiv2.hpp>
#include <iostream>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
exv_grep_keys_t keys;
Exiv2::dumpLibraryInfo(std::cout,keys);
return 0;
// return a.exec();
}

@ -93,13 +93,15 @@ typedef int pid_t;
#endif #endif
////////////////////////////////////// //////////////////////////////////////
// https://softwareengineering.stackexchange.com/questions/291141/how-to-handle-design-changes-for-auto-ptr-deprecation-in-c11 #ifndef _MSC_VER
#if __cplusplus >= 201103L // https://softwareengineering.stackexchange.com/questions/291141/how-to-handle-design-changes-for-auto-ptr-deprecation-in-c11
#include <memory> #if __cplusplus >= 201103L
#include <sys/types.h> #include <memory>
#include <unistd.h> #include <sys/types.h>
template <typename T> #include <unistd.h>
using auto_ptr = std::unique_ptr<T>; template <typename T>
using auto_ptr = std::unique_ptr<T>;
#endif
#endif #endif
#endif // _CONFIG_H_ #endif // _CONFIG_H_

Loading…
Cancel
Save