Skip to content

Commit

Permalink
CMake: fix linking protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing committed Aug 6, 2021
1 parent d06bc0e commit cfb3757
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
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_LIB protobuf::libprotobuf-lite)
elseif(TARGET protobuf::libprotobuf)
target_link_libraries(mixxx-proto PRIVATE protobuf::libprotobuf)
is_static_library(Protobuf_USE_STATIC_LIB 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()

0 comments on commit cfb3757

Please sign in to comment.