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
|
2020-12-01 02:08:38 +08:00
|
|
|
REF 2514f0bd7da7e2af1bed4c5d1b84f031c4d12c10 #v3.14.0
|
|
|
|
SHA512 765fd12786b405eb8b7365f1117fa16d0e268f8677e829e0a91635bb4278295c5e488949726394f84d0993f8ea8205ca66eb1f79c88cc89ad5ac4a2df483d473
|
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
|
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
|
|
|
|
zlib protobuf_WITH_ZLIB
|
|
|
|
)
|
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.
|
|
|
|
# download it here because `vcpkg_configure_cmake()` halts execution in download mode when running configure process.
|
|
|
|
vcpkg_find_acquire_program(PKGCONFIG)
|
|
|
|
endif()
|
2017-11-02 02:04:18 +08:00
|
|
|
|
2016-09-23 23:10:37 +08:00
|
|
|
vcpkg_configure_cmake(
|
2017-05-11 03:29:10 +08:00
|
|
|
SOURCE_PATH ${SOURCE_PATH}/cmake
|
2018-03-12 14:41:51 +08:00
|
|
|
PREFER_NINJA
|
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}
|
|
|
|
${FEATURE_OPTIONS}
|
2016-09-23 23:10:37 +08:00
|
|
|
)
|
|
|
|
|
2017-10-06 08:49:28 +08:00
|
|
|
vcpkg_install_cmake()
|
2016-09-23 23:10:37 +08:00
|
|
|
|
2017-01-17 10:36:47 +08:00
|
|
|
# It appears that at this point the build hasn't actually finished. There is probably
|
|
|
|
# a process spawned by the build, therefore we need to wait a bit.
|
|
|
|
|
|
|
|
function(protobuf_try_remove_recurse_wait PATH_TO_REMOVE)
|
|
|
|
file(REMOVE_RECURSE ${PATH_TO_REMOVE})
|
|
|
|
if (EXISTS "${PATH_TO_REMOVE}")
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 5)
|
|
|
|
file(REMOVE_RECURSE ${PATH_TO_REMOVE})
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/include)
|
2016-09-23 23:10:37 +08:00
|
|
|
|
2018-03-20 07:33:13 +08:00
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
2021-03-27 03:55:34 +08:00
|
|
|
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/share/protobuf/protobuf-targets-release.cmake
|
|
|
|
"\${_IMPORT_PREFIX}/bin/protoc${VCPKG_HOST_EXECUTABLE_SUFFIX}"
|
|
|
|
"\${_IMPORT_PREFIX}/tools/protobuf/protoc${VCPKG_HOST_EXECUTABLE_SUFFIX}"
|
|
|
|
)
|
2018-03-20 07:33:13 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
|
|
|
file(READ ${CURRENT_PACKAGES_DIR}/debug/share/protobuf/protobuf-targets-debug.cmake DEBUG_MODULE)
|
|
|
|
string(REPLACE "\${_IMPORT_PREFIX}" "\${_IMPORT_PREFIX}/debug" DEBUG_MODULE "${DEBUG_MODULE}")
|
2018-08-08 08:49:46 +08:00
|
|
|
string(REPLACE "\${_IMPORT_PREFIX}/debug/bin/protoc${EXECUTABLE_SUFFIX}" "\${_IMPORT_PREFIX}/tools/protobuf/protoc${EXECUTABLE_SUFFIX}" DEBUG_MODULE "${DEBUG_MODULE}")
|
2018-03-20 07:33:13 +08:00
|
|
|
file(WRITE ${CURRENT_PACKAGES_DIR}/share/protobuf/protobuf-targets-debug.cmake "${DEBUG_MODULE}")
|
|
|
|
endif()
|
2016-09-23 23:10:37 +08:00
|
|
|
|
2017-01-17 10:36:47 +08:00
|
|
|
protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/share)
|
2016-09-23 23:10:37 +08:00
|
|
|
|
2021-03-27 03:55:34 +08:00
|
|
|
if(protobuf_BUILD_PROTOC_BINARIES)
|
|
|
|
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" OR NOT VCPKG_CMAKE_SYSTEM_NAME)
|
|
|
|
vcpkg_copy_tools(TOOL_NAMES protoc AUTO_CLEAN)
|
2018-04-11 06:05:04 +08:00
|
|
|
else()
|
2021-03-27 03:55:34 +08:00
|
|
|
vcpkg_copy_tools(TOOL_NAMES protoc protoc-3.14.0.0 AUTO_CLEAN)
|
2018-04-11 06:05:04 +08:00
|
|
|
endif()
|
2017-05-11 03:29:10 +08:00
|
|
|
else()
|
2021-03-27 03:55:34 +08:00
|
|
|
file(COPY ${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT} DESTINATION ${CURRENT_PACKAGES_DIR}/tools)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
2018-04-11 06:05:04 +08:00
|
|
|
protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/bin)
|
2021-03-27 03:55:34 +08:00
|
|
|
protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/bin)
|
2017-05-11 03:29:10 +08:00
|
|
|
endif()
|
|
|
|
|
2018-04-26 21:23:44 +08:00
|
|
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
|
2021-03-27 03:55:34 +08:00
|
|
|
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/google/protobuf/stubs/platform_macros.h
|
|
|
|
"\#endif // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_"
|
|
|
|
"\#ifndef PROTOBUF_USE_DLLS\n\#define PROTOBUF_USE_DLLS\n\#endif // PROTOBUF_USE_DLLS\n\n\#endif // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_"
|
|
|
|
)
|
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()
|
2020-07-25 02:39:21 +08:00
|
|
|
set(packages protobuf protobuf-lite)
|
|
|
|
foreach(_package IN LISTS packages)
|
|
|
|
set(_file ${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/${_package}.pc)
|
|
|
|
if(EXISTS "${_file}")
|
|
|
|
vcpkg_replace_string(${_file} "-l${_package}" "-l${_package}d")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2021-03-27 03:55:34 +08:00
|
|
|
vcpkg_fixup_pkgconfig()
|
|
|
|
|
|
|
|
if(NOT protobuf_BUILD_PROTOC_BINARIES)
|
|
|
|
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
|
|
|
|
|
|
|
configure_file(${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake ${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake @ONLY)
|
2021-03-27 03:55:34 +08:00
|
|
|
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
|