|
14 | 14 |
|
15 | 15 | INCLUDE(ExternalProject)
|
16 | 16 | # Always invoke `FIND_PACKAGE(Protobuf)` for importing function protobuf_generate_cpp
|
| 17 | +IF(NOT WIN32) |
17 | 18 | FIND_PACKAGE(Protobuf QUIET)
|
| 19 | +ENDIF(NOT WIN32) |
18 | 20 | macro(UNSET_VAR VAR_NAME)
|
19 | 21 | UNSET(${VAR_NAME} CACHE)
|
20 | 22 | UNSET(${VAR_NAME})
|
21 | 23 | endmacro()
|
| 24 | + |
22 | 25 | UNSET_VAR(PROTOBUF_INCLUDE_DIR)
|
23 | 26 | UNSET_VAR(PROTOBUF_FOUND)
|
24 | 27 | UNSET_VAR(PROTOBUF_PROTOC_EXECUTABLE)
|
@@ -94,12 +97,14 @@ macro(PROMPT_PROTOBUF_LIB)
|
94 | 97 | SET(protobuf_DEPS ${ARGN})
|
95 | 98 |
|
96 | 99 | MESSAGE(STATUS "Protobuf protoc executable: ${PROTOBUF_PROTOC_EXECUTABLE}")
|
| 100 | + MESSAGE(STATUS "Protobuf-lite library: ${PROTOBUF_LITE_LIBRARY}") |
97 | 101 | MESSAGE(STATUS "Protobuf library: ${PROTOBUF_LIBRARY}")
|
| 102 | + MESSAGE(STATUS "Protoc library: ${PROTOBUF_PROTOC_LIBRARY}") |
98 | 103 | MESSAGE(STATUS "Protobuf version: ${PROTOBUF_VERSION}")
|
99 | 104 | INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
|
100 | 105 |
|
101 | 106 | # Assuming that all the protobuf libraries are of the same type.
|
102 |
| - IF(${PROTOBUF_LIBRARY} MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}$") |
| 107 | + IF(${PROTOBUF_LIBRARY} MATCHES ${CMAKE_STATIC_LIBRARY_SUFFIX}) |
103 | 108 | SET(protobuf_LIBTYPE STATIC)
|
104 | 109 | ELSEIF(${PROTOBUF_LIBRARY} MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$")
|
105 | 110 | SET(protobuf_LIBTYPE SHARED)
|
@@ -137,18 +142,25 @@ macro(SET_PROTOBUF_VERSION)
|
137 | 142 | endmacro()
|
138 | 143 |
|
139 | 144 | set(PROTOBUF_ROOT "" CACHE PATH "Folder contains protobuf")
|
| 145 | +IF (WIN32) |
| 146 | + SET(PROTOBUF_ROOT ${THIRD_PARTY_PATH}/install/protobuf) |
| 147 | + MESSAGE(WARNING, "In windows, protobuf only support msvc build, please build it manually and put it at " ${PROTOBUF_ROOT}) |
| 148 | +ENDIF(WIN32) |
| 149 | + |
140 | 150 | if (NOT "${PROTOBUF_ROOT}" STREQUAL "")
|
| 151 | + |
141 | 152 | find_path(PROTOBUF_INCLUDE_DIR google/protobuf/message.h PATHS ${PROTOBUF_ROOT}/include NO_DEFAULT_PATH)
|
142 |
| - find_library(PROTOBUF_LIBRARY protobuf PATHS ${PROTOBUF_ROOT}/lib NO_DEFAULT_PATH) |
143 |
| - find_library(PROTOBUF_LITE_LIBRARY protobuf-lite PATHS ${PROTOBUF_ROOT}/lib NO_DEFAULT_PATH) |
144 |
| - find_library(PROTOBUF_PROTOC_LIBRARY protoc PATHS ${PROTOBUF_ROOT}/lib NO_DEFAULT_PATH) |
| 153 | + find_library(PROTOBUF_LIBRARY protobuf libprotobuf.lib PATHS ${PROTOBUF_ROOT}/lib NO_DEFAULT_PATH) |
| 154 | + find_library(PROTOBUF_LITE_LIBRARY protobuf-lite libprotobuf-lite.lib PATHS ${PROTOBUF_ROOT}/lib NO_DEFAULT_PATH) |
| 155 | + find_library(PROTOBUF_PROTOC_LIBRARY protoc libprotoc.lib PATHS ${PROTOBUF_ROOT}/lib NO_DEFAULT_PATH) |
145 | 156 | find_program(PROTOBUF_PROTOC_EXECUTABLE protoc PATHS ${PROTOBUF_ROOT}/bin NO_DEFAULT_PATH)
|
146 | 157 | if (PROTOBUF_INCLUDE_DIR AND PROTOBUF_LIBRARY AND PROTOBUF_LITE_LIBRARY AND PROTOBUF_PROTOC_LIBRARY AND PROTOBUF_PROTOC_EXECUTABLE)
|
147 | 158 | message(STATUS "Using custom protobuf library in ${PROTOBUF_ROOT}.")
|
| 159 | + SET(PROTOBUF_FOUND true) |
148 | 160 | SET_PROTOBUF_VERSION()
|
149 | 161 | PROMPT_PROTOBUF_LIB()
|
150 | 162 | else()
|
151 |
| - message(WARNING "Cannot find protobuf library in ${PROTOBUF_ROOT}.") |
| 163 | + message(WARNING "Cannot find protobuf library in ${PROTOBUF_ROOT}") |
152 | 164 | endif()
|
153 | 165 | endif()
|
154 | 166 |
|
@@ -239,6 +251,7 @@ IF(CMAKE_CROSSCOMPILING)
|
239 | 251 | CACHE FILEPATH "protobuf executable." FORCE)
|
240 | 252 | ENDIF()
|
241 | 253 |
|
| 254 | + |
242 | 255 | IF(NOT PROTOBUF_FOUND)
|
243 | 256 | build_protobuf(extern_protobuf FALSE)
|
244 | 257 |
|
|
0 commit comments