Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protobuf: Use package provided config if available #11751

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2059,7 +2059,7 @@ if(STATIC_DEPS)
mark_as_advanced(Protobuf_USE_STATIC_LIBS)
endif()
add_subdirectory(src/proto)
target_link_libraries(mixxx-lib PRIVATE mixxx-proto)
target_link_libraries(mixxx-lib PUBLIC mixxx-proto)

# Rigtorp SPSC Queue
# https://github.com/rigtorp/SPSCQueue
Expand Down
26 changes: 17 additions & 9 deletions src/proto/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# Protobuf
find_package(Protobuf)

# first try the package provided config
find_package(Protobuf CONFIG)
if(NOT Protobuf_FOUND)
# Fall back to the CMake provide module
find_package(Protobuf MODULE REQUIRED)
endif()

add_library(mixxx-proto OBJECT)

if(TARGET protobuf::libprotobuf-lite)
target_link_libraries(mixxx-proto PUBLIC protobuf::libprotobuf-lite)
elseif(TARGET protobuf::libprotobuf)
target_link_libraries(mixxx-proto PUBLIC protobuf::libprotobuf)
else()
message(FATAL_ERROR "Protobuf or Protobuf-lite libraries are required to compile Mixxx.")
endif()

protobuf_generate(
LANGUAGE cpp
TARGET mixxx-proto
Expand All @@ -11,11 +27,3 @@ protobuf_generate(
skin.proto
waveform.proto
)

if(TARGET protobuf::libprotobuf-lite)
target_link_libraries(mixxx-proto PRIVATE protobuf::libprotobuf-lite)
elseif(TARGET protobuf::libprotobuf)
target_link_libraries(mixxx-proto PRIVATE protobuf::libprotobuf)
else()
message(FATAL_ERROR "Protobuf or Protobuf-lite libraries are required to compile Mixxx.")
endif()
Loading