다음을 통해 공유


vcpkg create

개요

vcpkg create <port-name> <url-to-source> [archive-file-name]

설명

소스 코드 프로젝트를 패키지하는 포트를 생성합니다. 패키지할 소스 코드의 포트 이름과 URL이 필요합니다.

이 명령은 제공된 URL에서 소스 코드를 다운로드한 다음 새 포트 디렉터리에 파일과 vcpkg.json 파일을 만듭니다portfile.cmake.

이 명령은 선택적 인수로 제공된 특정 파일 이름을 사용하여 다운로드한 소스 코드를 저장할 수 있습니다. 보관 파일 이름을 지정하지 않으면 명령은 해당 URL에서 파일 이름을 파생합니다.

명령으로 vcpkg create 만든 포트는 시작 지점으로만 사용되며, 대부분의 경우 성공적인 빌드를 위해 추가 편집이 필요하다는 것을 이해하는 것이 중요합니다. vcpkg 큐레이팅된 레지스트리에 포트를 추가하는 방법에 대한 자세한 지침은 자습서 중 하나를 참조하는 것이 좋습니다.

예시

vcpkg create zlib2 https://github.com/madler/zlib/archive/v1.2.11.tar.gz zlib-1.2.11.tar.gz

-- Downloading https://github.com/madler/zlib/archive/v1.2.11.tar.gz -> zlib-1.2.11.tar.gz...
-- Generated portfile: C:\src\vcpkg\ports\zlib2\portfile.cmake
-- Generated manifest: C:\src\vcpkg\ports\zlib2\vcpkg.json
-- To launch an editor for these new files, run
--     .\vcpkg edit zlib2

명령을 실행하면 다음 작업이 수행됩니다.

  1. 파일과 파일을 포함하는 포트 zlib2 폴더를 portfile.cmakevcpkg.json 만듭니다.
  2. https://github.com/madler/zlib/archive/v1.2.11.tar.gz 디렉터리에서 downloads 와 같이 zlib-1.2.11.tar.gz 다운로드합니다.

portfile.cmake 콘텐츠는 다음과 같습니다.

# Common Ambient Variables:
#   CURRENT_BUILDTREES_DIR    = ${VCPKG_ROOT_DIR}\buildtrees\${PORT}
#   CURRENT_PACKAGES_DIR      = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET}
#   CURRENT_PORT_DIR          = ${VCPKG_ROOT_DIR}\ports\${PORT}
#   CURRENT_INSTALLED_DIR     = ${VCPKG_ROOT_DIR}\installed\${TRIPLET}
#   DOWNLOADS                 = ${VCPKG_ROOT_DIR}\downloads
#   PORT                      = current port name (zlib, etc)
#   TARGET_TRIPLET            = current triplet (x86-windows, x64-windows-static, etc)
#   VCPKG_CRT_LINKAGE         = C runtime linkage type (static, dynamic)
#   VCPKG_LIBRARY_LINKAGE     = target library linkage type (static, dynamic)
#   VCPKG_ROOT_DIR            = <C:\path\to\current\vcpkg>
#   VCPKG_TARGET_ARCHITECTURE = target architecture (x64, x86, arm)
#   VCPKG_TOOLCHAIN           = ON OFF
#   TRIPLET_SYSTEM_ARCH       = arm x86 x64
#   BUILD_ARCH                = "Win32" "x64" "ARM"
#   DEBUG_CONFIG              = "Debug Static" "Debug Dll"
#   RELEASE_CONFIG            = "Release Static"" "Release DLL"
#   VCPKG_TARGET_IS_WINDOWS
#   VCPKG_TARGET_IS_UWP
#   VCPKG_TARGET_IS_LINUX
#   VCPKG_TARGET_IS_OSX
#   VCPKG_TARGET_IS_FREEBSD
#   VCPKG_TARGET_IS_ANDROID
#   VCPKG_TARGET_IS_MINGW
#   VCPKG_TARGET_EXECUTABLE_SUFFIX
#   VCPKG_TARGET_STATIC_LIBRARY_SUFFIX
#   VCPKG_TARGET_SHARED_LIBRARY_SUFFIX
#
#   See additional helpful variables in /docs/maintainers/vcpkg_common_definitions.md

# Also consider vcpkg_from_* functions if you can; the generated code here is for any web accessable
# source archive.
#  vcpkg_from_github
#  vcpkg_from_gitlab
#  vcpkg_from_bitbucket
#  vcpkg_from_sourceforge
vcpkg_download_distfile(ARCHIVE
    URLS "https://github.com/madler/zlib/archive/v1.2.11.tar.gz"
    FILENAME "zlib-1.2.11.tar.gz"
    SHA512 104c62ed1228b5f1199bc037081861576900eb0697a226cafa62a35c4c890b5cb46622e399f9aad82ee5dfb475bae26ae75e2bd6da3d261361b1c8b996970faf
)

vcpkg_extract_source_archive_ex(
    OUT_SOURCE_PATH SOURCE_PATH
    ARCHIVE "${ARCHIVE}"
    # (Optional) A friendly name to use instead of the filename of the archive (e.g.: a version number or tag).
    # REF 1.0.0
    # (Optional) Read the docs for how to generate patches at:
    # https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/examples/patching.md
    # PATCHES
    #   001_port_fixes.patch
    #   002_more_port_fixes.patch
)

# # Check if one or more features are a part of a package installation.
# # See /docs/maintainers/vcpkg_check_features.md for more details
# vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
#   FEATURES # <- Keyword FEATURES is required because INVERTED_FEATURES are being used
#     tbb   WITH_TBB
#   INVERTED_FEATURES
#     tbb   ROCKSDB_IGNORE_PACKAGE_TBB
# )

vcpkg_cmake_configure(
    SOURCE_PATH "${SOURCE_PATH}"
    # OPTIONS -DUSE_THIS_IN_ALL_BUILDS=1 -DUSE_THIS_TOO=2
    # OPTIONS_RELEASE -DOPTIMIZE=1
    # OPTIONS_DEBUG -DDEBUGGABLE=1
)

vcpkg_cmake_install()

# # Moves all .cmake files from /debug/share/zlib2/ to /share/zlib2/
# # See /docs/maintainers/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.md for more details
# When you uncomment "vcpkg_cmake_config_fixup()", you need to add the following to "dependencies" vcpkg.json:
#{
#    "name": "vcpkg-cmake-config",
#    "host": true
#}
# vcpkg_cmake_config_fixup()

# Uncomment the line below if necessary to install the license file for the port
# as a file named `copyright` to the directory `${CURRENT_PACKAGES_DIR}/share/${PORT}`
# vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

vcpkg.json 콘텐츠는 다음과 같습니다.

{
  "name": "zlib2",
  "version": "",
  "homepage": "",
  "description": "",
  "dependencies": [
    {
      "name": "vcpkg-cmake",
      "host": true
    }
  ],

  "default-features": [],
  "features": [
    {
      "name": "",
      "description": "",
      "dependencies": []
    }
  ]
}

edit 명령을 사용하여 포트 파일을 수정할 수 있습니다.

vcpkg edit zlib2