@@ -55,49 +55,9 @@ list(JOIN BUF_PROTO_COMPONENTS , BUF_PROTO_COMPONENTS_JOINED)
5555
5656if (VIAMCPPSDK_USE_DYNAMIC_PROTOS)
5757
58- # Look for the `buf` command in the usual places, and use it if
59- # found. If we can't find it, try to download it and use that.
60- #
61- # TODO: File an upstream issue with `buf.build` to add
62- # `find_package` support for it, then use it.
63- #
64- find_program (BUF_COMMAND buf)
65- if (NOT BUF_COMMAND)
66-
67- set (HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD ${CMAKE_HOST_SYSTEM_PROCESSOR} )
68- if (CMAKE_HOST_WIN32 )
69- if (HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD STREQUAL "AMD64" )
70- set (HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD x86_64)
71- elseif (HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD STREQUAL "ARM64" )
72- set (HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD arm64)
73- else ()
74- message (FATAL_ERROR "Unknown Windows platform to correct buf download URL: ${HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD} " )
75- endif ()
76- endif ()
77-
78- set (BUF_DOWNLOAD_URL https://github.com/bufbuild/buf/releases/latest/download/buf-${CMAKE_HOST_SYSTEM_NAME} -${HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD}${CMAKE_HOST_EXECUTABLE_SUFFIX} )
79-
80- message (STATUS "system name ${CMAKE_SYSTEM_NAME} host name ${CMAKE_HOST_SYSTEM_NAME} " )
81- message (STATUS "exe suffix ${CMAKE_EXECUTABLE_SUFFIX} host suffix ${CMAKE_HOST_EXECUTABLE_SUFFIX} " )
82-
83- file (
84- DOWNLOAD
85- ${BUF_DOWNLOAD_URL}
86- ${CMAKE_CURRENT_BINARY_DIR} /buf_latest${CMAKE_HOST_EXECUTABLE_SUFFIX}
87- STATUS buf_status
88- )
89- list (GET buf_status 0 buf_status_code)
90- list (GET buf_status 1 buf_status_string)
91-
92- if (NOT buf_status_code EQUAL 0)
93- message (FATAL_ERROR "No local `buf` program found (try setting PATH?) and failed to download: ${buf_status_string} for ${BUF_DOWNLOAD_URL} " )
94- endif ()
95-
96- set (BUF_COMMAND ${CMAKE_CURRENT_BINARY_DIR} /buf_latest${CMAKE_HOST_EXECUTABLE_SUFFIX} )
97- file (CHMOD ${BUF_COMMAND} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
98- endif ()
58+ viamcppsdk_get_buf()
9959
100- # TODO: IDeally we could just generate to `CMAKE_CURRENT_BINARY_DIR`
60+ # TODO: Ideally we could just generate to `CMAKE_CURRENT_BINARY_DIR`
10161 # and everything would work just fine. However, that directory also
10262 # has intermediate cmake state in it, so we can't use it as a source
10363 # for a directory copy to update the static protos, as we do
0 commit comments