Skip to content

Commit

Permalink
fix: missing -DPROTOBUF_USE_DLLS in pkg-config
Browse files Browse the repository at this point in the history
When the protobuf libraries have been compiled as shared libraries the
users of the library need to add `-DPROTOBUF_USE_DLLS` to their build
line. Otherwise some symbols are missing.
  • Loading branch information
coryan committed May 6, 2023
1 parent da2c4a6 commit 13c792e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ foreach (_target IN LISTS _pc_target_list)
string(CONCAT _protobuf_PC_REQUIRES "${_protobuf_PC_REQUIRES}" "${_sep}" "${_target}")
set(_sep " ")
endforeach ()
set(_protobuf_PC_CFLAGS)
if (protobuf_BUILD_SHARED_LIBS)
set(_protobuf_PC_CFLAGS -DPROTOBUF_USE_DLLS)
endif ()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc @ONLY)
Expand Down
2 changes: 1 addition & 1 deletion cmake/protobuf-lite.pc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Description: Google's Data Interchange Format
Version: @protobuf_VERSION@
Requires: @_protobuf_PC_REQUIRES@
Libs: -L${libdir} -lprotobuf-lite @CMAKE_THREAD_LIBS_INIT@
Cflags: -I${includedir}
Cflags: -I${includedir} @_protobuf_PC_CFLAGS@
Conflicts: protobuf
2 changes: 1 addition & 1 deletion cmake/protobuf.pc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Description: Google's Data Interchange Format
Version: @protobuf_VERSION@
Requires: @_protobuf_PC_REQUIRES@
Libs: -L${libdir} -lprotobuf @CMAKE_THREAD_LIBS_INIT@
Cflags: -I${includedir}
Cflags: -I${includedir} @_protobuf_PC_CFLAGS@
Conflicts: protobuf-lite

0 comments on commit 13c792e

Please sign in to comment.