2016-09-23 23:10:37 +08:00
|
|
|
include(vcpkg_common_functions)
|
2017-05-11 03:29:10 +08:00
|
|
|
|
2018-04-26 21:23:44 +08:00
|
|
|
vcpkg_from_github(
|
|
|
|
OUT_SOURCE_PATH SOURCE_PATH
|
|
|
|
REPO google/protobuf
|
2019-06-19 04:34:43 +08:00
|
|
|
REF v3.8.0
|
|
|
|
SHA512 ba27c64e5193cd4a144bf0c9dc0d195fbbe6e580aaca01960362f0f185074588ca40046d3bcea76e1deae7508b722f6c5be484ea957122ae8e98229c7c3a4ad2
|
2018-04-26 21:23:44 +08:00
|
|
|
HEAD_REF master
|
2017-11-26 04:36:50 +08:00
|
|
|
PATCHES
|
2018-10-17 15:22:35 +08:00
|
|
|
fix-uwp.patch
|
|
|
|
disable-lite.patch
|
2017-06-12 23:26:30 +08:00
|
|
|
)
|
|
|
|
|
2018-04-26 21:23:44 +08:00
|
|
|
if(CMAKE_HOST_WIN32 AND NOT VCPKG_TARGET_ARCHITECTURE MATCHES "x64" AND NOT VCPKG_TARGET_ARCHITECTURE MATCHES "x86")
|
|
|
|
set(protobuf_BUILD_PROTOC_BINARIES OFF)
|
|
|
|
elseif(CMAKE_HOST_WIN32 AND VCPKG_CMAKE_SYSTEM_NAME)
|
|
|
|
set(protobuf_BUILD_PROTOC_BINARIES OFF)
|
|
|
|
else()
|
|
|
|
set(protobuf_BUILD_PROTOC_BINARIES ON)
|
2018-03-12 14:41:51 +08:00
|
|
|
endif()
|
2017-06-12 23:26:30 +08:00
|
|
|
|
2018-04-26 21:23:44 +08:00
|
|
|
if(NOT protobuf_BUILD_PROTOC_BINARIES AND NOT EXISTS ${CURRENT_INSTALLED_DIR}/../x86-windows/tools/protobuf)
|
|
|
|
message(FATAL_ERROR "Cross-targetting protobuf requires the x86-windows protoc to be available. Please install protobuf:x86-windows first.")
|
2017-07-01 04:59:23 +08:00
|
|
|
endif()
|
|
|
|
|
2018-04-26 21:23:44 +08:00
|
|
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
|
2017-05-11 03:29:10 +08:00
|
|
|
set(protobuf_BUILD_SHARED_LIBS ON)
|
|
|
|
else()
|
|
|
|
set(protobuf_BUILD_SHARED_LIBS OFF)
|
|
|
|
endif()
|
|
|
|
|
2018-04-26 21:23:44 +08:00
|
|
|
if(VCPKG_CRT_LINKAGE STREQUAL "static")
|
2017-05-11 03:29:10 +08:00
|
|
|
set(protobuf_MSVC_STATIC_RUNTIME ON)
|
|
|
|
else()
|
|
|
|
set(protobuf_MSVC_STATIC_RUNTIME OFF)
|
|
|
|
endif()
|
2016-09-23 23:10:37 +08:00
|
|
|
|
2017-11-02 02:04:18 +08:00
|
|
|
if("zlib" IN_LIST FEATURES)
|
|
|
|
set(protobuf_WITH_ZLIB ON)
|
|
|
|
else()
|
|
|
|
set(protobuf_WITH_ZLIB OFF)
|
|
|
|
endif()
|
|
|
|
|
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
|
2017-05-11 03:29:10 +08:00
|
|
|
-Dprotobuf_BUILD_SHARED_LIBS=${protobuf_BUILD_SHARED_LIBS}
|
|
|
|
-Dprotobuf_MSVC_STATIC_RUNTIME=${protobuf_MSVC_STATIC_RUNTIME}
|
2017-11-02 02:04:18 +08:00
|
|
|
-Dprotobuf_WITH_ZLIB=${protobuf_WITH_ZLIB}
|
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}
|
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-08-08 08:49:46 +08:00
|
|
|
if(CMAKE_HOST_WIN32)
|
|
|
|
set(EXECUTABLE_SUFFIX ".exe")
|
|
|
|
else()
|
|
|
|
set(EXECUTABLE_SUFFIX "")
|
|
|
|
endif()
|
|
|
|
|
2018-03-20 07:33:13 +08:00
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
|
|
|
file(READ ${CURRENT_PACKAGES_DIR}/share/protobuf/protobuf-targets-release.cmake RELEASE_MODULE)
|
2018-08-08 08:49:46 +08:00
|
|
|
string(REPLACE "\${_IMPORT_PREFIX}/bin/protoc${EXECUTABLE_SUFFIX}" "\${_IMPORT_PREFIX}/tools/protobuf/protoc${EXECUTABLE_SUFFIX}" RELEASE_MODULE "${RELEASE_MODULE}")
|
2018-03-20 07:33:13 +08:00
|
|
|
file(WRITE ${CURRENT_PACKAGES_DIR}/share/protobuf/protobuf-targets-release.cmake "${RELEASE_MODULE}")
|
|
|
|
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
|
|
|
|
2018-04-11 06:05:04 +08:00
|
|
|
if(CMAKE_HOST_WIN32)
|
2018-04-26 21:23:44 +08:00
|
|
|
if(protobuf_BUILD_PROTOC_BINARIES)
|
|
|
|
file(INSTALL ${CURRENT_PACKAGES_DIR}/bin/protoc.exe DESTINATION ${CURRENT_PACKAGES_DIR}/tools/protobuf)
|
|
|
|
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/protobuf)
|
|
|
|
else()
|
|
|
|
file(COPY ${CURRENT_INSTALLED_DIR}/../x86-windows/tools/protobuf 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)
|
|
|
|
protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/bin)
|
|
|
|
else()
|
|
|
|
protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/bin/protoc.exe)
|
|
|
|
protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/bin/protoc.exe)
|
|
|
|
endif()
|
2017-05-11 03:29:10 +08:00
|
|
|
else()
|
2018-12-19 09:31:37 +08:00
|
|
|
file(GLOB EXECUTABLES ${CURRENT_PACKAGES_DIR}/bin/protoc*)
|
|
|
|
foreach(E IN LISTS EXECUTABLES)
|
|
|
|
file(INSTALL ${E} DESTINATION ${CURRENT_PACKAGES_DIR}/tools/protobuf
|
|
|
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ)
|
|
|
|
endforeach()
|
2018-04-11 06:05:04 +08:00
|
|
|
protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/bin)
|
|
|
|
protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/bin)
|
2017-05-11 03:29:10 +08:00
|
|
|
endif()
|
|
|
|
|
2018-10-17 15:22:35 +08:00
|
|
|
if(EXISTS ${CURRENT_PACKAGES_DIR}/lib/libprotobuf-lite.lib)
|
|
|
|
message(FATAL_ERROR "Expected to not build the lite runtime because it contains some of the same symbols as the full runtime.")
|
|
|
|
endif()
|
|
|
|
|
2018-04-26 21:23:44 +08:00
|
|
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
|
2017-09-09 07:58:25 +08:00
|
|
|
file(READ ${CURRENT_PACKAGES_DIR}/include/google/protobuf/stubs/platform_macros.h _contents)
|
|
|
|
string(REPLACE "\#endif // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_" "\#define PROTOBUF_USE_DLLS\n\#endif // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_" _contents "${_contents}")
|
|
|
|
file(WRITE ${CURRENT_PACKAGES_DIR}/include/google/protobuf/stubs/platform_macros.h "${_contents}")
|
|
|
|
endif()
|
2017-07-08 08:51:59 +08:00
|
|
|
|
2017-05-11 03:29:10 +08:00
|
|
|
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/protobuf RENAME copyright)
|
2016-09-23 23:10:37 +08:00
|
|
|
vcpkg_copy_pdbs()
|