Skip to content

pkg-config should work on MSVC #125

Closed

Description

@BillyONeal

In microsoft/vcpkg#53943 we asked GPT 5.6 Sol to check that CMake bindings, pkg-config bindings, and direct include use cases work. AI was not used to write this message. It found that pkg-config is broken on MSVC because it's explicitly blocked here:

physfs/CMakeLists.txt

Lines 382 to 388 in ccffd00

if(NOT MSVC)
configure_file(cmake/physfs.pc.in physfs.pc @ONLY)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/physfs.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
)
endif()

  • There's no reason to forbid MSVC from using pkg-config, it works fine, though affordances need to be made for the static lib version being different when it is selected.
  • Checking for MSVC causes this to misbehave for other Windows compilers, which also need to take the same name as .dll and .lib. If the problem we're avoiding is "the same name would come out" it would be better to check if(CMAKE_STATIC_LIBRARY_SUFFIX STREQUAL CMAKE_IMPORT_LIBRARY_SUFFIX)

Unfortunately I asked GPT to create a patch for this while I was still looking at the vcpkg repo and before I saw https://github.com/icculus/physfs/blob/main/AGENTS.md forbidding AI generated contributions. It did basically exactly what I would want to do so anything I would submit is now effectively poisoned, so I've not submitted it as a PR.

If you're willing to make an exception in this case on the grounds that no product code is being edited, only build scripts, I have attached the patch here as a separate file so you can avoid looking at it if you don't want to. Or I can submit it as a PR for you.

pkgconfig.patch

Activity

  1. BillyONeal commented on Sep 22, 2026

    @BillyONeal
    Author

    It would also be helpful if you could comment on microsoft/vcpkg#53943 whether you want to forbid us from applying this patch there (thus intentionally leaving pkg-config broken) whether you apply it here or not. (The patch is not there but it is in xiaozhuai/vcpkg#41 so be careful)

  2. BillyONeal commented on Sep 22, 2026

    @BillyONeal
    Author

    xiaozhuai/vcpkg#41 got merged so microsoft/vcpkg#53943 now also contains the patch; you can avoid seeing by just not opening the files tab.

  3. icculus commented on Sep 22, 2026

    @icculus
    Owner

    @madebr We aren't going to apply this specific patch because it's AI-generated, but I had no idea pkg-config was a going concern on Windows. Removing the MSVC check is a no-brainer in that case, but do you have any opinions on how it's splitting up the static/shared library naming?

    (And is any of this something we need to change in SDL, etc?)

  4. icculus commented on Sep 22, 2026

    @icculus
    Owner

    you can avoid seeing

    I appreciate that you're trying to respect a boundary, but the boundary was "please don't post this stuff at all," to be clear.

    I also get that open source is a culture where it's super-hard not to be helpful on impulse, so we're going to get this issue handled, and no one is upset.

  5. madebr commented on Sep 22, 2026

    @madebr
    Collaborator

    I think pkg-config can be made compatible with MSVC compilers as long as you don't expect it to support static libraries (pkg-config --static option).

    I'd replace -L$libdir with-LIBPATH:$libdir and -lphysfs with physfs.lib.

  6. madebr commented on Sep 22, 2026

    @madebr
    Collaborator

    Please go see #126 and check whether it fixes this issue.
    I only tested this on Linux, but the pc file looks MSVC compatible to me

  7. icculus commented on Sep 22, 2026

    @icculus
    Owner

    I merged it to make it easier for the vcpkg crew to just grab main to test. If it needs further tweaks we can make them.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions