Skip to content

Commit 733a3c6

Browse files
committed
Allow linkage to system protobuf
1 parent 5a21cd9 commit 733a3c6

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tensorflow_cc/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ project(
99
option(ALLOW_CUDA "Try to find and use CUDA." ON)
1010
option(REQUIRE_CUDA "Make sure to find and use CUDA (implies ALLOW_CUDA)." OFF)
1111
set(TENSORFLOW_TAG "v${version}" CACHE STRING "The tensorflow release tag to be checked out (default v${version}).")
12+
option(SYSTEM_PROTOBUF "Link to system protobuf." OFF)
1213
set(TARGET_CXX_STANDARD "cxx_std_11" CACHE STRING "C++ standard to be enforced when linking to TensorflowCC targets (e.g., cxx_std_11).")
1314

1415
# -------------
@@ -53,6 +54,17 @@ target_link_libraries(
5354
"${CMAKE_INSTALL_PREFIX}/lib/libtensorflow_cc.so.${PROJECT_VERSION_MAJOR}"
5455
dl pthread
5556
)
57+
if(SYSTEM_PROTOBUF)
58+
find_package(Protobuf REQUIRED)
59+
target_include_directories(
60+
tensorflow_cc INTERFACE
61+
"${Protobuf_INCLUDE_DIRS}"
62+
)
63+
target_link_libraries(
64+
tensorflow_cc INTERFACE
65+
"${Protobuf_LIBRARIES}"
66+
)
67+
endif()
5668

5769
# ----------------------------------------
5870
# Configure CMake Config and Version Files

0 commit comments

Comments
 (0)