Tag Archives: Could not find a package configuration file provided by “Protobuf” with any of the following names: ProtobufConfig.cmake

[Solved] Protobuf & cmake Low Version Error: Could not find a package configuration file provided by “Protobuf” with any of the following names: ProtobufConfig.cmake

background

If Caffe is compiled with cmake and protobuf of a lower version (such as 2.5) is used, an error will be reported. Cmake cannot find protobuf

Solution:

Change the default cmake file of Caffe project and use PKG config to find it

Solution:

Modify the cmake file with error. The path is cmake/protobuf.Cmake under Cafe project. Modify the following two places

# Finds Google Protocol Buffers library and compilers and extends

# Modified 1:
########################
# Use pkg-config to find packages instead
set(ENV{PKG_CONFIG_PATH} /home/timber/Library/lib/pkgconfig)
#find_package( Protobuf REQUIRED )# comment out
find_package(PkgConfig)
pkg_search_module( Protobuf  REQUIRED protobuf)
#########################

list(APPEND Caffe_INCLUDE_DIRS PUBLIC ${PROTOBUF_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS PUBLIC ${PROTOBUF_LIBRARIES})

# As of Ubuntu 14.04 protoc is no longer a part of libprotobuf-dev package
# and should be installed separately as in: sudo apt-get install protobuf-compiler
if(EXISTS ${PROTOBUF_PROTOC_EXECUTABLE})
  message(STATUS "Found PROTOBUF Compiler: ${PROTOBUF_PROTOC_EXECUTABLE}")
else()
  message(FATAL_ERROR "Could not find PROTOBUF Compiler")
endif()

# Modified 2:
##########################
# Forcibly set to ON
set(PROTOBUF_FOUND ON)
if(PROTOBUF_FOUND)
##########################      
  # fetches protobuf version
  caffe_parse_header(${PROTOBUF_INCLUDE_DIR}/google/protobuf/stubs/common.h VERION_LINE GOOGLE_PROTOBUF_VERSION)
  string(REGEX MATCH "([0-9])00([0-9])00([0-9])" PROTOBUF_VERSION ${GOOGLE_PROTOBUF_VERSION})
  set(PROTOBUF_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
  unset(GOOGLE_PROTOBUF_VERSION)
endif()

# place where to generate protobuf sources
set(proto_gen_folder "${PROJECT_BINARY_DIR}/include/caffe/proto")
include_directories("${PROJECT_BINARY_DIR}/include")

set(PROTOBUF_GENERATE_CPP_APPEND_PATH TRUE)