Skip to content

Commit 6c6a97f

Browse files
committed
Fix wrong protobuf cmake variable when cmake < 3.6.0
1 parent 2a2fa36 commit 6c6a97f

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

tools/converter/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ endif()
3030

3131
# -----------find protobuf lib-----------
3232
find_package(Protobuf REQUIRED)
33+
if (${CMAKE_VERSION} VERSION_LESS "3.6.0")
34+
set(Protobuf_LIBRARIES ${PROTOBUF_LIBRARIES})
35+
set(Protobuf_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS})
36+
endif()
3337

3438
# -----------set path-----------
3539
set(SRC_PATH source)

tools/converter/source/caffe/CMakeLists.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ set(CMAKE_C_STANDARD 99)
66
set(CMAKE_CXX_STANDARD 11)
77

88
find_package(Protobuf REQUIRED)
9+
if (${CMAKE_VERSION} VERSION_LESS "3.6.0")
10+
set(Protobuf_LIBRARIES ${PROTOBUF_LIBRARIES})
11+
set(Protobuf_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS})
12+
endif()
913

10-
include_directories(${PROTOBUF_INCLUDE_DIR})
14+
include_directories(${Protobuf_INCLUDE_DIRS})
1115

1216
include_directories(${CMAKE_CURRENT_BINARY_DIR})
1317

@@ -21,4 +25,4 @@ include_directories(${CMAKE_SOURCE_DIR}/source/include)
2125
file(GLOB CAFFE_SRC ${CMAKE_SOURCE_DIR}/source/caffe/*)
2226

2327
add_library(caffe SHARED ${CAFFE_SRC} ${CAFFE_PROTO_SRCS})
24-
target_link_libraries(caffe ${Protobuf_LIBRARIES})
28+
target_link_libraries(caffe ${Protobuf_LIBRARIES})

tools/converter/source/onnx/CMakeLists.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ set(CMAKE_C_STANDARD 99)
66
set(CMAKE_CXX_STANDARD 11)
77

88
find_package(Protobuf REQUIRED)
9+
if (${CMAKE_VERSION} VERSION_LESS "3.6.0")
10+
set(Protobuf_LIBRARIES ${PROTOBUF_LIBRARIES})
11+
set(Protobuf_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS})
12+
endif()
913

10-
include_directories(${PROTOBUF_INCLUDE_DIR})
14+
include_directories(${Protobuf_INCLUDE_DIRS})
1115

1216
include_directories(${CMAKE_CURRENT_BINARY_DIR})
1317

@@ -23,4 +27,4 @@ include_directories(${CMAKE_SOURCE_DIR}/source/include)
2327

2428
file(GLOB ONNX_SRC ${CMAKE_SOURCE_DIR}/source/onnx/*)
2529
add_library(onnx SHARED ${ONNX_SRC} ${ONNX_PROTO_SRCS})
26-
target_link_libraries(onnx ${Protobuf_LIBRARIES})
30+
target_link_libraries(onnx ${Protobuf_LIBRARIES})

tools/converter/source/tensorflow/CMakeLists.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ set(CMAKE_C_STANDARD 99)
66
set(CMAKE_CXX_STANDARD 11)
77

88
find_package(Protobuf REQUIRED)
9+
if (${CMAKE_VERSION} VERSION_LESS "3.6.0")
10+
set(Protobuf_LIBRARIES ${PROTOBUF_LIBRARIES})
11+
set(Protobuf_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS})
12+
endif()
913

10-
include_directories(${PROTOBUF_INCLUDE_DIR})
14+
include_directories(${Protobuf_INCLUDE_DIRS})
1115

1216
include_directories(${CMAKE_CURRENT_BINARY_DIR})
1317

@@ -30,4 +34,4 @@ include_directories(${CMAKE_SOURCE_DIR}/source/include)
3034
file(GLOB TENSORFLOW_SRC ${CMAKE_SOURCE_DIR}/source/tensorflow/*)
3135

3236
add_library(tensorflow SHARED ${TENSORFLOW_SRC} ${TENSORFLOW_PROTO_SRCS})
33-
target_link_libraries(tensorflow ${Protobuf_LIBRARIES})
37+
target_link_libraries(tensorflow ${Protobuf_LIBRARIES})

0 commit comments

Comments
 (0)