Add missing file

This commit is contained in:
Simon Layton
2016-12-16 07:57:40 -05:00
parent 0154db83c0
commit dac78727fb

45
cmake/External/Protobuf.cmake vendored Normal file
View File

@ -0,0 +1,45 @@
if (NOT __PROTOBUF_INCLUDED)
set(__PROTOBUF_INCLUDED TRUE)
# try the system-wide nccl first
if(USE_SYSTEM_PROTOBUF)
find_package(Protobuf)
endif()
if (PROTOBUF_FOUND)
set(PROTOBUF_EXTERNAL FALSE)
else()
message(STATUS "Building Protobuf at ${CMAKE_SOURCE_DIR}/third_party/protobuf")
# build directory
set(protobuf_prefix ${CMAKE_SOURCE_DIR}/third_party/protobuf)
# we build glog statically, but want to link it into the caffe shared library
# this requires position-independent code
if (UNIX)
set(PROTOBUF_EXTRA_COMPILER_FLAGS "-fPIC")
endif()
set(PROTOBUF_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${PROTOBUF_EXTRA_COMPILER_FLAGS})
set(PROTOBUF_C_FLAGS ${CMAKE_C_FLAGS} ${PROTOBUF_EXTRA_COMPILER_FLAGS})
ExternalProject_Add(protobuf_external
SOURCE_DIR ${CMAKE_SOURCE_DIR}/third_party/protobuf
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND "./autogen.sh" COMMAND ./configure --prefix=${CMAKE_SOURCE_DIR}/third_party/protobuf/build
BUILD_COMMAND make
INSTALL_COMMAND make install
)
set(PROTOBUF_FOUND TRUE)
set(PROTOBUF_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/third_party/protobuf/build/include)
set(PROTOBUF_LIBRARIES ${CMAKE_SOURCE_DIR}/third_party/protobuf/build/lib/libprotobuf.so)
set(PROTOBUF_LIBRARY_DIRS ${CMAKE_SOURCE_DIR}/third_party/protobuf/build/lib)
set(PROTOBUF_PROTOC_EXECUTABLE ${CMAKE_SOURCE_DIR}/third_party/protobuf/build/bin/protoc)
set(PROTOBUF_EXTERNAL TRUE)
list(APPEND external_project_dependencies protobuf_external)
endif()
include("${CMAKE_SOURCE_DIR}/cmake/ProtoBuf.cmake")
endif()