Skip to content

Windows MSVC build: Add libmtp support. - #140

Draft
mikeller wants to merge 1 commit into
subsurface:Subsurface-DS9from
mikeller:add_windows_libmtp
Draft

mikeller wants to merge 1 commit into
subsurface:Subsurface-DS9from
mikeller:add_windows_libmtp

Conversation

@mikeller

Copy link
Copy Markdown
Member
  • Add libmtp support to the MSVC build.
  • Add support for building with WPD.

Copilot AI lite review requested due to automatic review settings September 16, 2026 02:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The MSVC project may fail to compile or link when VCPKG_ROOT is set without libmtp installed.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds libmtp and WPD support to the Windows MSVC build and ignores VS Code metadata.

Changes:

  • Adds vcpkg-based libmtp build settings across configurations.
  • Adds WPD-related libraries.
  • Ignores .vscode/.
File summaries
File Summary
contrib/msvc/libdivecomputer.vcxproj Adds libmtp/WPD configuration; the VCPKG_ROOT gate may enable libmtp when the port is unavailable.
.gitignore Adds .vscode/ to ignored files.
Review details

Suppressed comments (1)

contrib/msvc/libdivecomputer.vcxproj:76

  • The project still exposes Win32/x86 configurations (for example, contrib/README:34-37 and the x86 CI job), but these unconditional paths always select the x64-windows triplet. Enabling libmtp for a Win32 build therefore links x64 libmtp.lib into a 32-bit target and fails with an architecture mismatch. Select x86-windows for Win32/x86 and x64-windows for x64, or disable libmtp for the 32-bit configurations.
    <LibmtpIncludes Condition="'$(EnableLibmtp)'=='true'">$(VCPKG_ROOT)\installed\x64-windows\include;</LibmtpIncludes>
    <LibmtpLibs Condition="'$(EnableLibmtp)'=='true'">libmtp.lib;ole32.lib;portabledeviceguids.lib;propsys.lib;</LibmtpLibs>
    <LibmtpLibDirs Condition="'$(EnableLibmtp)'=='true'">$(VCPKG_ROOT)\installed\x64-windows\lib;</LibmtpLibDirs>
  • Files reviewed: 1/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread contrib/msvc/libdivecomputer.vcxproj Outdated
<PropertyGroup Label="UserMacros" />
<!-- Auto-enable libmtp support when VCPKG_ROOT is set, unless explicitly overridden. -->
<PropertyGroup>
<EnableLibmtp Condition="'$(EnableLibmtp)'=='' and '$(VCPKG_ROOT)'!=''">true</EnableLibmtp>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both issues have been addressed in the rebase:

  1. The auto-enable condition now uses Exists('$(VCPKG_ROOT)\installed\x64-windows\include\libmtp.h') instead of just checking VCPKG_ROOT is non-empty, so the port must actually be present for libmtp to be enabled.

  2. An explicit override sets EnableLibmtp to false for Win32 configurations, so the x64-windows triplet paths are never referenced in 32-bit builds.

Copilot AI review requested due to automatic review settings September 16, 2026 05:03
@mikeller

Copy link
Copy Markdown
Member Author

The DCO failure has been resolved: the "Add support for building with WPD." commit was amended to add the missing Signed-off-by trailer during the rebase.

Copilot stopped reviewing on behalf of mikeller due to an error September 16, 2026 05:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Copilot was unable to run its full agentic suite in this review.

Pull request overview

Copilot reviewed 1 out of 2 changed files in this pull request and generated 6 comments.

Comment thread contrib/msvc/libdivecomputer.vcxproj Outdated
<LibmtpPreprocessor Condition="'$(EnableLibmtp)'=='true'">HAVE_LIBMTP;</LibmtpPreprocessor>
<LibmtpIncludes Condition="'$(EnableLibmtp)'=='true'">$(VCPKG_ROOT)\installed\x64-windows\include;</LibmtpIncludes>
<LibmtpLibs Condition="'$(EnableLibmtp)'=='true'">libmtp.lib;ole32.lib;portabledeviceguids.lib;propsys.lib;</LibmtpLibs>
<LibmtpLibDirs Condition="'$(EnableLibmtp)'=='true'">$(VCPKG_ROOT)\installed\x64-windows\lib;</LibmtpLibDirs>
Comment thread contrib/msvc/libdivecomputer.vcxproj Outdated
<PropertyGroup Label="UserMacros" />
<!-- Enable libmtp support when the vcpkg port is present, unless explicitly overridden. -->
<PropertyGroup>
<EnableLibmtp Condition="'$(EnableLibmtp)'=='' and Exists('$(VCPKG_ROOT)\installed\x64-windows\include\libmtp.h')">true</EnableLibmtp>
Comment thread contrib/msvc/libdivecomputer.vcxproj Outdated
Comment on lines +71 to +74
<EnableLibmtp Condition="'$(EnableLibmtp)'=='' and Exists('$(VCPKG_ROOT)\installed\x64-windows\include\libmtp.h')">true</EnableLibmtp>
<EnableLibmtp Condition="'$(EnableLibmtp)'==''">false</EnableLibmtp>
<!-- libmtp is x64-only until 32-bit vcpkg triplet support is confirmed. -->
<EnableLibmtp Condition="'$(EnableLibmtp)'=='true' and '$(Platform)'=='Win32'">false</EnableLibmtp>
<!-- libmtp is x64-only until 32-bit vcpkg triplet support is confirmed. -->
<EnableLibmtp Condition="'$(EnableLibmtp)'=='true' and '$(Platform)'=='Win32'">false</EnableLibmtp>
<LibmtpPreprocessor Condition="'$(EnableLibmtp)'=='true'">HAVE_LIBMTP;</LibmtpPreprocessor>
<LibmtpIncludes Condition="'$(EnableLibmtp)'=='true'">$(VCPKG_ROOT)\installed\x64-windows\include;</LibmtpIncludes>
Comment thread contrib/msvc/libdivecomputer.vcxproj Outdated
Comment on lines +75 to +78
<LibmtpPreprocessor Condition="'$(EnableLibmtp)'=='true'">HAVE_LIBMTP;</LibmtpPreprocessor>
<LibmtpIncludes Condition="'$(EnableLibmtp)'=='true'">$(VCPKG_ROOT)\installed\x64-windows\include;</LibmtpIncludes>
<LibmtpLibs Condition="'$(EnableLibmtp)'=='true'">libmtp.lib;ole32.lib;portabledeviceguids.lib;propsys.lib;</LibmtpLibs>
<LibmtpLibDirs Condition="'$(EnableLibmtp)'=='true'">$(VCPKG_ROOT)\installed\x64-windows\lib;</LibmtpLibDirs>
Comment on lines +103 to +104
<AdditionalIncludeDirectories>..\..\include;$(LibmtpIncludes)%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBDIVECOMPUTER_EXPORTS;ENABLE_LOGGING;HAVE_VERSION_SUFFIX;HAVE_AF_IRDA_H;HAVE_WS2BTH_H;$(LibmtpPreprocessor)%(PreprocessorDefinitions)</PreprocessorDefinitions>
Copilot AI review requested due to automatic review settings September 16, 2026 05:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@mikeller
mikeller marked this pull request as draft September 16, 2026 07:31
Add support for building with WPD.

Three improvements to the libmtp property-group block:

1. Guard the Exists() check with '$(VCPKG_ROOT)'!='' so that an
   unset VCPKG_ROOT does not cause MSBuild to evaluate
   Exists('\installed\x64-windows\include\libmtp.h') against the
   drive root.

2. Fold the Win32 platform restriction directly into the enable
   condition instead of overwriting EnableLibmtp in a separate
   element, which was confusing due to MSBuild property-evaluation
   order.

3. Make LibmtpLibDirs configuration-aware: Debug builds use the
   vcpkg debug lib directory (installed\x64-windows\debug\lib),
   Release builds use the release lib directory
   (installed\x64-windows\lib).  Previously Debug|x64 always
   linked against the release import library.

Also add a short comment explaining why the Windows SDK system
libraries (ole32, portabledeviceguids, propsys) are listed
explicitly.

Signed-off-by: Michael Keller <github@ike.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants