1# CMake definitions for libprotobuf (the "full" C++ protobuf runtime). 2 3include(${protobuf_SOURCE_DIR}/src/file_lists.cmake) 4include(${protobuf_SOURCE_DIR}/cmake/protobuf-configure-target.cmake) 5 6add_library(libprotobuf ${protobuf_SHARED_OR_STATIC} 7 ${libprotobuf_srcs} 8 ${libprotobuf_hdrs} 9 ${protobuf_version_rc_file}) 10if(protobuf_HAVE_LD_VERSION_SCRIPT) 11 if(${CMAKE_VERSION} VERSION_GREATER 3.13 OR ${CMAKE_VERSION} VERSION_EQUAL 3.13) 12 target_link_options(libprotobuf PRIVATE -Wl,--version-script=${protobuf_SOURCE_DIR}/src/libprotobuf.map) 13 elseif(protobuf_BUILD_SHARED_LIBS) 14 target_link_libraries(libprotobuf PRIVATE -Wl,--version-script=${protobuf_SOURCE_DIR}/src/libprotobuf.map) 15 endif() 16 set_target_properties(libprotobuf PROPERTIES 17 LINK_DEPENDS ${protobuf_SOURCE_DIR}/src/libprotobuf.map) 18endif() 19target_link_libraries(libprotobuf PRIVATE ${CMAKE_THREAD_LIBS_INIT}) 20if(protobuf_WITH_ZLIB) 21 target_link_libraries(libprotobuf PRIVATE ${ZLIB_LIBRARIES}) 22endif() 23if(protobuf_LINK_LIBATOMIC) 24 target_link_libraries(libprotobuf PRIVATE atomic) 25endif() 26if(${CMAKE_SYSTEM_NAME} STREQUAL "Android") 27 target_link_libraries(libprotobuf PRIVATE log) 28endif() 29target_include_directories(libprotobuf PUBLIC 30 $<BUILD_INTERFACE:${protobuf_SOURCE_DIR}/src> 31 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> 32) 33target_link_libraries(libprotobuf PUBLIC ${protobuf_ABSL_USED_TARGETS}) 34protobuf_configure_target(libprotobuf) 35if(protobuf_BUILD_SHARED_LIBS) 36 target_compile_definitions(libprotobuf 37 PUBLIC PROTOBUF_USE_DLLS 38 PRIVATE LIBPROTOBUF_EXPORTS) 39endif() 40set_target_properties(libprotobuf PROPERTIES 41 VERSION ${protobuf_VERSION} 42 OUTPUT_NAME ${LIB_PREFIX}protobuf 43 DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}" 44 # For -fvisibility=hidden and -fvisibility-inlines-hidden 45 C_VISIBILITY_PRESET hidden 46 CXX_VISIBILITY_PRESET hidden 47 VISIBILITY_INLINES_HIDDEN ON 48) 49add_library(protobuf::libprotobuf ALIAS libprotobuf) 50 51target_link_libraries(libprotobuf PRIVATE utf8_validity) 52