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

CMake: fix linking protobuf #4185

Merged
merged 1 commit into from
Aug 6, 2021
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
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2074,10 +2074,6 @@ target_include_directories(mixxx-lib SYSTEM PUBLIC ${PortMidi_INCLUDE_DIRS})
target_link_libraries(mixxx-lib PRIVATE ${PortMidi_LIBRARIES})

# Protobuf
if(NOT BUILD_SHARED_LIBS)
set(Protobuf_USE_STATIC_LIBS ON)
mark_as_advanced(Protobuf_USE_STATIC_LIBS)
endif()
add_subdirectory(src/proto)
target_link_libraries(mixxx-lib PRIVATE mixxx-proto)

Expand Down
23 changes: 14 additions & 9 deletions src/proto/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Protobuf
find_package(Protobuf)
find_package(Protobuf REQUIRED)

add_library(mixxx-proto OBJECT)

include(IsStaticLibrary)
if(TARGET protobuf::libprotobuf-lite)
target_link_libraries(mixxx-proto PRIVATE protobuf::libprotobuf-lite)
is_static_library(Protobuf_USE_STATIC_LIBS protobuf::libprotobuf-lite)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm doubt this is even needed. Protobuf_USE_STATIC_LIBS is a parameter for the Protobuf find module (https://cmake.org/cmake/help/latest/module/FindProtobuf.html) so I don't think it does anything after the find_package(Protobuf REQURIED).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes. So lets remove it entirely. Do we have still a use case for setting it from Mixxx? If so, we can reintroduce it.

elseif(TARGET protobuf::libprotobuf)
target_link_libraries(mixxx-proto PRIVATE protobuf::libprotobuf)
is_static_library(Protobuf_USE_STATIC_LIBS 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 +24,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()