Search code examples
ccmakestatic-librariesvcpkg

Building your own package for distribution via vcpkg


I'm running into an issue with a local test of (MacOS) as I install my own package from Github via vcpkg, in a brand new c-based project)

Here's what the vcpkg folder structure looks like: x64-osx/debug folder seems to be okay since I see the dependencies there.

Folder Structure

  • vcpkg_installed
    • vcpkg (/info, /upates etc.)
    • x64-osx
      • debug

        • include (mylib/mylib.h is present)
        • lib (libmylib.a is present)
      • include

        • mylib (mylib.h is present)
      • lib (Missing libmylib.a file)

      • share

portfile.cmake

vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
        OUT_SOURCE_PATH SOURCE_PATH
        REPO username/mylib
        REF "${VERSION}"
        SHA512 b567c0090926e6dd6d78f5b6d839539ed517f1d133d7078bfbdc118c43edd3e354a4a045632cb64d53af06bca34041aff972700541d4131bb45d70601311af4c
        HEAD_REF main
)

vcpkg_cmake_configure(SOURCE_PATH "${SOURCE_PATH}" OPTIONS -DBUILD_TESTS=OFF)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib")

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" COPYONLY)

Question: I don't see libmylib.a file under the lib folder, and I assume a non-debug or release version has to be there for users to use this library effectively.

It seems that my vcpkg configuration (portfile.cmake) is building the debug version but not the distribution or production version.

What am I missing from my portfile.cmake file (that goes to the vcpkg repo) to make it happen?


Solution

  • Your are not missing something your are deleting the release artifacts with:

    file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib")