Skip to content

Commit 9866a0e

Browse files
committed
Merge pull request monero-project#9480
9c7e6ab ci: fix windows msys2 build (tobtoht)
2 parents fabbde3 + 9c7e6ab commit 9866a0e

File tree

2 files changed

+12
-62
lines changed

2 files changed

+12
-62
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,7 @@ jobs:
6868
- uses: msys2/setup-msys2@v2
6969
with:
7070
update: true
71-
install: mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-ccache mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-libusb mingw-w64-x86_64-unbound git
72-
- shell: msys2 {0}
73-
run: |
74-
curl -O https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-protobuf-c-1.4.1-1-any.pkg.tar.zst
75-
curl -O https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-protobuf-21.9-1-any.pkg.tar.zst
76-
pacman --noconfirm -U mingw-w64-x86_64-protobuf-c-1.4.1-1-any.pkg.tar.zst mingw-w64-x86_64-protobuf-21.9-1-any.pkg.tar.zst
71+
install: mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-ccache mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-protobuf mingw-w64-x86_64-libusb mingw-w64-x86_64-unbound git pkg-config
7772
- name: build
7873
run: |
7974
${{env.CCACHE_SETTINGS}}

cmake/CheckTrezor.cmake

Lines changed: 11 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,6 @@ OPTION(USE_DEVICE_TREZOR_UDP_RELEASE "Trezor UdpTransport in release mode" $ENV{
2323
OPTION(USE_DEVICE_TREZOR_DEBUG "Trezor Debugging enabled" $ENV{USE_DEVICE_TREZOR_DEBUG})
2424
OPTION(TREZOR_DEBUG "Main Trezor debugging switch" $ENV{TREZOR_DEBUG})
2525

26-
# Helper function to fix cmake < 3.6.0 FindProtobuf variables
27-
function(_trezor_protobuf_fix_vars)
28-
if(${CMAKE_VERSION} VERSION_LESS "3.6.0")
29-
foreach(UPPER
30-
PROTOBUF_SRC_ROOT_FOLDER
31-
PROTOBUF_IMPORT_DIRS
32-
PROTOBUF_DEBUG
33-
PROTOBUF_LIBRARY
34-
PROTOBUF_PROTOC_LIBRARY
35-
PROTOBUF_INCLUDE_DIR
36-
PROTOBUF_PROTOC_EXECUTABLE
37-
PROTOBUF_LIBRARY_DEBUG
38-
PROTOBUF_PROTOC_LIBRARY_DEBUG
39-
PROTOBUF_LITE_LIBRARY
40-
PROTOBUF_LITE_LIBRARY_DEBUG
41-
)
42-
if (DEFINED ${UPPER})
43-
string(REPLACE "PROTOBUF_" "Protobuf_" Camel ${UPPER})
44-
if (NOT DEFINED ${Camel})
45-
set(${Camel} ${${UPPER}} PARENT_SCOPE)
46-
endif()
47-
endif()
48-
endforeach()
49-
endif()
50-
endfunction()
51-
5226
macro(trezor_fatal_msg msg)
5327
if ($ENV{USE_DEVICE_TREZOR_MANDATORY})
5428
message(FATAL_ERROR
@@ -72,40 +46,21 @@ endmacro()
7246

7347
# Use Trezor master switch
7448
if (USE_DEVICE_TREZOR)
75-
# Protobuf is required to build protobuf messages for Trezor
76-
include(FindProtobuf OPTIONAL)
49+
# Look for protobuf-config.cmake, provided by Protobuf
50+
find_package(Protobuf CONFIG)
7751

78-
# PkgConfig works better with new Protobuf
79-
find_package(PkgConfig QUIET)
80-
pkg_check_modules(PROTOBUF protobuf)
81-
82-
if (NOT Protobuf_FOUND)
83-
FIND_PACKAGE(Protobuf CONFIG)
84-
endif()
85-
if (NOT Protobuf_FOUND)
86-
FIND_PACKAGE(Protobuf)
52+
if (Protobuf_FOUND)
53+
# https://github.com/protocolbuffers/protobuf/issues/14576
54+
find_program(Protobuf_PROTOC_EXECUTABLE protoc REQUIRED)
55+
set(Protobuf_LIBRARY protobuf::libprotobuf) # Compatibility with FindProtobuf.cmake
56+
else()
57+
# Look for FindProtobuf.cmake, provided by CMake
58+
find_package(Protobuf)
8759
endif()
8860

89-
_trezor_protobuf_fix_vars()
90-
9161
# Early fail for optional Trezor support
92-
if(NOT Protobuf_FOUND AND NOT Protobuf_LIBRARY AND NOT Protobuf_PROTOC_EXECUTABLE AND NOT Protobuf_INCLUDE_DIR)
93-
trezor_fatal_msg("Trezor: Could not find Protobuf")
94-
elseif(${CMAKE_CXX_STANDARD} LESS 17 AND ${Protobuf_VERSION} GREATER 21)
95-
trezor_fatal_msg("Trezor: Unsupported Protobuf version ${Protobuf_VERSION} with C++ ${CMAKE_CXX_STANDARD}. Please, use Protobuf v21.")
96-
elseif(NOT Protobuf_LIBRARY)
97-
trezor_fatal_msg("Trezor: Protobuf library not found: ${Protobuf_LIBRARY}")
98-
unset(Protobuf_FOUND)
99-
elseif(NOT Protobuf_PROTOC_EXECUTABLE OR NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
100-
trezor_fatal_msg("Trezor: Protobuf executable not found: ${Protobuf_PROTOC_EXECUTABLE}")
101-
unset(Protobuf_FOUND)
102-
elseif(NOT Protobuf_INCLUDE_DIR OR NOT EXISTS "${Protobuf_INCLUDE_DIR}")
103-
trezor_fatal_msg("Trezor: Protobuf include dir not found: ${Protobuf_INCLUDE_DIR}")
104-
unset(Protobuf_FOUND)
105-
else()
106-
message(STATUS "Trezor: Protobuf lib: ${Protobuf_LIBRARY}, inc: ${Protobuf_INCLUDE_DIR}, protoc: ${Protobuf_PROTOC_EXECUTABLE}")
107-
set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIR})
108-
set(Protobuf_FOUND 1) # override found if all required info was provided by variables
62+
if (NOT Protobuf_FOUND)
63+
trezor_fatal_msg("Trezor: protobuf library not found")
10964
endif()
11065

11166
if(TREZOR_DEBUG)

0 commit comments

Comments
 (0)