@@ -11,7 +11,7 @@ option(REQUIRE_CUDA "Make sure to find and use CUDA (implies ALLOW_CUDA)." OFF)
1111set (LOCAL_RAM_RESOURCES 4096 CACHE STRING "The amount of local RAM resources passed to bazel scheduler (e.g., 4096)." )
1212set (LOCAL_CPU_RESOURCES HOST_CPUS CACHE STRING "The amount of local CPU cores passed to bazel scheduler (e.g., 2)." )
1313set (TENSORFLOW_TAG "v${version} " CACHE STRING "The tensorflow release tag to be checked out (default v${version} )." )
14- option (SYSTEM_PROTOBUF "Link to system protobuf ." OFF )
14+ option (INSTALL_PROTOBUF "Install protobuf compatible with tensorflow version ." OFF )
1515set (CMAKE_CXX_STANDARD 14 CACHE STRING "The C++ standard for building and linking the library (e.g., 14)." )
1616
1717# -------------
@@ -32,6 +32,9 @@ configure_file("cmake/build_tensorflow.sh.in" "build_tensorflow.sh" @ONLY)
3232# ----------------------------------------------
3333
3434include (TensorflowBase )
35+ if (INSTALL_PROTOBUF)
36+ include (ProtobufExternal )
37+ endif ()
3538
3639# ------------------------------
3740# Define Tensorflow_CC Interface
@@ -40,6 +43,10 @@ include(TensorflowBase)
4043add_library (tensorflow_cc INTERFACE )
4144target_compile_features (tensorflow_cc INTERFACE "cxx_std_${CMAKE_CXX_STANDARD} " )
4245
46+ if (INSTALL_PROTOBUF)
47+ add_dependencies (tensorflow_cc protobuf-external )
48+ endif ()
49+
4350# The include folders are sometimes contained under bazel-bin/bin/ and sometimes just bazel-bin.
4451target_include_directories (
4552 tensorflow_cc INTERFACE
@@ -53,17 +60,6 @@ target_link_libraries(
5360 "${CMAKE_INSTALL_PREFIX} /lib/libtensorflow_cc.so.${PROJECT_VERSION_MAJOR} "
5461 dl pthread
5562)
56- if (SYSTEM_PROTOBUF)
57- find_package (Protobuf REQUIRED )
58- target_include_directories (
59- tensorflow_cc INTERFACE
60- "${Protobuf_INCLUDE_DIRS} "
61- )
62- target_link_libraries (
63- tensorflow_cc INTERFACE
64- "${Protobuf_LIBRARIES} "
65- )
66- endif ()
6763
6864# ----------------------------------------
6965# Configure CMake Config and Version Files
0 commit comments