]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/tools/ports/protobuf/portfile.cmake
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / tools / ports / protobuf / portfile.cmake
1 vcpkg_from_github(
2 OUT_SOURCE_PATH SOURCE_PATH
3 REPO protocolbuffers/protobuf
4 REF 436bd7880e458532901c58f4d9d1ea23fa7edd52 #v3.15.8
5 SHA512 88bb9a965bccfe11a07aee2c0c16eb9cc1845ea2d7500ef6def3e1c0a8155ac4eadd0ceef4b12552960dffe95a0fc82549d1abba71ca073ab86ec5de57d9cafb
6 HEAD_REF master
7 PATCHES
8 fix-static-build.patch
9 fix-default-proto-file-path.patch
10 port_def.patch
11 )
12
13 string(COMPARE EQUAL "${TARGET_TRIPLET}" "${HOST_TRIPLET}" protobuf_BUILD_PROTOC_BINARIES)
14 string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" protobuf_BUILD_SHARED_LIBS)
15 string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" protobuf_MSVC_STATIC_RUNTIME)
16
17 vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
18 FEATURES
19 zlib protobuf_WITH_ZLIB
20 )
21
22 if(VCPKG_TARGET_IS_UWP)
23 set(protobuf_BUILD_LIBPROTOC OFF)
24 else()
25 set(protobuf_BUILD_LIBPROTOC ON)
26 endif()
27
28 if (VCPKG_DOWNLOAD_MODE)
29 # download PKGCONFIG in download mode which is used in `vcpkg_fixup_pkgconfig()` at the end of this script.
30 # download it here because `vcpkg_configure_cmake()` halts execution in download mode when running configure process.
31 vcpkg_find_acquire_program(PKGCONFIG)
32 endif()
33
34 vcpkg_configure_cmake(
35 SOURCE_PATH ${SOURCE_PATH}/cmake
36 PREFER_NINJA
37 OPTIONS
38 -Dprotobuf_BUILD_SHARED_LIBS=${protobuf_BUILD_SHARED_LIBS}
39 -Dprotobuf_MSVC_STATIC_RUNTIME=${protobuf_MSVC_STATIC_RUNTIME}
40 -Dprotobuf_BUILD_TESTS=OFF
41 -DCMAKE_INSTALL_CMAKEDIR:STRING=share/protobuf
42 -Dprotobuf_BUILD_PROTOC_BINARIES=${protobuf_BUILD_PROTOC_BINARIES}
43 -Dprotobuf_BUILD_LIBPROTOC=${protobuf_BUILD_LIBPROTOC}
44 ${FEATURE_OPTIONS}
45 )
46
47 vcpkg_install_cmake()
48
49 # It appears that at this point the build hasn't actually finished. There is probably
50 # a process spawned by the build, therefore we need to wait a bit.
51
52 function(protobuf_try_remove_recurse_wait PATH_TO_REMOVE)
53 file(REMOVE_RECURSE ${PATH_TO_REMOVE})
54 if (EXISTS "${PATH_TO_REMOVE}")
55 execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 5)
56 file(REMOVE_RECURSE ${PATH_TO_REMOVE})
57 endif()
58 endfunction()
59
60 protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/include)
61
62 if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
63 vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/share/protobuf/protobuf-targets-release.cmake
64 "\${_IMPORT_PREFIX}/bin/protoc${VCPKG_HOST_EXECUTABLE_SUFFIX}"
65 "\${_IMPORT_PREFIX}/tools/protobuf/protoc${VCPKG_HOST_EXECUTABLE_SUFFIX}"
66 )
67 endif()
68
69 if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
70 file(READ ${CURRENT_PACKAGES_DIR}/debug/share/protobuf/protobuf-targets-debug.cmake DEBUG_MODULE)
71 string(REPLACE "\${_IMPORT_PREFIX}" "\${_IMPORT_PREFIX}/debug" DEBUG_MODULE "${DEBUG_MODULE}")
72 string(REPLACE "\${_IMPORT_PREFIX}/debug/bin/protoc${EXECUTABLE_SUFFIX}" "\${_IMPORT_PREFIX}/tools/protobuf/protoc${EXECUTABLE_SUFFIX}" DEBUG_MODULE "${DEBUG_MODULE}")
73 file(WRITE ${CURRENT_PACKAGES_DIR}/share/protobuf/protobuf-targets-debug.cmake "${DEBUG_MODULE}")
74 endif()
75
76 protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/share)
77
78 if(protobuf_BUILD_PROTOC_BINARIES)
79 if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" OR NOT VCPKG_CMAKE_SYSTEM_NAME)
80 vcpkg_copy_tools(TOOL_NAMES protoc AUTO_CLEAN)
81 else()
82 vcpkg_copy_tools(TOOL_NAMES protoc protoc-3.15.8.0 AUTO_CLEAN)
83 endif()
84 else()
85 file(COPY ${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT} DESTINATION ${CURRENT_PACKAGES_DIR}/tools)
86 endif()
87
88 vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/share/${PORT}/protobuf-config.cmake
89 "if(protobuf_MODULE_COMPATIBLE)"
90 "if(ON)"
91 )
92 if(NOT protobuf_BUILD_LIBPROTOC)
93 vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/share/${PORT}/protobuf-module.cmake
94 "_protobuf_find_libraries(Protobuf_PROTOC protoc)"
95 ""
96 )
97 endif()
98
99 if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
100 protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/bin)
101 protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/bin)
102 endif()
103
104 if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
105 vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/google/protobuf/stubs/platform_macros.h
106 "\#endif // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_"
107 "\#ifndef PROTOBUF_USE_DLLS\n\#define PROTOBUF_USE_DLLS\n\#endif // PROTOBUF_USE_DLLS\n\n\#endif // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_"
108 )
109 endif()
110
111 vcpkg_copy_pdbs()
112 set(packages protobuf protobuf-lite)
113 foreach(_package IN LISTS packages)
114 set(_file ${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/${_package}.pc)
115 if(EXISTS "${_file}")
116 vcpkg_replace_string(${_file} "-l${_package}" "-l${_package}d")
117 endif()
118 endforeach()
119
120 vcpkg_fixup_pkgconfig()
121
122 if(NOT protobuf_BUILD_PROTOC_BINARIES)
123 configure_file(${CMAKE_CURRENT_LIST_DIR}/protobuf-targets-vcpkg-protoc.cmake ${CURRENT_PACKAGES_DIR}/share/${PORT}/protobuf-targets-vcpkg-protoc.cmake COPYONLY)
124 endif()
125
126 configure_file(${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake ${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake @ONLY)
127 file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)