]> granicus.if.org Git - taglib/commitdiff
Fix WinRT configuring
authorevpobr <evpobr@users.noreply.github.com>
Thu, 8 Jun 2017 13:59:14 +0000 (18:59 +0500)
committerevpobr <evpobr@users.noreply.github.com>
Thu, 8 Jun 2017 14:00:37 +0000 (19:00 +0500)
Don't rely on _WIN32_WINNT value to enable WinRT support.

if _WIN32_WINNT is not set manually, it is defaulted to SDK version. So
if you use SDK > 8 you cannot use TagLib under Win7 and lower because of
CreateFile2 function dependency.

PLATFORM_WINRT option (OFF by default) was introduced to enable WinRT
build.

Related issues: https://github.com/Microsoft/vcpkg/issues/1240

CMakeLists.txt
ConfigureChecks.cmake
taglib/toolkit/tfilestream.cpp

index bbd7d7cc0b89b61e22c83bbcad2b9cc4f3628ea0..3e081ea223f19dd0e02dae5d7be5b57f74f76b7a 100644 (file)
@@ -46,6 +46,11 @@ option(BUILD_BINDINGS "Build the bindings" ON)
 
 option(NO_ITUNES_HACKS "Disable workarounds for iTunes bugs" OFF)
 
+option(PLATFORM_WINRT "Enable WinRT support" OFF)
+if(PLATFORM_WINRT)
+  add_definitions(-DPLATFORM_WINRT)
+endif()
+
 add_definitions(-DHAVE_CONFIG_H)
 set(TESTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests/")
 
index e39d97b299eb903ebf035e4208e3bdbda8f25318..5e5fca2fda24591e1db813e7c0bf76d7c56bf914 100644 (file)
@@ -209,3 +209,7 @@ if(BUILD_TESTS AND NOT BUILD_SHARED_LIBS)
   endif()
 endif()
 
+# Detect WinRT mode
+if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
+       set(PLATFORM WINRT 1)
+endif()
index 219913af304ff9eda09fba85a2c45a856b1e46b4..17a09f3daaac582ad9f5e963cecace68b06315c4 100644 (file)
@@ -51,7 +51,7 @@ namespace
   {
     const DWORD access = readOnly ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE);
 
-#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)
+#if defined (PLATFORM_WINRT)
     return CreateFile2(path.wstr().c_str(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL);
 #else
     return CreateFileW(path.wstr().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);