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