Skip to content

[libxchange] initial port#51346

Merged
BillyONeal merged 15 commits intomicrosoft:masterfrom
attipaci:xchange-1.1.2
May 1, 2026
Merged

[libxchange] initial port#51346
BillyONeal merged 15 commits intomicrosoft:masterfrom
attipaci:xchange-1.1.2

Conversation

@attipaci
Copy link
Copy Markdown
Contributor

@attipaci attipaci commented Apr 23, 2026

This is a draft PR with the upstream release candidate. Please comment on issues so they may be fixed upstream if need be. This PR will be updated to the final upstream v1.1.2 release in a couple of weeks, after which it may be merged as appropriate.

  • Changes comply with the maintainer guide.
  • The packaged project shows strong association with the chosen port name. Check this box if at least one of the following criteria is met:
    • The project is in Repology: https://repology.org//versions
    • The project is amongst the first web search results for "" or " C++". Include a screenshot of the search engine results in the PR.
    • The port name follows the 'GitHubOrg-GitHubRepo' form or equivalent Owner-Project form.
  • Optional dependencies of the build are all controlled by the port. A dependency is controlled if it is declared an unconditional dependency in vcpkg.json, or explicitly disabled through patches or build system arguments such as CMAKE_DISABLE_FIND_PACKAGE_Xxx or VCPKG_LOCK_FIND_PACKAGE
  • The versioning scheme in vcpkg.json matches what upstream says.
  • The license declaration in vcpkg.json matches what upstream says.
  • The installed as the "copyright" file matches what upstream says.
  • The source code of the component installed comes from an authoritative source.
  • The generated "usage text" is brief and accurate. See adding-usage for context. Don't add a usage file if the automatically generated usage is correct.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Exactly one version is added in each modified versions file.
image

@attipaci attipaci force-pushed the xchange-1.1.2 branch 3 times, most recently from e143a94 to 18e2a0f Compare April 23, 2026 12:17
@attipaci
Copy link
Copy Markdown
Contributor Author

attipaci commented Apr 23, 2026

From the arm64_linux failure log:

CMake Error at CMakeLists.txt:80 (find_library):
  Could not find MATH_LIBRARY using the following names: m

libm is standard on Linux. It's strange that it seems to be missing for the arm64_linux build (but fine on the other Linux and non-Windows builds). Any help or insight is welcome on how this may be fixed.

@dg0yt
Copy link
Copy Markdown
Contributor

dg0yt commented Apr 24, 2026

For the arm64-linux cross build, libm is not in the standard paths searched by CMake's find_library. But it is in the paths searched by the C linker, CMAKE_C_IMPLICIT_LINK_DIRECTORIES.

Basically it is a bad idea to search for the path of libm because you are supposed to use -lm.

Related: #50514

@attipaci
Copy link
Copy Markdown
Contributor Author

Thanks @dg0yt,

I've changed how the need for linking against the math library is determined. It's a bit strange that CMake does not have a more automatic portable way to link against the math library when needed for a given platform, given that it's likely to a very common use case and equally common source of mistakes that limit portability...

@attipaci attipaci marked this pull request as ready for review April 27, 2026 07:27
@attipaci attipaci changed the title WIP: [xchange] Initial port [xchange] Initial port Apr 27, 2026
@attipaci attipaci changed the title [xchange] Initial port [xchange] initial port Apr 28, 2026
Copy link
Copy Markdown
Member

@vicroms vicroms left a comment

Choose a reason for hiding this comment

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

Changes requested:

  • docs and examples should not be installed

For consideration:

  • This library is named libxchange on Repology

Comment thread ports/libxchange/portfile.cmake Outdated
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DBUILD_TESTING=OFF
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
-DBUILD_TESTING=OFF
-DBUILD_TESTING=OFF
-DBUILD_DOC=OFF
-DBUILD_EXAMPLES=OFF

The port is installing documentation and examples by default

xchange:<triplet>:/share/doc/xchange/CHANGELOG.md
xchange:<triplet>:/share/doc/xchange/CONTRIBUTING.md
xchange:<triplet>:/share/doc/xchange/examples/CMakeLists.txt
xchange:<triplet>:/share/doc/xchange/examples/example-escape.c
xchange:<triplet>:/share/doc/xchange/examples/Makefile
xchange:<triplet>:/share/doc/xchange/examples/example-json.c
xchange:<triplet>:/share/doc/xchange/examples/.gitignore

Copy link
Copy Markdown
Contributor Author

@attipaci attipaci Apr 28, 2026

Choose a reason for hiding this comment

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

Hi @vicroms,

Thanks for the feedback. I'll remove the doc and examples from the install. I'm also happy to call it libxchange (I was debating it in the first place). The original name is xchange (as in the Github repo, and the CMake package export), but that name was already taken by a once-upon-a-time Fedora package, hence it became libxchange for Linux.

Copy link
Copy Markdown
Contributor Author

@attipaci attipaci Apr 28, 2026

Choose a reason for hiding this comment

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

BUILD_DOC and BUILD_EXAMPLES are both OFF by default, so there is no need to set these explicitly. The examples (source code) and some bare basic documentation (e.g. CHANGELOG.md) are always installed in the docdir by upstream. Which means that the vcpkg port will have to explicitly remove these if they are unwanted. I've updated to portfile to remove the docdir contents installed by upstream. Hopefully that is sufficient.

Copy link
Copy Markdown
Contributor Author

@attipaci attipaci Apr 28, 2026

Choose a reason for hiding this comment

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

Nevertheless, the CMake package export from upstream is xchange, not libxchange. If that is confusing, then I think naming the vcpkg port as xchange (the same as the CMake package) might still be preferrable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nevertheless, the CMake package export from upstream is xchange, not libxchange. If that is confusing, then I think naming the vcpkg port as xchange (the same as the CMake package) might still be preferrable.

We cite repology because we believe being consistent with other package managers is more important than being consistent with other identifiers.

@vicroms vicroms marked this pull request as draft April 28, 2026 18:16
Comment thread ports/libxchange/portfile.cmake Outdated
Co-authored-by: Kai Pastor <dg0yt@darc.de>
@attipaci attipaci marked this pull request as ready for review April 29, 2026 06:58
@attipaci attipaci requested a review from vicroms April 29, 2026 08:23
@attipaci attipaci changed the title [xchange] initial port [libxchange] initial port Apr 29, 2026
Copy link
Copy Markdown
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

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

Please merge these nitpick fixes. attipaci#3

@BillyONeal BillyONeal marked this pull request as draft April 30, 2026 00:23
@BillyONeal
Copy link
Copy Markdown
Member

I don't think Victor (@vicroms ) comment is fixed yet. If upstream exposes an option to disable building examples we should use it.

@attipaci
Copy link
Copy Markdown
Contributor Author

attipaci commented Apr 30, 2026

Hi @BillyONeal,

I think I tried to answer @vicroms comments -- I clearly did not do a good job, so I'll ty again... ;-)

Upstream always installs the example source code (.c files) and the changelog and contributor guide (.md files) into the doc directory (<prefix>/share/doc/xchange/). Upstream has no options to disable these.

The BUILD_EXAMPLES option controls only whether or not the examples are also compiled into test programs during build, while the BUILD_DOC option controls whether additional HTML documentation is built using Doxygen. Both BUILD_EXAMPLES and BUILD_DOC are OFF by default, so @vicroms suggested changes have exactly zero effect on what is built / installed.

The only way to ensure that vcpkg does not have stuff installed in the docdir is to remove these after the upstream install. Which is the change I did implement.

I hope this clarifies it better.

-- A.

Remove extra newline, ensure line endings are LF, remove trailing whitespace.
@attipaci attipaci marked this pull request as ready for review April 30, 2026 10:00
@attipaci attipaci requested a review from BillyONeal April 30, 2026 10:00
@BillyONeal
Copy link
Copy Markdown
Member

Ah, I see the confusion now. I think what happened is that @vicroms saw "examples" in the file list, saw that upstream has a BUILD_EXAMPLES, and that that was not turned off when we invoke it, then wrote the comment.

The unconditional write is here:

https://github.com/Sigmyne/xchange/blob/0e3e3ec6d37317b0bd1f4a59f0fe1e05c4a23cfe/CMakeLists.txt#L140-L144

Copy link
Copy Markdown
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

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

Thank you!

@BillyONeal BillyONeal dismissed vicroms’s stale review May 1, 2026 01:12

They explained that that does not apply

@BillyONeal BillyONeal merged commit 6e8e56f into microsoft:master May 1, 2026
16 checks passed
@attipaci attipaci deleted the xchange-1.1.2 branch May 1, 2026 08:53
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.

4 participants