# 写到了cmake默认查找地点/usr/share/cmake-3.16/Modules # Locate and configure the Google Protocol Buffers library # # Adds the following targets: # # protobuf::libprotobuf - Protobuf library # protobuf::libprotobuf-lite - Protobuf lite library # protobuf::libprotoc - Protobuf Protoc Library # protobuf::protoc - protoc executable # # # Generates C++ sources from the .proto files # # protobuf_generate_cpp ( [...]) # # SRCS - variable to define with autogenerated source files # HDRS - variable to define with autogenerated header files # DEST - directory where the source files will be created # ARGN - .proto files # if(NOT DEFINED PROTOBUF_ROOT) message(FATAL_ERROR "PROTOBUF_ROOT not set in FindgRPC.cmake") else() find_path(PROTOBUF_INCLUDE_DIR google/protobuf/service.h ${PROTOBUF_ROOT}/include) mark_as_advanced(PROTOBUF_INCLUDE_DIR) message("${BoldGreen}Find_package protobuf: PROTOBUF_INCLUDE_DIR is ${PROTOBUF_INCLUDE_DIR}${ColourReset}") set(PROTOBUF_BINARY_DIR ${PROTOBUF_ROOT}/bin) set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${PROTOBUF_ROOT}/lib) endif () # The Protobuf library find_library(PROTOBUF_LIBRARY NAMES protobuf) mark_as_advanced(PROTOBUF_LIBRARY) add_library(protobuf::libprotobuf UNKNOWN IMPORTED) set_target_properties(protobuf::libprotobuf PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${PROTOBUF_INCLUDE_DIR} INTERFACE_LINK_LIBRARIES pthread IMPORTED_LOCATION ${PROTOBUF_LIBRARY} ) # The Protobuf lite library find_library(PROTOBUF_LITE_LIBRARY NAMES protobuf-lite) mark_as_advanced(PROTOBUF_LITE_LIBRARY) add_library(protobuf::libprotobuf-lite UNKNOWN IMPORTED) set_target_properties(protobuf::libprotobuf-lite PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${PROTOBUF_INCLUDE_DIR} INTERFACE_LINK_LIBRARIES pthread IMPORTED_LOCATION ${PROTOBUF_LITE_LIBRARY} ) # The Protobuf Protoc Library find_library(PROTOBUF_PROTOC_LIBRARY NAMES protoc) mark_as_advanced(PROTOBUF_PROTOC_LIBRARY) add_library(protobuf::libprotoc UNKNOWN IMPORTED) set_target_properties(protobuf::libprotoc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${PROTOBUF_INCLUDE_DIR} INTERFACE_LINK_LIBRARIES protobuf::libprotobuf IMPORTED_LOCATION ${PROTOBUF_PROTOC_LIBRARY} ) # Find the protoc Executable find_program(PROTOBUF_PROTOC_EXECUTABLE protoc ${PROTOBUF_BINARY_DIR}) mark_as_advanced(PROTOBUF_PROTOC_EXECUTABLE) message("${BoldGreen}PROTOBUF_PROTOC_EXECUTABLE is ${PROTOBUF_PROTOC_EXECUTABLE}${ColourReset}") add_executable(protobuf::protoc IMPORTED) set_target_properties(protobuf::protoc PROPERTIES IMPORTED_LOCATION ${PROTOBUF_PROTOC_EXECUTABLE} ) include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Protobuf DEFAULT_MSG PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR PROTOBUF_PROTOC_EXECUTABLE)