From b304244766fbe318ae6c7edb94a59b929c582ccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz=20M=C3=A1s?= Date: Tue, 6 Oct 2020 22:01:01 +0200 Subject: [PATCH 1/3] Move winsock2 inclusion to http.cpp --- CMakeLists.txt | 1 - include/exiv2/config.h | 6 ------ src/http.cpp | 5 +++++ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 85b92ac70a..c8f9d0887c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,6 @@ project(exiv2 # use TWEAK to categorize the build LANGUAGES CXX ) include(cmake/mainSetup.cmake REQUIRED) -add_compile_options(-DEXIV2_BUILDING_EXIV2) # options and their default values option( BUILD_SHARED_LIBS "Build exiv2lib as a shared library" ON ) diff --git a/include/exiv2/config.h b/include/exiv2/config.h index 1af0b69ac1..8c35ec2120 100644 --- a/include/exiv2/config.h +++ b/include/exiv2/config.h @@ -92,12 +92,6 @@ typedef int pid_t; # endif #endif ////////////////////////////////////// -#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW__) -#ifdef EXIV2_BUILDING_EXIV2 -#define __USE_W32_SOCKETS -#include -#endif -#endif // https://softwareengineering.stackexchange.com/questions/291141/how-to-handle-design-changes-for-auto-ptr-deprecation-in-c11 diff --git a/src/http.cpp b/src/http.cpp index afd7949246..104aa5e3b4 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -40,6 +40,11 @@ //////////////////////////////////////// // platform specific code +#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW__) +#define __USE_W32_SOCKETS +#include +#endif + #if defined(WIN32) || defined(_MSC_VER) || defined(__MINGW__) #include #include From 30773c92a3f2051ec455b876720574b62fb0c54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz=20M=C3=A1s?= Date: Tue, 6 Oct 2020 22:48:38 +0200 Subject: [PATCH 2/3] WIN32_LEAN_AND_MEAN propagated with exiv2lib target --- cmake/compilerFlags.cmake | 2 +- src/CMakeLists.txt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/compilerFlags.cmake b/cmake/compilerFlags.cmake index ed0e1e331b..d8776411dd 100644 --- a/cmake/compilerFlags.cmake +++ b/cmake/compilerFlags.cmake @@ -139,7 +139,7 @@ if(MSVC) # Object Level Parallelism add_compile_options(/MP) - add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN) + add_definitions(-DNOMINMAX) # This definition is not only needed for Exiv2 but also for xmpsdk # https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ if (MSVC_VERSION GREATER_EQUAL "1910") # VS2017 and up diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 83cbbb005c..38cb8f41cb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -192,7 +192,9 @@ if (EXIV2_ENABLE_WEBREADY) endif() if (WIN32) - target_compile_definitions(exiv2lib PRIVATE PSAPI_VERSION=1) # to be compatible with <= WinVista (#905) + target_compile_definitions(exiv2lib PRIVATE PSAPI_VERSION=1) # to be compatible with <= WinVista (#905) + # Since windows.h is included in some headers, we need to propagate this definition + target_compile_definitions(exiv2lib PUBLIC WIN32_LEAN_AND_MEAN) endif() if (NOT MSVC) From 778479556fded5f9847a6280293545b53373ba28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz=20M=C3=A1s?= Date: Tue, 6 Oct 2020 22:56:07 +0200 Subject: [PATCH 3/3] Include winsock2 at the beginning of http.cpp --- src/http.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/http.cpp b/src/http.cpp index 104aa5e3b4..fc274b794b 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -18,7 +18,11 @@ * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. */ -// included header files +#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW__) +#define __USE_W32_SOCKETS +#include +#endif + #include "config.h" #include "datasets.hpp" #include "http.hpp" @@ -40,10 +44,6 @@ //////////////////////////////////////// // platform specific code -#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW__) -#define __USE_W32_SOCKETS -#include -#endif #if defined(WIN32) || defined(_MSC_VER) || defined(__MINGW__) #include