diff --git a/ports/cpp-pinyin/portfile.cmake b/ports/cpp-pinyin/portfile.cmake new file mode 100644 index 0000000000..30b6a6101a --- /dev/null +++ b/ports/cpp-pinyin/portfile.cmake @@ -0,0 +1,26 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO wolfgitpr/cpp-pinyin + REF "${VERSION}" + SHA512 cdd78cdc493ab352bfd7c5adfb4642bc587fb26f65b4d81a07e7c89c377222a30730f3e800f028106b66cbc35e32709c1a0e470e9737b6ee9718e3ce9da8137a + HEAD_REF main +) + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" CPP_PINYIN_BUILD_STATIC) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DCPP_PINYIN_BUILD_STATIC=${CPP_PINYIN_BUILD_STATIC} + -DCPP_PINYIN_BUILD_TESTS=FALSE + "-DVCPKG_DICT_DIR=${CURRENT_PACKAGES_DIR}/share/${PORT}" +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/${PORT}") + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") +configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" COPYONLY) diff --git a/ports/cpp-pinyin/usage b/ports/cpp-pinyin/usage new file mode 100644 index 0000000000..23b6a783d6 --- /dev/null +++ b/ports/cpp-pinyin/usage @@ -0,0 +1,12 @@ +cpp-pinyin provides CMake targets: + + find_package(cpp-pinyin CONFIG REQUIRED) + target_link_libraries(main PRIVATE cpp-pinyin::cpp-pinyin) + +To use the library, you need to copy the dictionary files to the binary directory. + + add_custom_command(TARGET main POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy_directory + "${cpp-pinyin_DIR}/dict" + "$/dict" + ) diff --git a/ports/cpp-pinyin/vcpkg.json b/ports/cpp-pinyin/vcpkg.json new file mode 100644 index 0000000000..07b23eedb7 --- /dev/null +++ b/ports/cpp-pinyin/vcpkg.json @@ -0,0 +1,17 @@ +{ + "name": "cpp-pinyin", + "version": "1.0.0", + "description": "A lightweight Chinese/Cantonese to Pinyin library.", + "homepage": "https://github.com/wolfgitpr/cpp-pinyin", + "license": "Apache-2.0", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/versions/baseline.json b/versions/baseline.json index f90322c10f..f16f78c585 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -1920,6 +1920,10 @@ "baseline": "1.9.0", "port-version": 0 }, + "cpp-pinyin": { + "baseline": "1.0.0", + "port-version": 0 + }, "cpp-redis": { "baseline": "4.3.1", "port-version": 5 diff --git a/versions/c-/cpp-pinyin.json b/versions/c-/cpp-pinyin.json new file mode 100644 index 0000000000..592b2b3010 --- /dev/null +++ b/versions/c-/cpp-pinyin.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "f3a4b0cc31a8acaecebdee019de6f0a07b45037a", + "version": "1.0.0", + "port-version": 0 + } + ] +}