aboutsummaryrefslogtreecommitdiff
path: root/ports/protobuf
diff options
context:
space:
mode:
authorras0219 <533828+ras0219@users.noreply.github.com>2021-03-26 12:55:34 -0700
committerGitHub <noreply@github.com>2021-03-26 12:55:34 -0700
commitb5bb1511f0a07be530e0bde3ae098eb3d8e83e68 (patch)
tree62f7ed43202e512d28ac92fb2be768283f62dee9 /ports/protobuf
parent6a63ecae92e3eb26ae596e5c4ddf527f045803a4 (diff)
downloadvcpkg-b5bb1511f0a07be530e0bde3ae098eb3d8e83e68.tar.gz
vcpkg-b5bb1511f0a07be530e0bde3ae098eb3d8e83e68.zip
[many ports] Apply host dependencies (#16479)
* [vcpkg] Add VCPKG_HOST_TRIPLET. Improve vcpkg.schema.json * [many ports] Apply host dependencies * [yasm-tool] Revert yasm-tool changes to split into PR #16478 * [many ports] Add versions * [vcpkg.cmake] Revert change applied in other PR * [boost-modular-build-helper] Merge from master Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'ports/protobuf')
-rw-r--r--ports/protobuf/portfile.cmake97
-rw-r--r--ports/protobuf/protobuf-targets-vcpkg-protoc.cmake8
-rw-r--r--ports/protobuf/vcpkg-cmake-wrapper.cmake3
-rw-r--r--ports/protobuf/vcpkg.json8
4 files changed, 53 insertions, 63 deletions
diff --git a/ports/protobuf/portfile.cmake b/ports/protobuf/portfile.cmake
index a79a34ef8..1104b9c06 100644
--- a/ports/protobuf/portfile.cmake
+++ b/ports/protobuf/portfile.cmake
@@ -9,34 +9,20 @@ vcpkg_from_github(
fix-default-proto-file-path.patch
)
-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 NOT VCPKG_TARGET_IS_MINGW AND NOT (VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP))
- set(protobuf_BUILD_PROTOC_BINARIES OFF)
-else()
- set(protobuf_BUILD_PROTOC_BINARIES ON)
-endif()
-
-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.")
-endif()
+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)
-if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
- set(VCPKG_BUILD_SHARED_LIBS ON)
-else()
- set(VCPKG_BUILD_SHARED_LIBS OFF)
-endif()
+vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
+ zlib protobuf_WITH_ZLIB
+)
-if(VCPKG_CRT_LINKAGE STREQUAL "dynamic")
- set(VCPKG_BUILD_STATIC_CRT OFF)
+if(VCPKG_TARGET_IS_UWP)
+ set(protobuf_BUILD_LIBPROTOC OFF)
else()
- set(VCPKG_BUILD_STATIC_CRT ON)
+ set(protobuf_BUILD_LIBPROTOC ON)
endif()
-vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
- zlib protobuf_WITH_ZLIB
-)
-
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.
@@ -47,12 +33,13 @@ vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}/cmake
PREFER_NINJA
OPTIONS
- -Dprotobuf_BUILD_SHARED_LIBS=${VCPKG_BUILD_SHARED_LIBS}
- -Dprotobuf_MSVC_STATIC_RUNTIME=${VCPKG_BUILD_STATIC_CRT}
+ -Dprotobuf_BUILD_SHARED_LIBS=${protobuf_BUILD_SHARED_LIBS}
+ -Dprotobuf_MSVC_STATIC_RUNTIME=${protobuf_MSVC_STATIC_RUNTIME}
-Dprotobuf_BUILD_TESTS=OFF
-DCMAKE_INSTALL_CMAKEDIR:STRING=share/protobuf
-Dprotobuf_BUILD_PROTOC_BINARIES=${protobuf_BUILD_PROTOC_BINARIES}
- ${FEATURE_OPTIONS}
+ -Dprotobuf_BUILD_LIBPROTOC=${protobuf_BUILD_LIBPROTOC}
+ ${FEATURE_OPTIONS}
)
vcpkg_install_cmake()
@@ -70,17 +57,11 @@ endfunction()
protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/include)
-if(CMAKE_HOST_WIN32)
- set(EXECUTABLE_SUFFIX ".exe")
-else()
- set(EXECUTABLE_SUFFIX "")
-endif()
-
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
- vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/share/protobuf/protobuf-targets-release.cmake
- "\${_IMPORT_PREFIX}/bin/protoc${EXECUTABLE_SUFFIX}"
- "\${_IMPORT_PREFIX}/tools/protobuf/protoc${EXECUTABLE_SUFFIX}"
-)
+ 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}"
+ )
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
@@ -92,35 +73,26 @@ endif()
protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/share)
-if(CMAKE_HOST_WIN32)
- if(protobuf_BUILD_PROTOC_BINARIES)
- vcpkg_copy_tools(TOOL_NAMES protoc)
- else()
- file(COPY ${CURRENT_INSTALLED_DIR}/../x86-windows/tools/${PORT} DESTINATION ${CURRENT_PACKAGES_DIR}/tools)
- endif()
-
- if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
- protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/bin)
- protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/bin)
+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)
else()
- protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/bin/protoc.exe)
- protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/bin/protoc.exe)
+ vcpkg_copy_tools(TOOL_NAMES protoc protoc-3.14.0.0 AUTO_CLEAN)
endif()
else()
- file(GLOB EXECUTABLES ${CURRENT_PACKAGES_DIR}/bin/protoc*)
- foreach(E IN LISTS EXECUTABLES)
- file(INSTALL ${E} DESTINATION ${CURRENT_PACKAGES_DIR}/tools/${PORT}
- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ)
- endforeach()
- protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/bin)
+ file(COPY ${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT} DESTINATION ${CURRENT_PACKAGES_DIR}/tools)
+endif()
+
+if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/bin)
+ protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/bin)
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
- 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_"
-)
+ 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_"
+ )
endif()
vcpkg_copy_pdbs()
@@ -132,10 +104,11 @@ foreach(_package IN LISTS packages)
endif()
endforeach()
-if(NOT VCPKG_TARGET_IS_WINDOWS)
- set(SYSTEM_LIBRARIES SYSTEM_LIBRARIES pthread)
+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)
endif()
-vcpkg_fixup_pkgconfig(${SYSTEM_LIBRARIES})
configure_file(${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake ${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake @ONLY)
-file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) \ No newline at end of file
+file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
diff --git a/ports/protobuf/protobuf-targets-vcpkg-protoc.cmake b/ports/protobuf/protobuf-targets-vcpkg-protoc.cmake
new file mode 100644
index 000000000..245adf560
--- /dev/null
+++ b/ports/protobuf/protobuf-targets-vcpkg-protoc.cmake
@@ -0,0 +1,8 @@
+# Create imported target protobuf::protoc
+add_executable(protobuf::protoc IMPORTED)
+
+# Import target "protobuf::protoc" for configuration "Release"
+set_property(TARGET protobuf::protoc APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(protobuf::protoc PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${Protobuf_PROTOC_EXECUTABLE}"
+)
diff --git a/ports/protobuf/vcpkg-cmake-wrapper.cmake b/ports/protobuf/vcpkg-cmake-wrapper.cmake
index 1a0f683d2..542a16c2b 100644
--- a/ports/protobuf/vcpkg-cmake-wrapper.cmake
+++ b/ports/protobuf/vcpkg-cmake-wrapper.cmake
@@ -10,4 +10,7 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.3)
endif()
cmake_policy(POP)
endif()
+
+find_program(Protobuf_PROTOC_EXECUTABLE NAMES protoc PATHS "${CMAKE_CURRENT_LIST_DIR}/../../../@HOST_TRIPLET@/tools/protobuf" NO_DEFAULT_PATH)
+
_find_package(${ARGS})
diff --git a/ports/protobuf/vcpkg.json b/ports/protobuf/vcpkg.json
index fef05b79d..9d38c89fd 100644
--- a/ports/protobuf/vcpkg.json
+++ b/ports/protobuf/vcpkg.json
@@ -1,9 +1,15 @@
{
"name": "protobuf",
"version-string": "3.14.0",
- "port-version": 1,
+ "port-version": 2,
"description": "Protocol Buffers - Google's data interchange format",
"homepage": "https://github.com/protocolbuffers/protobuf",
+ "dependencies": [
+ {
+ "name": "protobuf",
+ "host": true
+ }
+ ],
"features": {
"zlib": {
"description": "ZLib based features like Gzip streams",