trezor: support c++17 and protobuf v25, libusb fix

- fix If there is no protobuf version installed, if fails
- passphrase test fix, wallet keys init was missing
This commit is contained in:
Dusan Klinec
2023-11-10 00:36:31 +01:00
parent 7b7958bbd9
commit 4689ad2d3c
5 changed files with 39 additions and 20 deletions

View File

@@ -75,7 +75,13 @@ if (USE_DEVICE_TREZOR)
# Protobuf is required to build protobuf messages for Trezor
include(FindProtobuf OPTIONAL)
FIND_PACKAGE(Protobuf CONFIG)
# PkgConfig works better with new Protobuf
find_package(PkgConfig QUIET)
pkg_check_modules(PROTOBUF protobuf)
if (NOT Protobuf_FOUND)
FIND_PACKAGE(Protobuf CONFIG)
endif()
if (NOT Protobuf_FOUND)
FIND_PACKAGE(Protobuf)
endif()
@@ -83,11 +89,11 @@ if (USE_DEVICE_TREZOR)
_trezor_protobuf_fix_vars()
# Early fail for optional Trezor support
if(${Protobuf_VERSION} GREATER 21)
trezor_fatal_msg("Trezor: Unsupported Protobuf version ${Protobuf_VERSION}. Please, use Protobuf v21.")
elseif(NOT Protobuf_FOUND AND NOT Protobuf_LIBRARY AND NOT Protobuf_PROTOC_EXECUTABLE AND NOT Protobuf_INCLUDE_DIR)
if(NOT Protobuf_FOUND AND NOT Protobuf_LIBRARY AND NOT Protobuf_PROTOC_EXECUTABLE AND NOT Protobuf_INCLUDE_DIR)
trezor_fatal_msg("Trezor: Could not find Protobuf")
elseif(NOT Protobuf_LIBRARY OR NOT EXISTS "${Protobuf_LIBRARY}")
elseif(${CMAKE_CXX_STANDARD} LESS 17 AND ${Protobuf_VERSION} GREATER 21)
trezor_fatal_msg("Trezor: Unsupported Protobuf version ${Protobuf_VERSION} with C++ ${CMAKE_CXX_STANDARD}. Please, use Protobuf v21.")
elseif(NOT Protobuf_LIBRARY)
trezor_fatal_msg("Trezor: Protobuf library not found: ${Protobuf_LIBRARY}")
unset(Protobuf_FOUND)
elseif(NOT Protobuf_PROTOC_EXECUTABLE OR NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
@@ -150,9 +156,10 @@ if(Protobuf_FOUND AND USE_DEVICE_TREZOR AND TREZOR_PYTHON)
endif()
if(USE_DEVICE_TREZOR_PROTOBUF_TEST)
# For now, Protobuf v21 is the maximum supported version as v23 requires C++17. TODO: Remove once we move to C++17
if(${Protobuf_VERSION} GREATER 21)
trezor_fatal_msg("Trezor: Unsupported Protobuf version ${Protobuf_VERSION}. Please, use Protobuf v21.")
if(PROTOBUF_LDFLAGS)
set(PROTOBUF_TRYCOMPILE_LINKER "${PROTOBUF_LDFLAGS}")
else()
set(PROTOBUF_TRYCOMPILE_LINKER "${Protobuf_LIBRARY}")
endif()
try_compile(Protobuf_COMPILE_TEST_PASSED
@@ -164,7 +171,7 @@ if(Protobuf_FOUND AND USE_DEVICE_TREZOR AND TREZOR_PYTHON)
CMAKE_EXE_LINKER_FLAGS ${CMAKE_TRY_COMPILE_LINKER_FLAGS}
"-DINCLUDE_DIRECTORIES=${Protobuf_INCLUDE_DIR};${CMAKE_BINARY_DIR}"
"-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
LINK_LIBRARIES ${Protobuf_LIBRARY} ${CMAKE_TRY_COMPILE_LINK_LIBRARIES}
LINK_LIBRARIES "${PROTOBUF_TRYCOMPILE_LINKER}" ${CMAKE_TRY_COMPILE_LINK_LIBRARIES}
OUTPUT_VARIABLE OUTPUT
)
if(NOT Protobuf_COMPILE_TEST_PASSED)