Debian Codegraph @

extra/protobuf/protobuf-24.4/cmake/libprotobuf.cmake

raw
1 # CMake definitions for libprotobuf (the "full" C++ protobuf runtime).
2
3 include(${protobuf_SOURCE_DIR}/src/file_lists.cmake)
4 include(${protobuf_SOURCE_DIR}/cmake/protobuf-configure-target.cmake)
5
6 add_library(libprotobuf ${protobuf_SHARED_OR_STATIC}
7 ${libprotobuf_srcs}
8 ${libprotobuf_hdrs}
9 ${protobuf_version_rc_file})
10
11 ADD_OBJDUMP_TARGET(show_libprotobuf "$<TARGET_FILE:libprotobuf>"
12 DEPENDS libprotobuf)
13 ADD_LIBRARY(ext::libprotobuf ALIAS libprotobuf)
14
15 # Disable this, we have our own version script
16 if(FALSE AND protobuf_HAVE_LD_VERSION_SCRIPT)
17 if(${CMAKE_VERSION} VERSION_GREATER 3.13 OR ${CMAKE_VERSION} VERSION_EQUAL 3.13)
18 target_link_options(libprotobuf PRIVATE -Wl,--version-script=${protobuf_SOURCE_DIR}/src/libprotobuf.map)
19 elseif(protobuf_BUILD_SHARED_LIBS)
20 target_link_libraries(libprotobuf PRIVATE -Wl,--version-script=${protobuf_SOURCE_DIR}/src/libprotobuf.map)
21 endif()
22 set_target_properties(libprotobuf PROPERTIES
23 LINK_DEPENDS ${protobuf_SOURCE_DIR}/src/libprotobuf.map)
24 endif()
25 target_link_libraries(libprotobuf PRIVATE ${CMAKE_THREAD_LIBS_INIT})
26 if(protobuf_WITH_ZLIB)
27 target_link_libraries(libprotobuf PRIVATE ${ZLIB_LIBRARIES})
28 endif()
29 if(protobuf_LINK_LIBATOMIC)
30 target_link_libraries(libprotobuf PRIVATE atomic)
31 endif()
32 if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
33 target_link_libraries(libprotobuf PRIVATE log)
34 endif()
35 target_include_directories(libprotobuf PUBLIC ${protobuf_SOURCE_DIR}/src)
36 target_link_libraries(libprotobuf PUBLIC ${protobuf_ABSL_USED_TARGETS})
37 protobuf_configure_target(libprotobuf)
38 if(protobuf_BUILD_SHARED_LIBS)
39 target_compile_definitions(libprotobuf
40 PUBLIC PROTOBUF_USE_DLLS
41 PRIVATE LIBPROTOBUF_EXPORTS)
42 endif()
43 set_target_properties(libprotobuf PROPERTIES
44 VERSION ${protobuf_VERSION}
45 OUTPUT_NAME ${LIB_PREFIX}protobuf
46 DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}"
47 # For -fvisibility=hidden and -fvisibility-inlines-hidden
48 C_VISIBILITY_PRESET hidden
49 CXX_VISIBILITY_PRESET hidden
50 VISIBILITY_INLINES_HIDDEN ON
51 )
52 add_library(protobuf::libprotobuf ALIAS libprotobuf)
53
54 target_link_libraries(libprotobuf PRIVATE utf8_validity)
55
56 ################################################################
57
58 IF(protobuf_BUILD_SHARED_LIBS)
59 SET_TARGET_PROPERTIES(libprotobuf PROPERTIES
60 DEBUG_POSTFIX ""
61 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/library_output_directory
62 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/library_output_directory
63 )
64
65 IF(LINUX)
66 SET_TARGET_PROPERTIES(libprotobuf
67 PROPERTIES LINK_FLAGS
68 "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libprotobuf.ver"
69 )
70 SET_TARGET_PROPERTIES(libprotobuf
71 PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libprotobuf.ver
72 )
73 ENDIF()
74 IF(APPLE)
75 TARGET_LINK_OPTIONS(libprotobuf PRIVATE LINKER:-no_warn_duplicate_libraries)
76 ENDIF()
77
78 IF(WIN32)
79 ADD_CUSTOM_COMMAND(TARGET libprotobuf POST_BUILD
80 COMMAND ${CMAKE_COMMAND} -E copy_if_different
81 "${CMAKE_BINARY_DIR}/library_output_directory/${CMAKE_CFG_INTDIR}/$<TARGET_FILE_NAME:libprotobuf>"
82 "${CMAKE_BINARY_DIR}/runtime_output_directory/${CMAKE_CFG_INTDIR}/$<TARGET_FILE_NAME:libprotobuf>"
83 )
84
85 SET_TARGET_PROPERTIES(libprotobuf PROPERTIES
86 DEBUG_POSTFIX "-debug")
87 INSTALL_DEBUG_TARGET(libprotobuf
88 DESTINATION "${INSTALL_BINDIR}"
89 COMPONENT SharedLibraries
90 )
91 ENDIF()
92
93 INSTALL_PRIVATE_LIBRARY(libprotobuf)
94
95 ENDIF()