@ -14,11 +14,14 @@
INCLUDE ( ExternalProject )
# A l w a y s i n v o k e ` FIND_PACKAGE ( Protobuf ) ` f o r i m p o r t i n g f u n c t i o n p r o t o b u f _ g e n e r a t e _ c p p
IF ( NOT WIN32 )
FIND_PACKAGE ( Protobuf QUIET )
ENDIF ( NOT WIN32 )
macro ( UNSET_VAR VAR_NAME )
UNSET ( ${ VAR_NAME } CACHE )
UNSET ( ${ VAR_NAME } )
endmacro ( )
UNSET_VAR ( PROTOBUF_INCLUDE_DIR )
UNSET_VAR ( PROTOBUF_FOUND )
UNSET_VAR ( PROTOBUF_PROTOC_EXECUTABLE )
@ -94,12 +97,14 @@ macro(PROMPT_PROTOBUF_LIB)
SET ( protobuf_DEPS ${ ARGN } )
MESSAGE ( STATUS "Protobuf protoc executable: ${PROTOBUF_PROTOC_EXECUTABLE}" )
MESSAGE ( STATUS "Protobuf-lite library: ${PROTOBUF_LITE_LIBRARY}" )
MESSAGE ( STATUS "Protobuf library: ${PROTOBUF_LIBRARY}" )
MESSAGE ( STATUS "Protoc library: ${PROTOBUF_PROTOC_LIBRARY}" )
MESSAGE ( STATUS "Protobuf version: ${PROTOBUF_VERSION}" )
INCLUDE_DIRECTORIES ( ${ PROTOBUF_INCLUDE_DIR } )
# A s s u m i n g t h a t a l l t h e p r o t o b u f l i b r a r i e s a r e o f t h e s a m e t y p e .
IF ( ${ PROTOBUF_LIBRARY } MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}$" )
IF ( ${ PROTOBUF_LIBRARY } MATCHES ${ CMAKE_STATIC_LIBRARY_SUFFIX } )
SET ( protobuf_LIBTYPE STATIC )
ELSEIF ( ${ PROTOBUF_LIBRARY } MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$" )
SET ( protobuf_LIBTYPE SHARED )
@ -137,18 +142,25 @@ macro(SET_PROTOBUF_VERSION)
endmacro ( )
set ( PROTOBUF_ROOT "" CACHE PATH "Folder contains protobuf" )
IF ( WIN32 )
SET ( PROTOBUF_ROOT ${ THIRD_PARTY_PATH } /install/protobuf )
MESSAGE ( WARNING, "In windows, protobuf only support msvc build, please build it manually and put it at " ${ PROTOBUF_ROOT } )
ENDIF ( WIN32 )
if ( NOT "${PROTOBUF_ROOT}" STREQUAL "" )
find_path ( PROTOBUF_INCLUDE_DIR google/protobuf/message.h PATHS ${ PROTOBUF_ROOT } /include NO_DEFAULT_PATH )
find_library ( PROTOBUF_LIBRARY protobuf PATHS ${ PROTOBUF_ROOT } /lib NO_DEFAULT_PATH )
find_library ( PROTOBUF_LITE_LIBRARY protobuf-lite PATHS ${ PROTOBUF_ROOT } /lib NO_DEFAULT_PATH )
find_library ( PROTOBUF_PROTOC_LIBRARY protoc PATHS ${ PROTOBUF_ROOT } /lib NO_DEFAULT_PATH )
find_library ( PROTOBUF_LIBRARY protobuf libprotobuf.lib PATHS ${ PROTOBUF_ROOT } /lib NO_DEFAULT_PATH )
find_library ( PROTOBUF_LITE_LIBRARY protobuf-lite libprotobuf-lite.lib PATHS ${ PROTOBUF_ROOT } /lib NO_DEFAULT_PATH )
find_library ( PROTOBUF_PROTOC_LIBRARY protoc libprotoc.lib PATHS ${ PROTOBUF_ROOT } /lib NO_DEFAULT_PATH )
find_program ( PROTOBUF_PROTOC_EXECUTABLE protoc PATHS ${ PROTOBUF_ROOT } /bin NO_DEFAULT_PATH )
if ( PROTOBUF_INCLUDE_DIR AND PROTOBUF_LIBRARY AND PROTOBUF_LITE_LIBRARY AND PROTOBUF_PROTOC_LIBRARY AND PROTOBUF_PROTOC_EXECUTABLE )
message ( STATUS "Using custom protobuf library in ${PROTOBUF_ROOT}." )
SET ( PROTOBUF_FOUND true )
SET_PROTOBUF_VERSION ( )
PROMPT_PROTOBUF_LIB ( )
else ( )
message ( WARNING "Cannot find protobuf library in ${PROTOBUF_ROOT} . ")
message ( WARNING "Cannot find protobuf library in ${PROTOBUF_ROOT} ")
endif ( )
endif ( )
@ -239,6 +251,7 @@ IF(CMAKE_CROSSCOMPILING)
C A C H E F I L E P A T H " p r o t o b u f e x e c u t a b l e . " F O R C E )
ENDIF ( )
IF ( NOT PROTOBUF_FOUND )
build_protobuf ( extern_protobuf FALSE )