Use find_package Protobuf CONFIG

This commit is contained in:
Jonas Kvinge 2023-05-14 21:52:55 +02:00
parent 58278ab1e4
commit b52ffd09b2
2 changed files with 17 additions and 11 deletions

View File

@ -117,9 +117,14 @@ else()
find_package(Iconv)
endif()
find_package(GnuTLS REQUIRED)
find_package(Protobuf REQUIRED)
if(NOT Protobuf_PROTOC_EXECUTABLE)
message(FATAL_ERROR "Missing protobuf compiler.")
if(NOT APPLE)
find_package(Protobuf CONFIG)
endif()
if(NOT Protobuf_FOUND)
find_package(Protobuf REQUIRED)
endif()
if(NOT TARGET protobuf::protoc)
message(FATAL_ERROR "Missing Protobuf compiler.")
endif()
if(LINUX)
find_package(ALSA REQUIRED)

View File

@ -1,5 +1,14 @@
cmake_minimum_required(VERSION 3.7)
# Workaround a bug in protobuf-generate.cmake (https://github.com/protocolbuffers/protobuf/issues/12450)
if(NOT protobuf_PROTOC_EXE)
set(protobuf_PROTOC_EXE "protobuf::protoc")
endif()
if(NOT Protobuf_LIBRARIES)
set(Protobuf_LIBRARIES protobuf::libprotobuf protobuf::libprotoc)
endif()
set(SOURCES tagreaderbase.cpp tagreadermessages.proto)
if(USE_TAGLIB AND TAGLIB_FOUND)
@ -47,14 +56,6 @@ target_link_libraries(libstrawberry-tagreader PRIVATE
libstrawberry-common
)
if(WIN32 AND Protobuf_VERSION VERSION_GREATER_EQUAL 4.22.0)
if (MSVC)
target_link_libraries(libstrawberry-tagreader PRIVATE abseil_dll)
else()
target_link_libraries(libstrawberry-tagreader PRIVATE absl_log_internal_message absl_log_internal_check_op)
endif()
endif()
if(USE_TAGLIB AND TAGLIB_FOUND)
target_include_directories(libstrawberry-tagreader SYSTEM PRIVATE ${TAGLIB_INCLUDE_DIRS})
target_link_libraries(libstrawberry-tagreader PRIVATE ${TAGLIB_LIBRARIES})