Skip to content

cmake: simplify and fixup varname for runtime dependencies list - #2090

Closed
vszakats wants to merge 2 commits into
libssh2:masterfrom
vszakats:cm-simplify-and-rename-rtlibvar
Closed

vszakats wants to merge 2 commits into
libssh2:masterfrom
vszakats:cm-simplify-and-rename-rtlibvar

Conversation

@vszakats

@vszakats vszakats commented Jun 20, 2026 •

Copy link
Copy Markdown
Member
  • factor out the single-underscored name.
  • rename double-underscored name into the LIBSSH2_ namespace.
    Spotted by GitHub Code Quality

Follow-up to 694b9d9 #1610
Follow-up to 6bf8983

@vszakats vszakats added the build label Jun 20, 2026
@vszakats vszakats closed this in d652ba0 Jun 20, 2026
@vszakats
vszakats deleted the cm-simplify-and-rename-rtlibvar branch June 20, 2026 18:01
@vszakats

Copy link
Copy Markdown
Member Author

This broke the copying feature. Will fix.

@vszakats
vszakats requested a review from Copilot June 20, 2026 20:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the CMake variable used to collect runtime dependency files by removing the previous underscored names and introducing a LIBSSH2_-namespaced list for use by the example/test dependency-copy targets.

Changes:

  • Rename the runtime dependency list variable to LIBSSH2_RUNTIME_DEPENDENCIES.
  • Update example/test CMake logic to consume the renamed variable.
  • Simplify the runtime dependency list initialization/documentation in the top-level CMake.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
CMakeLists.txt Initializes LIBSSH2_RUNTIME_DEPENDENCIES and appends OpenSSL runtime DLLs (Windows).
src/CMakeLists.txt Appends the built shared library to the runtime dependency list.
example/CMakeLists.txt Uses LIBSSH2_RUNTIME_DEPENDENCIES when creating the copy-dependencies target for examples.
tests/CMakeLists.txt Uses LIBSSH2_RUNTIME_DEPENDENCIES when creating the copy-dependencies target for tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/CMakeLists.txt
Comment on lines +176 to 177
list(APPEND LIBSSH2_RUNTIME_DEPENDENCIES $<TARGET_FILE:${LIB_SHARED}>)
endif()

@vszakats vszakats Jun 20, 2026 •

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.

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.

→ PR #2091

vszakats added a commit that referenced this pull request Jun 21, 2026
This feature has been permanently enabled since the initial commit
adding CMake builds to libssh2. Limited to libssh2's own DLL (if built
that way), and OpenSSL's crypto DLL. While limited to these two DLLs
(and not supporting other dependencies), history shows this feature was
prone to break, and recently started breaking parallel builds, due to
MSBuild failing while copying the DLLs to the same location in
concurrent threads. This recently made MSVC GHA jobs flaky.

It's also a potential performance and disk trashing issue when copying
large DLLs (OpenSSL `libcrypto-*.dll`) on each build, for each of the 52
(at the time of this commit) targets. That's potentially 104 copy
operations. Perhaps this could be limited to once per each target
directory, but that's adding even more complexity and development time.
There is also no generalized/trivial way to pick up the complete set of
DLL dependencies; e.g. libcrypto.dll may need other DLLs. Another
disadvantage is copying around DLLs eventually ends up contributing to
DLL-hell, copies may go stale, picked up when undesired, or due the
heuristic detection, they may not match the dependency version/instance
actually linked. The copying was done on all platforms, while typically
the issue is exclusive to Windows MSVC (and it's also where it breaks.)

As a replacement, I propose to add any necessary DLL location to `PATH`
before running examples or tests. It works well in CI. Also in curl.

Fixing:
```
Version: 20260616.203.1
[...]
MSBuild version 17.14.40+3e7442088 for .NET Framework
[...]
D:/a/libssh2/libssh2/bld/tests/Release\libssh2.dll: message: deploying dependencies
  D:/a/libssh2/libssh2/bld/tests/Release\libcrypto-3-x64.dll: message: deploying dependencies
  The process cannot access the file because it is being used by another process.
[...]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmDone [D:\a\libssh2\libssh2\bld\tests\test_auth_pubkey_ok_rsa_sha2_256_signed.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [D:\a\libssh2\libssh2\bld\tests\test_auth_pubkey_ok_rsa_sha2_256_signed.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :VCEnd" exited with code 32. [D:\a\libssh2\libssh2\bld\tests\test_auth_pubkey_ok_rsa_sha2_256_signed.vcxproj]
  D:/a/libssh2/libssh2/bld/tests/Release/test_auth_keyboard_info_request.exe: message: deploying dependencies
  D:/a/libssh2/libssh2/bld/tests/Release\libcrypto-3-x64.dll: message: deploying dependencies
  test_auth_pubkey_ok_rsa_openssh.vcxproj -> D:\a\libssh2\libssh2\bld\tests\Release\test_auth_pubkey_ok_rsa_openssh.exe
```
Refs (MSVC):
https://github.com/libssh2/libssh2/actions/runs/27838566519/job/82392203784 OpenSSL
https://github.com/libssh2/libssh2/actions/runs/27838566519/job/82392203753 WinCNG
https://github.com/libssh2/libssh2/actions/runs/27823077802/job/82340632890 WinCNG UWP

Examples, with shared libssh2:
combined with WINCNG:
Before: https://github.com/libssh2/libssh2/actions/runs/27891639324/job/82535960547 (277 steps)
After: https://github.com/libssh2/libssh2/actions/runs/27901568257/job/82562736781 (229 steps)
combined with OpenSSL:
Before: https://github.com/libssh2/libssh2/actions/runs/27902131772/job/82564199274 (326 steps)
After: https://github.com/libssh2/libssh2/actions/runs/27902733625/job/82565870012 (229 steps)

Observe these steps no longer performed:
```
D:/a/libssh2/libssh2/bld/example/Release\libcrypto-3-x64.dll: message: deploying dependencies
D:/a/libssh2/libssh2/bld/example/Release\libssh2.dll: message: deploying dependencies
```

Ref: #2078
Ref: 1e5e292
Follow-up to a95a02c #2093
Follow-up to 97d8e8d #2091
Follow-up to d652ba0 #2090
Follow-up to dd50a41 #1638
Follow-up to 694b9d9 #1610
Follow-up to 97417ad #899
Follow-up to 19884e5 #818
Follow-up to 6bf8983

Closes #2101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants