Skip to content

Commit 1ca4e9c

Browse files
coryanfowles
authored andcommitted
fix: missing -DPROTOBUF_USE_DLLS in pkg-config (#12700)
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. Fixes #12699 FWIW, I am not sure this is an ideal fix. It may be better to fix the headers such that no macros change the ABI. Closes #12700 COPYBARA_INTEGRATE_REVIEW=#12700 from coryan:fix-define-protobuf-use-dlls-in-pkg-config-file 13c792e PiperOrigin-RevId: 530116678
1 parent d5a1b09 commit 1ca4e9c

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

cmake/install.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ foreach (_target IN LISTS _pc_target_list)
1212
string(CONCAT _protobuf_PC_REQUIRES "${_protobuf_PC_REQUIRES}" "${_sep}" "${_target}")
1313
set(_sep " ")
1414
endforeach ()
15+
set(_protobuf_PC_CFLAGS)
16+
if (protobuf_BUILD_SHARED_LIBS)
17+
set(_protobuf_PC_CFLAGS -DPROTOBUF_USE_DLLS)
18+
endif ()
1519

1620
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf.pc.cmake
1721
${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc @ONLY)

cmake/protobuf-lite.pc.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ Description: Google's Data Interchange Format
88
Version: @protobuf_VERSION@
99
Requires: @_protobuf_PC_REQUIRES@
1010
Libs: -L${libdir} -lprotobuf-lite @CMAKE_THREAD_LIBS_INIT@
11-
Cflags: -I${includedir}
11+
Cflags: -I${includedir} @_protobuf_PC_CFLAGS@
1212
Conflicts: protobuf

cmake/protobuf.pc.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ Description: Google's Data Interchange Format
88
Version: @protobuf_VERSION@
99
Requires: @_protobuf_PC_REQUIRES@
1010
Libs: -L${libdir} -lprotobuf @CMAKE_THREAD_LIBS_INIT@
11-
Cflags: -I${includedir}
11+
Cflags: -I${includedir} @_protobuf_PC_CFLAGS@
1212
Conflicts: protobuf-lite

0 commit comments

Comments
 (0)