2018-04-26 21:23:44 +08:00
|
|
|
vcpkg_from_github(
|
|
|
|
OUT_SOURCE_PATH SOURCE_PATH
|
2019-08-15 05:16:33 +08:00
|
|
|
REPO protocolbuffers/protobuf
|
2024-06-22 04:39:50 +08:00
|
|
|
REF "v${VERSION}"
|
|
|
|
SHA512 ce81add9d978a6b63d4205715eac5084e81a6753da1f6c6bad6493e60253215901bffc4a60d704a873333f2b9f94fd86cb7eb5b293035f2268c12692bd808bac
|
2018-04-26 21:23:44 +08:00
|
|
|
HEAD_REF master
|
2017-11-26 04:36:50 +08:00
|
|
|
PATCHES
|
2020-05-27 13:11:06 +08:00
|
|
|
fix-static-build.patch
|
2020-12-29 05:19:50 +08:00
|
|
|
fix-default-proto-file-path.patch
|
2024-06-22 04:39:50 +08:00
|
|
|
fix-utf8-range.patch
|
2024-08-02 05:35:33 +08:00
|
|
|
fix-arm64-msvc.patch
|
2017-06-12 23:26:30 +08:00
|
|
|
)
|
|
|
|
|
2021-03-27 03:55:34 +08:00
|
|
|
string(COMPARE EQUAL "${TARGET_TRIPLET}" "${HOST_TRIPLET}" protobuf_BUILD_PROTOC_BINARIES)
|
|
|
|
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" protobuf_BUILD_SHARED_LIBS)
|
|
|
|
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" protobuf_MSVC_STATIC_RUNTIME)
|
2017-07-01 04:59:23 +08:00
|
|
|
|
2021-03-27 03:55:34 +08:00
|
|
|
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
2021-04-02 01:32:41 +08:00
|
|
|
FEATURES
|
|
|
|
zlib protobuf_WITH_ZLIB
|
2021-03-27 03:55:34 +08:00
|
|
|
)
|
2017-05-11 03:29:10 +08:00
|
|
|
|
2021-03-27 03:55:34 +08:00
|
|
|
if(VCPKG_TARGET_IS_UWP)
|
|
|
|
set(protobuf_BUILD_LIBPROTOC OFF)
|
2017-05-11 03:29:10 +08:00
|
|
|
else()
|
2021-03-27 03:55:34 +08:00
|
|
|
set(protobuf_BUILD_LIBPROTOC ON)
|
2017-05-11 03:29:10 +08:00
|
|
|
endif()
|
2016-09-23 23:10:37 +08:00
|
|
|
|
2020-09-05 22:22:07 +08:00
|
|
|
if (VCPKG_DOWNLOAD_MODE)
|
|
|
|
# download PKGCONFIG in download mode which is used in `vcpkg_fixup_pkgconfig()` at the end of this script.
|
2022-03-16 04:26:15 +08:00
|
|
|
# download it here because `vcpkg_cmake_configure()` halts execution in download mode when running configure process.
|
2020-09-05 22:22:07 +08:00
|
|
|
vcpkg_find_acquire_program(PKGCONFIG)
|
|
|
|
endif()
|
2017-11-02 02:04:18 +08:00
|
|
|
|
2024-01-27 08:45:13 +08:00
|
|
|
# Delete language backends we aren't targeting to reduce false positives in automated dependency
|
|
|
|
# detectors like Dependabot.
|
|
|
|
file(REMOVE_RECURSE
|
|
|
|
"${SOURCE_PATH}/csharp"
|
|
|
|
"${SOURCE_PATH}/java"
|
2024-06-22 04:39:50 +08:00
|
|
|
"${SOURCE_PATH}/lua"
|
2024-01-27 08:45:13 +08:00
|
|
|
"${SOURCE_PATH}/objectivec"
|
|
|
|
"${SOURCE_PATH}/php"
|
|
|
|
"${SOURCE_PATH}/python"
|
|
|
|
"${SOURCE_PATH}/ruby"
|
2024-06-22 04:39:50 +08:00
|
|
|
"${SOURCE_PATH}/rust"
|
2024-01-27 08:45:13 +08:00
|
|
|
)
|
|
|
|
|
2022-03-16 04:26:15 +08:00
|
|
|
vcpkg_cmake_configure(
|
2022-07-21 06:41:57 +08:00
|
|
|
SOURCE_PATH "${SOURCE_PATH}"
|
2016-09-23 23:10:37 +08:00
|
|
|
OPTIONS
|
2021-03-27 03:55:34 +08:00
|
|
|
-Dprotobuf_BUILD_SHARED_LIBS=${protobuf_BUILD_SHARED_LIBS}
|
|
|
|
-Dprotobuf_MSVC_STATIC_RUNTIME=${protobuf_MSVC_STATIC_RUNTIME}
|
2016-09-23 23:10:37 +08:00
|
|
|
-Dprotobuf_BUILD_TESTS=OFF
|
2018-04-26 21:23:44 +08:00
|
|
|
-DCMAKE_INSTALL_CMAKEDIR:STRING=share/protobuf
|
|
|
|
-Dprotobuf_BUILD_PROTOC_BINARIES=${protobuf_BUILD_PROTOC_BINARIES}
|
2021-03-27 03:55:34 +08:00
|
|
|
-Dprotobuf_BUILD_LIBPROTOC=${protobuf_BUILD_LIBPROTOC}
|
2024-06-22 04:39:50 +08:00
|
|
|
-Dprotobuf_ABSL_PROVIDER=package
|
2021-03-27 03:55:34 +08:00
|
|
|
${FEATURE_OPTIONS}
|
2016-09-23 23:10:37 +08:00
|
|
|
)
|
|
|
|
|
2022-03-16 04:26:15 +08:00
|
|
|
vcpkg_cmake_install()
|
2016-09-23 23:10:37 +08:00
|
|
|
|
2021-03-27 03:55:34 +08:00
|
|
|
if(protobuf_BUILD_PROTOC_BINARIES)
|
2021-08-03 07:59:18 +08:00
|
|
|
if(VCPKG_TARGET_IS_WINDOWS)
|
2021-03-27 03:55:34 +08:00
|
|
|
vcpkg_copy_tools(TOOL_NAMES protoc AUTO_CLEAN)
|
2018-04-11 06:05:04 +08:00
|
|
|
else()
|
2024-06-22 04:39:50 +08:00
|
|
|
string(REPLACE "." ";" VERSION_LIST ${VERSION})
|
|
|
|
list(GET VERSION_LIST 1 VERSION_MINOR)
|
|
|
|
list(GET VERSION_LIST 2 VERSION_PATCH)
|
|
|
|
vcpkg_copy_tools(TOOL_NAMES protoc protoc-${VERSION_MINOR}.${VERSION_PATCH}.0 AUTO_CLEAN)
|
2018-04-11 06:05:04 +08:00
|
|
|
endif()
|
2017-05-11 03:29:10 +08:00
|
|
|
else()
|
2022-03-16 04:26:15 +08:00
|
|
|
file(COPY "${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT}" DESTINATION "${CURRENT_PACKAGES_DIR}/tools")
|
2021-03-27 03:55:34 +08:00
|
|
|
endif()
|
|
|
|
|
2022-03-16 04:26:15 +08:00
|
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/protobuf-config.cmake"
|
2021-03-29 04:52:48 +08:00
|
|
|
"if(protobuf_MODULE_COMPATIBLE)"
|
2024-06-22 04:39:50 +08:00
|
|
|
"if(1)"
|
2021-03-29 04:52:48 +08:00
|
|
|
)
|
2021-05-06 22:12:43 +08:00
|
|
|
if(NOT protobuf_BUILD_LIBPROTOC)
|
2022-03-16 04:26:15 +08:00
|
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/protobuf-module.cmake"
|
2021-05-06 22:12:43 +08:00
|
|
|
"_protobuf_find_libraries(Protobuf_PROTOC protoc)"
|
|
|
|
""
|
|
|
|
)
|
|
|
|
endif()
|
2021-03-29 04:52:48 +08:00
|
|
|
|
2024-06-22 04:39:50 +08:00
|
|
|
vcpkg_cmake_config_fixup()
|
2017-05-11 03:29:10 +08:00
|
|
|
|
2018-04-26 21:23:44 +08:00
|
|
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
|
2024-06-22 04:39:50 +08:00
|
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/google/protobuf/port_def.inc"
|
|
|
|
"\#ifdef PROTOBUF_PORT_"
|
|
|
|
"\#ifndef PROTOBUF_USE_DLLS\n\#define PROTOBUF_USE_DLLS\n\#endif // PROTOBUF_USE_DLLS\n\n\#ifdef PROTOBUF_PORT_"
|
2021-03-27 03:55:34 +08:00
|
|
|
)
|
2017-09-09 07:58:25 +08:00
|
|
|
endif()
|
2017-07-08 08:51:59 +08:00
|
|
|
|
2016-09-23 23:10:37 +08:00
|
|
|
vcpkg_copy_pdbs()
|
2024-05-25 10:39:45 +08:00
|
|
|
|
|
|
|
function(replace_package_string package)
|
|
|
|
set(debug_file "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/${package}.pc")
|
|
|
|
set(release_file "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/${package}.pc")
|
|
|
|
|
|
|
|
if(EXISTS "${release_file}")
|
2024-06-22 04:39:50 +08:00
|
|
|
vcpkg_replace_string("${release_file}" "absl_abseil_dll" "abseil_dll" IGNORE_UNCHANGED)
|
2024-05-25 10:39:45 +08:00
|
|
|
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
|
2024-06-22 04:39:50 +08:00
|
|
|
vcpkg_replace_string("${release_file}" "-l${package}" "-llib${package}" IGNORE_UNCHANGED)
|
2024-05-25 10:39:45 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(EXISTS "${debug_file}")
|
2024-06-22 04:39:50 +08:00
|
|
|
vcpkg_replace_string("${debug_file}" "absl_abseil_dll" "abseil_dll" IGNORE_UNCHANGED)
|
2024-05-25 10:39:45 +08:00
|
|
|
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
|
2024-06-22 04:39:50 +08:00
|
|
|
vcpkg_replace_string("${debug_file}" "-l${package}" "-llib${package}d" IGNORE_UNCHANGED)
|
2024-05-25 10:39:45 +08:00
|
|
|
else()
|
2024-06-22 04:39:50 +08:00
|
|
|
vcpkg_replace_string("${debug_file}" "-l${package}" "-l${package}d" IGNORE_UNCHANGED)
|
2024-05-25 10:39:45 +08:00
|
|
|
endif()
|
2020-07-25 02:39:21 +08:00
|
|
|
endif()
|
2024-05-25 10:39:45 +08:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
set(packages protobuf protobuf-lite)
|
|
|
|
foreach(package IN LISTS packages)
|
2024-06-22 04:39:50 +08:00
|
|
|
replace_package_string("${package}")
|
2020-07-25 02:39:21 +08:00
|
|
|
endforeach()
|
|
|
|
|
2024-05-25 10:39:45 +08:00
|
|
|
|
2021-03-27 03:55:34 +08:00
|
|
|
vcpkg_fixup_pkgconfig()
|
|
|
|
|
|
|
|
if(NOT protobuf_BUILD_PROTOC_BINARIES)
|
2022-03-16 04:26:15 +08:00
|
|
|
configure_file("${CMAKE_CURRENT_LIST_DIR}/protobuf-targets-vcpkg-protoc.cmake" "${CURRENT_PACKAGES_DIR}/share/${PORT}/protobuf-targets-vcpkg-protoc.cmake" COPYONLY)
|
2020-07-25 02:39:21 +08:00
|
|
|
endif()
|
2020-09-28 08:36:08 +08:00
|
|
|
|
2022-03-16 04:26:15 +08:00
|
|
|
configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY)
|
2024-06-22 04:39:50 +08:00
|
|
|
|
|
|
|
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share" "${CURRENT_PACKAGES_DIR}/debug/include")
|
|
|
|
|
|
|
|
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
|