]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/ci/ports/protobuf/portfile.cmake
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / ci / ports / protobuf / portfile.cmake
1 vcpkg_from_github(
2 OUT_SOURCE_PATH SOURCE_PATH
3 REPO protocolbuffers/protobuf
4 REF 31ebe2ac71400344a5db91ffc13c4ddfb7589f92 #v3.12.3
5 SHA512 74e623547bb9448ccea29925172bf13fcbffab80eb02f58d248180000b4ae7249f0dee88bb4ef438857b0e1a96a600ab270ebf3b58568da28cbf97d8a2398297
6 HEAD_REF master
7 PATCHES
8 fix-uwp.patch
9 fix-android-log.patch
10 fix-static-build.patch
11 )
12
13 if(CMAKE_HOST_WIN32 AND NOT VCPKG_TARGET_ARCHITECTURE MATCHES "x64" AND NOT VCPKG_TARGET_ARCHITECTURE MATCHES "x86")
14 set(protobuf_BUILD_PROTOC_BINARIES OFF)
15 elseif(CMAKE_HOST_WIN32 AND VCPKG_CMAKE_SYSTEM_NAME)
16 set(protobuf_BUILD_PROTOC_BINARIES OFF)
17 else()
18 set(protobuf_BUILD_PROTOC_BINARIES ON)
19 endif()
20
21 if(NOT protobuf_BUILD_PROTOC_BINARIES AND NOT EXISTS ${CURRENT_INSTALLED_DIR}/../x86-windows/tools/protobuf)
22 message(FATAL_ERROR "Cross-targeting protobuf requires the x86-windows protoc to be available. Please install protobuf:x86-windows first.")
23 endif()
24
25 if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
26 set(VCPKG_BUILD_SHARED_LIBS ON)
27 else()
28 set(VCPKG_BUILD_SHARED_LIBS OFF)
29 endif()
30
31 if(VCPKG_CRT_LINKAGE STREQUAL "dynamic")
32 set(VCPKG_BUILD_STATIC_CRT OFF)
33 else()
34 set(VCPKG_BUILD_STATIC_CRT ON)
35 endif()
36
37 vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
38 zlib protobuf_WITH_ZLIB
39 )
40
41
42 vcpkg_configure_cmake(
43 SOURCE_PATH ${SOURCE_PATH}/cmake
44 PREFER_NINJA
45 OPTIONS
46 -Dprotobuf_BUILD_SHARED_LIBS=${VCPKG_BUILD_SHARED_LIBS}
47 -Dprotobuf_MSVC_STATIC_RUNTIME=${VCPKG_BUILD_STATIC_CRT}
48 -Dprotobuf_BUILD_TESTS=OFF
49 -DCMAKE_INSTALL_CMAKEDIR:STRING=share/protobuf
50 -Dprotobuf_BUILD_PROTOC_BINARIES=${protobuf_BUILD_PROTOC_BINARIES}
51 ${FEATURE_OPTIONS}
52 )
53
54 vcpkg_install_cmake()
55
56 # It appears that at this point the build hasn't actually finished. There is probably
57 # a process spawned by the build, therefore we need to wait a bit.
58
59 function(protobuf_try_remove_recurse_wait PATH_TO_REMOVE)
60 file(REMOVE_RECURSE ${PATH_TO_REMOVE})
61 if (EXISTS "${PATH_TO_REMOVE}")
62 execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 5)
63 file(REMOVE_RECURSE ${PATH_TO_REMOVE})
64 endif()
65 endfunction()
66
67 protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/include)
68
69 if(CMAKE_HOST_WIN32)
70 set(EXECUTABLE_SUFFIX ".exe")
71 else()
72 set(EXECUTABLE_SUFFIX "")
73 endif()
74
75 if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
76 vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/share/protobuf/protobuf-targets-release.cmake
77 "\${_IMPORT_PREFIX}/bin/protoc${EXECUTABLE_SUFFIX}"
78 "\${_IMPORT_PREFIX}/tools/protobuf/protoc${EXECUTABLE_SUFFIX}"
79 )
80 endif()
81
82 if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
83 file(READ ${CURRENT_PACKAGES_DIR}/debug/share/protobuf/protobuf-targets-debug.cmake DEBUG_MODULE)
84 string(REPLACE "\${_IMPORT_PREFIX}" "\${_IMPORT_PREFIX}/debug" DEBUG_MODULE "${DEBUG_MODULE}")
85 string(REPLACE "\${_IMPORT_PREFIX}/debug/bin/protoc${EXECUTABLE_SUFFIX}" "\${_IMPORT_PREFIX}/tools/protobuf/protoc${EXECUTABLE_SUFFIX}" DEBUG_MODULE "${DEBUG_MODULE}")
86 file(WRITE ${CURRENT_PACKAGES_DIR}/share/protobuf/protobuf-targets-debug.cmake "${DEBUG_MODULE}")
87 endif()
88
89 protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/share)
90
91 if(CMAKE_HOST_WIN32)
92 if(protobuf_BUILD_PROTOC_BINARIES)
93 file(INSTALL ${CURRENT_PACKAGES_DIR}/bin/protoc.exe DESTINATION ${CURRENT_PACKAGES_DIR}/tools/${PORT})
94 vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT})
95 else()
96 file(COPY ${CURRENT_INSTALLED_DIR}/../x86-windows/tools/${PORT} DESTINATION ${CURRENT_PACKAGES_DIR}/tools)
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 else()
103 protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/bin/protoc.exe)
104 protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/bin/protoc.exe)
105 endif()
106 else()
107 file(GLOB EXECUTABLES ${CURRENT_PACKAGES_DIR}/bin/protoc*)
108 foreach(E IN LISTS EXECUTABLES)
109 file(INSTALL ${E} DESTINATION ${CURRENT_PACKAGES_DIR}/tools/${PORT}
110 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ)
111 endforeach()
112 protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/bin)
113 protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/bin)
114 endif()
115
116 if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
117 vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/google/protobuf/stubs/platform_macros.h
118 "\#endif // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_"
119 "\#ifndef PROTOBUF_USE_DLLS\n\#define PROTOBUF_USE_DLLS\n\#endif // PROTOBUF_USE_DLLS\n\n\#endif // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_"
120 )
121 endif()
122
123 file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
124 vcpkg_copy_pdbs()